Arturas Gudkovas (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5b34d3b...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzY2OTVmMWI4...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OT...
) HHH-14115 (
https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OT...
) @OneToMany with FetchType.EAGER doesn't work when using getResultStream (
https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OT...
)
Issue Type: Bug Affects Versions: 5.4.4 Assignee: Unassigned Attachments: test-case.zip
Components: hibernate-core Created: 23/Jul/2020 01:08 AM Priority: Major Reporter: Arturas
Gudkovas (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5b34d3b...
)
I am using @OneToMany relationship with FetchType.EAGER and getting result from a query as
a stream. Then fetching eager collection after closing EntityManager, e.g.
@Entity
public class Basket {
...
@OneToMany(fetch = FetchType.EAGER, mappedBy = "basket" )
private List<Fruit> fruits = new ArrayList<>();
...
Basket basket = entityManager.createQuery( "SELECT b FROM Basket b" ,
Basket.class)
.getResultStream()
.findFirst()
.get()
...
entitiManager.close();
...
basket.getFruits().size();
...
It fails with
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of
role: org.hibernate.bugs.Basket.fruits, could not initialize proxy - no Session
It is broken since 5.4.4. Suspect is the code change in ScrollableResultsImpl class (rev
cc01f2561dbca95bd58048f85e283ba1719ee588)
(
https://hibernate.atlassian.net/browse/HHH-14115#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-14115#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#100134- sha1:0043a36 )