列如,user有id,name,password
如果直接this.getHibernateTemplate().delete(user)
默认删除是按id=?删的
现在我知道了name=xx,但是id未知。要删除怎么写?
this.getHibernateTemplate().delete("from user u where u.name=?",+user.getName())
这样写不行啊,我试过了。
还有Action里,一个public String方法只能调用一次hibernate的事务吗?
我调两次就报错A different object with the same identifier value was already associated with the session
...全文
13657打赏收藏
关于this.getHibernateTemplate().delete()方法
列如,user有id,name,password 如果直接this.getHibernateTemplate().delete(user) 默认删除是按id=?删的 现在我知道了name=xx,但是id未知。要删除怎么写? this.getHibernateTemplate().delete("from user u where u.name=?",+user.getName()) 这样写不行啊,我试过了。 还有Action里,一个public String方法只能调用一次hibernate的事