【发布时间】:2011-05-18 16:18:40
【问题描述】:
我正在将 JPA 与 Hibernate 持久性提供程序一起使用。
我有一对多的映射,我用过
@OneToMany(mappedBy = "mSearchPreference", cascade = CascadeType.ALL, fetch=FetchType.EAGER)
我可以在控制台上看到一对多的 SQL 语句,尽管我遇到了异常
illegal access to loading collection (hibernate.LazyInitializationException)
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.AbstractPersistentCollection.readElementExistence(AbstractPersistentCollection.java:142)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:187)
有人可以帮我解决我需要做的其他安排吗?
【问题讨论】:
-
您确定要添加的不是另一个集合吗?您应该有更多可用的堆栈跟踪。
-
嗨,这里是完整的堆栈跟踪
-
@SatishKumar 你能展示你用来获取实体的代码吗?
标签: jpa