qq_张狂与自由_0
2016-04-22 17:40
用的hibernate5,请问怎么解决?
@Override public boolean usersLogin(Users u) { // TODO Auto-generated method stub Transaction tx = null; String sql = ""; try { Session session = MyHibernateSessionFactory.getSessionFactory().getCurrentSession(); tx = session.beginTransaction(); sql = "select * from users where username=? and password=? "; Query query = session.createSQLQuery(sql); query.setParameter(0, u.getUsername()); query.setParameter(1, u.getPassword()); List list = query.list(); tx.commit(); if (list.size() > 0) { return true; } else { return false; } } catch (Exception ex) { ex.printStackTrace(); return false; } finally { if (tx != null) { // tx.commit(); tx = null; } } }
映射关系没有配置好。检查struts.xml
使用Struts2+Hibernate开发学生信息管理功能
80701 学习 · 754 问题
相似问题