public Person login(String username, String password) throws Exception { String hql ="select u from Person as u where u.username=? and u.password=?"; Session session = HibernateSessionFactory.getSession(); try{ Person u = (Person)session.createQuery(hql).setString(0, username) .setString(1, password).uniqueResult(); return u; }catch(Exception e){ e.printStackTrace(); return null; } 我的代码是这样的的,可是报错找不到session,这是怎么回事呢
String hql ="select u from Person as u where u.username=? and u.password=?";
Session session = HibernateSessionFactory.getSession();
try{
Person u = (Person)session.createQuery(hql).setString(0, username)
.setString(1, password).uniqueResult();
return u;
}catch(Exception e){
e.printStackTrace();
return null;
}
我的代码是这样的的,可是报错找不到session,这是怎么回事呢
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"><hibernate-mapping package="vo">
<class name="Person" table="users">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="username" column="username"></property>
<property name="password" column="password"></property>
<property name="flag" column="flag"></property> </class>
</hibernate-mapping>
这是person那个文件,在哪里加lazy,
现在报这种错
04:44:11,406 INFO Environment:533 - hibernate.properties not found
不是说主键吗?但如果我的users表里没有主键呢,我的users表里只有
username
password
flag
应该怎么写
刚学这个hibernate好多都还不懂
完全不需要配置web.xml