BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / java / #15820同步于 2010/9/29
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖

Hibernate问题紧急求助!(代码已经贴上)

DestinyOwner
2010/9/29镜像同步6 回复
17:02:31,357 ERROR AssertionFailure:47 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) org.hibernate.AssertionFailure: possible non-threadsafe access to the session at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:123) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877) at org.hibernate.loader.Loader.doQuery(Loader.java:752) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.StatelessSessionImpl.list(StatelessSessionImpl.java:490) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at edu.bupt.pcncad.utils.DatabaseModifyTool.copycases(DatabaseModifyTool.java:108) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at edu.bupt.pcncad.utils.DatabaseModifyTool.main(DatabaseModifyTool.java:41) org.hibernate.AssertionFailure: possible non-threadsafe access to the sessionjava.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at edu.bupt.pcncad.utils.DatabaseModifyTool.main(DatabaseModifyTool.java:41) Caused by: org.hibernate.AssertionFailure: possible non-threadsafe access to the session at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:123) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:877) at org.hibernate.loader.Loader.doQuery(Loader.java:752) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2228) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) at org.hibernate.loader.Loader.list(Loader.java:2120) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.StatelessSessionImpl.list(StatelessSessionImpl.java:490) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at edu.bupt.pcncad.utils.DatabaseModifyTool.copycases(DatabaseModifyTool.java:108) ... 5 more
订阅后,新回复会通过你的通知中心匿名送达。
6 条回复
baoyu4300机器人#1 · 2010/9/29
你还应该贴代码。
DestinyOwner机器人#2 · 2010/9/29
要全部运行起来很麻烦,还有数据库脚本啥的…… 核心问题是StatelessSession里边的Query在执行list方法时有何潜在的同步问题? 【 在 baoyu4300 (愤怒的小叔叔) 的大作中提到: 】 : 你还应该贴代码。
baoyu4300机器人#3 · 2010/9/29
Session本身不是线程安全的吧? 你要么试试同步块保护,要么分析一下你创建session的时候不要把一个共享给多个线程
DestinyOwner机器人#4 · 2010/9/29
我想当地纳闷,明明这只是一个程序,就这一个线程,怎么会不安全。 【 在 baoyu4300 (愤怒的小叔叔) 的大作中提到: 】 : Session本身不是线程安全的吧? : 你要么试试同步块保护,要么分析一下你创建session的时候不要把一个共享给多个线程
DestinyOwner机器人#5 · 2010/9/29
一个方法,难道会出多个线程? 【 在 DestinyOwner (积极主动,努力创造自己的命运) 的大作中提到: 】 : 我想当地纳闷,明明这只是一个程序,就这一个线程,怎么会不安全。
a6560072机器人#6 · 2010/10/5
你进行一个操作后flush下,应该就能解决。