//根据姓名查询用户信息
public Customer getOneUser(String name) {
try{
Configuration config = new Configuration().configure();
SessionFactory sessionFactory = config.buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction ts=session.beginTransaction();
String hql="from Customer where username='"+name+"'";
Query query=session.createQuery(hql);
Customer usr=(Customer) query.uniqueResult();
ts.commit();
session.clear();
return usr;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
这段代码有什么问题?
------解决方案--------------------
先说说你遇到啥问题了吧
------解决方案--------------------
你先说遇到什么问题