哪位大神能把用的hibernate4的dao层代码给贴出来谢谢啦
我用的hibernate4 不知道dao层代码怎么写 哪位大神能给写一下谢谢
我用的hibernate4 不知道dao层代码怎么写 哪位大神能给写一下谢谢
2017-05-11
public Employee findByUsernameAndPassword(Employee employee) {
Session session = this.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
String hql2 = "from Employee e where e.username= '"+employee.getUsername()+"' and e.password = '"+employee.getPassword()+"'";
Query q = session.createQuery(hql2);
List<Employee> list =q.list();
if(list.size()>0){
return list.get(0);
}
tx.commit();
session.close();
return null;
}
举报