【发布时间】:2018-09-16 05:33:02
【问题描述】:
我在获取数据库中表中存在的所有条目时遇到异常。
我收到的错误是:
org.hibernate.HibernateException: collection is not associated with any session
at org.hibernate.collection.internal.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:678) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.internal.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:893) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:360) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2554) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2540) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
令我震惊的是,我在测试期间没有收到此错误,但它在生产环境中出现,这让我感到困惑!
这里有人可以帮我弄清楚这种奇怪的行为吗??
和桌子的大小有关系吗??
【问题讨论】:
-
stackoverflow.com/questions/18956825/… 这可能会有所帮助。确保会话已初始化
-
我已经想要这个答案并得到它。但是我想知道的是为什么我在本地测试时没有抛出这个异常!!
-
请添加您的代码以了解有关该问题的更多信息。
标签: java spring postgresql hibernate jpa