Users is not mapped
用的hibernate5,请问怎么解决?
用的hibernate5,请问怎么解决?
2016-04-22
@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; } } }
举报