Hibernate3 父子映射報錯:illegal access to loading collection
org.springframework.orm.hibernate3.HibernateSystemException:?illegal?access?to?loading?collection;?nested?exception?is?org.hibernate.LazyInitializationException:?illegal?access?to?loading?collection
Caused?by:?org.hibernate.LazyInitializationException:?illegal?access?to?loading?collection
????at?org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:
341
)
????at?org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:
86
)
????at?org.hibernate.collection.PersistentSet.hashCode(PersistentSet.java:
355
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.append(HashCodeBuilder.java:
348
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionAppend(HashCodeBuilder.java:
309
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionHashCode(HashCodeBuilder.java:
283
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionHashCode(HashCodeBuilder.java:
150
)
????at?com.hiany.forum.domain.base.BaseObject.hashCode(BaseObject.java:
32
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.append(HashCodeBuilder.java:
348
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionAppend(HashCodeBuilder.java:
309
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionHashCode(HashCodeBuilder.java:
283
)
????at?org.apache.commons.lang.builder.HashCodeBuilder.reflectionHashCode(HashCodeBuilder.java:
150
)
????at?com.hiany.forum.domain.base.BaseObject.hashCode(BaseObject.java:
32
)
????at?java.util.HashMap.hash(HashMap.java:
264
)
????at?java.util.HashMap.put(HashMap.java:
382
)
????at?java.util.HashSet.add(HashSet.java:
194
)
????at?java.util.AbstractCollection.addAll(AbstractCollection.java:
318
)
????at?org.hibernate.collection.PersistentSet.endRead(PersistentSet.java:
273
)
????at?org.hibernate.engine.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:
183
)
????at?org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:
268
)
????at?org.hibernate.engine.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:
249
)
????at?org.hibernate.loader.Loader.endCollectionLoad(Loader.java:
866
)
????at?org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:
853
)
????at?org.hibernate.loader.Loader.doQuery(Loader.java:
717
)
????at?org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
224
)
????at?org.hibernate.loader.Loader.loadCollection(Loader.java:
1919
)
????at?org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:
36
)
????at?org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:
520
)
????at?org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:
60
)
????at?org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1676
)
????at?org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:
454
)
????at?org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:
755
)
????at?org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:
229
)
????at?org.hibernate.loader.Loader.loadEntity(Loader.java:
1785
)
????at?org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:
47
)
????at?org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:
41
)
????at?org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:
2730
)
????at?org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:
365
)
????at?org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:
346
)
????at?org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:
123
)
????at?org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:
177
)
????at?org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:
87
)
????at?org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:
862
)
????at?org.hibernate.impl.SessionImpl.get(SessionImpl.java:
799
)
????at?org.hibernate.impl.SessionImpl.get(SessionImpl.java:
792
)
????at?org.springframework.orm.hibernate3.HibernateTemplate$
1
.doInHibernate(HibernateTemplate.java:
460
)
????at?org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:
362
)
????at?org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:
454
)
????at?org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:
448
)
????at?com.hiany.forum.dao.HibernateGenericDao.get(HibernateGenericDao.java:
41
)
????at?com.hiany.forum.dao.HibernateEntityDao.get(HibernateEntityDao.java:
40
)
????at?com.hiany.forum.dao.HibernateEntityDao$$FastClassByCGLIB$$967b2136.invoke(
<
generated
>
)
????at?net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:
149
)
????at?org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:
714
)
????at?org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
162
)
????at?org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
107
)
????at?org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
185
)
????at?org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:
652
)
????at?com.hiany.forum.service.ArticleManager$$EnhancerByCGLIB$$64259eef.get(
<
generated
>
)
????at?com.hiany.forum.service.ArticleManageTest.testArticleManager(ArticleManageTest.java:
56
)
????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:
585
)
????at?junit.framework.TestCase.runTest(TestCase.java:
154
)
????at?junit.framework.TestCase.runBare(TestCase.java:
127
)
????at?org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:
69
)
????at?junit.framework.TestResult$
1
.protect(TestResult.java:
106
)
????at?junit.framework.TestResult.runProtected(TestResult.java:
124
)
????at?junit.framework.TestResult.run(TestResult.java:
109
)
????at?junit.framework.TestCase.run(TestCase.java:
118
)
????at?junit.framework.TestSuite.runTest(TestSuite.java:
208
)
????at?junit.framework.TestSuite.run(TestSuite.java:
203
)
????at?org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:
128
)
????at?org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38
)
????at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460
)
????at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673
)
????at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386
)
????at?org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196
)
在做父子映射時候,使用父類去獲取子類時候,報錯如上。
跟蹤棧信息,我們可以發(fā)現(xiàn),domain object的 hashCode 方法有錯誤。
原來的domain object 使用了BaseObject作為基類:
import
?org.apache.commons.lang.builder.EqualsBuilder;
import
?org.apache.commons.lang.builder.HashCodeBuilder;
import
?org.apache.commons.lang.builder.ToStringBuilder;
import
?org.apache.commons.lang.builder.ToStringStyle;
import
?java.io.Serializable;
/**?*/
/**
?*?基類,domain?object?
?*?繼承此類可以自動獲得toString?equals?hashCode的method。
?
*/
public
?
abstract
?
class
?BaseObject?
implements
?Serializable?
{
????
private
?
static
?
final
?
long
?serialVersionUID?
=
?
3256446889040622647L
;
????
public
?String?toString()?
{
????????
return
?ToStringBuilder.reflectionToString(
this
,
????????????????ToStringStyle.MULTI_LINE_STYLE);
????}
????
public
?
boolean
?equals(Object?o)?
{
????????
return
?EqualsBuilder.reflectionEquals(
this
,?o);
????}
????
public
?
int
?hashCode()?
{
????????
return
?HashCodeBuilder.reflectionHashCode(
this
);
????}
????
????
protected
?
void
?init()
{}
;
}
但是除去該基類后,發(fā)現(xiàn)錯誤被修復(fù)了。
暫時還不清楚問題為什么會發(fā)生。
posted on 2006-10-16 09:29
旱頭憨腦
閱讀(6177)
評論(1)
編輯
收藏
評論
#
re: Hibernate3 父子映射報錯:illegal access to loading collection
2007-12-19 14:44
d
回復(fù)
更多評論
原因在與pojo里面的 public int hashCode() {... } 方法調(diào)用了set對象成員的hashCode()方法
如this.getSets().hashCode();
刪除該方法的調(diào)用即可;調(diào)用非set對象成員的.hashCode()方法沒有問題。
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
旱頭憨腦
lanluquan
導(dǎo)航
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
統(tǒng)計
隨筆 - 1
文章 - 10
評論 - 1
引用 - 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆檔案
■
2006年10月 (1)
文章分類
■
ajax(1)
(rss)
■
j2ee(7)
(rss)
■
java
(rss)
■
ruby(1)
(rss)
■
非技術(shù)(1)
(rss)
文章檔案
■
2008年6月 (1)
■
2007年9月 (1)
■
2007年7月 (1)
■
2006年10月 (4)
■
2006年9月 (1)
■
2006年8月 (2)
搜索
最新評論
1.?re: Hibernate3 父子映射報錯:illegal access to loading collection
評論內(nèi)容較長,點擊標(biāo)題查看
--d
Powered by:
BlogJava
Copyright © 旱頭憨腦
主站蜘蛛池模板:
亚洲剧情在线观看
|
98精品全国免费观看视频
|
中文字字幕在线高清免费电影
|
在线观看人成网站深夜免费
|
国产精品亚洲精品日韩已方
|
国产成人亚洲精品电影
|
亚洲免费人成视频观看
|
亚洲激情电影在线
|
国产一二三四区乱码免费
|
成年女人免费v片
|
亚洲一区二区三区免费视频
|
久久最新免费视频
|
日韩视频在线免费
|
亚洲乱码中文字幕在线
|
97av免费视频
|
国产亚洲成av人片在线观看
|
美女视频黄a视频全免费网站色窝
|
亚洲国产一区国产亚洲
|
老司机午夜性生免费福利
|
啦啦啦中文在线观看电视剧免费版
|
日韩免费的视频在线观看香蕉
|
2019亚洲午夜无码天堂
|
四虎免费大片aⅴ入口
|
手机永久免费的AV在线电影网
|
亚洲人成网站18禁止一区
|
免费网站看av片
|
国产成人精品日本亚洲网址
|
曰皮全部过程视频免费国产30分钟
|
国产成人亚洲综合在线
|
亚洲精品无码专区在线在线播放
|
国产最新凸凹视频免费
|
和老外3p爽粗大免费视频
|
亚洲欧洲日产专区
|
一级毛片免费观看
|
亚洲an天堂an在线观看
|
毛片免费观看网站
|
国产日韩精品无码区免费专区国产
|
免费人成视频在线观看网站
|
亚洲熟妇AV日韩熟妇在线
|
中文字幕专区在线亚洲
|
综合在线免费视频
|