Alexander Schwartz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6267ec4...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNWJjNTdjOWJl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16423?atlOrigin=eyJpIjoiNWJjNT...
) HHH-16423 (
https://hibernate.atlassian.net/browse/HHH-16423?atlOrigin=eyJpIjoiNWJjNT...
) LazyInitializationException when calling em.refresh() on entity with lazy and eager
children (
https://hibernate.atlassian.net/browse/HHH-16423?atlOrigin=eyJpIjoiNWJjNT...
)
Issue Type: Bug Affects Versions: 6.2.0 Assignee: Unassigned Components: hibernate-core
Created: 03/Apr/2023 05:13 AM Environment: Linux / H2 (probably independent of from the
database) Priority: Major Reporter: Alexander Schwartz (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6267ec4...
)
The problem can be reproduced as follows:
* given: entity with two collections, one lazy, the other eager
* fetch an entity
* refresh the entity
* access the lazy collection → LazyInitializationException as the collection doesn’t
contain a session (see below)
Reproducer:
https://github.com/ahus1/hibernate-test-case-templates/tree/kc-16069-lazy...
Chat with the hibernate team:
https://hibernate.zulipchat.com/#narrow/stream/132096-hibernate-user/topi...
Issue from the Keycloak team:
https://github.com/keycloak/keycloak/issues/19069#issuecomment-1494185743
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of
role: org.hibernate.bugs.RealmEntity.components: could not initialize proxy - no Session
at
org.hibernate.collection.spi.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:635)
at
org.hibernate.collection.spi.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:218)
at
org.hibernate.collection.spi.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:148)
at org.hibernate.collection.spi.PersistentSet.size(PersistentSet.java:151)
at org.hibernate.bugs.ORMUnitTestCase.hhh123Test(ORMUnitTestCase.java:98)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at
org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at
org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at
org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
at java.base/java.lang.Thread.run(Thread.java:829)
(
https://hibernate.atlassian.net/browse/HHH-16423#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16423#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100221- sha1:d541bce )