two open sessions异常

异常:

org.springframework.orm.hibernate3.HibernateSystemException: Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
Caused by: 
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
	at org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:410)
	at org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:43)
	at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
	at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
	at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
	at org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)

 原因:

系统中同一业务处理过程中,一个Session中对象可能被另一个Session访问,且业务处理过程中同时开了两个session

解决办法:

关闭上一个Sessoin后再接着处理下一个Session的业务,或将 业务处理合并到同一个Session中

猜你喜欢

转载自caoyinghui.iteye.com/blog/1095289
two
今日推荐