
Hibernate
totogogo
@CityU of HK
展开
-
出现org.hibernate.TransactionException: Transaction not successfully started的原因
是因为代码中有Transaction的嵌套,如:Transaction tx1=session.beginTransaction() Transaction tx2=session.beginTransaction() tx2.commit();tx1.commit();在适用hibernate JPA的时候,不能适用事务嵌套关于hibern原创 2007-11-25 19:18:00 · 10326 阅读 · 3 评论 -
Hibernate Tip: 使用JBOSS MBEAN时,Session会在事务提交后自动关闭!
做了一个hibernate app,相关代码如下:-------------------------------------VoteServiceImpl.classpublic class VoteServiceImpl{ Session session; 。。。。 public void closeSession(){ session.close();} public void del原创 2007-12-09 00:23:00 · 2235 阅读 · 1 评论 -
解决org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)
相关代码:===============================================public class VoteQuestion { private Set options = new HashSet(); 。。。 /** * @hibernate.set cascade = "all" table = "VOTE_OPTION" inverse =原创 2007-12-09 01:31:00 · 13634 阅读 · 0 评论 -
Hibernate Tip: 为什么要把变量类型设置为Long, Integer,而不是long, int
hibernate pojo里,int, long type的变量如果希望如果没有set的话就为null,那么应该使用Integer, Long,否则没有set也照样有值,即为0如:Integer age;public Integer getAge(){ return age;}public void setAge(Integer age){ this.age=age;}那么在原创 2007-12-08 23:54:00 · 3086 阅读 · 0 评论 -
hibernate的一个批处理问题!
执行下列代码:=====================================================Session session=sessionFactory.openSession();//add a vote with active=falseTransaction tx = session.beginTransaction();VoteQuestion vote=n原创 2007-12-09 02:00:00 · 3136 阅读 · 0 评论 -
Hibernate: cannot simultaneously fetch multiple bags 问题的解决办法
如果在一个pojo里使用超过一个List的变量,则会出现这个错误详见: http://www.quanlei.com/2011/10/2817.html他提供了4个解决方法,我采用方案3: 改变FetchMode为@Fetch(FetchMode.SUBSELECT)其他参考links:http://www.mkyong.com/hibernate/hibe转载 2012-04-30 11:07:02 · 4736 阅读 · 0 评论