我用的hibernate4 不知道dao层代码怎么写 哪位大神能给写一下谢谢
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;
}
非常感谢上面的