[hibernate-issues] [JIRA] (HHH-14115) @OneToMany with FetchType.EAGER doesn't work when using getResultStream

Arturas Gudkovas (JIRA) jira at hibernate.atlassian.net
Thu Jul 23 04:08:51 EDT 2020


Arturas Gudkovas ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5b34d3b9dab53b667c4df371 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 ) HHH-14115 ( https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 ) @OneToMany with FetchType.EAGER doesn't work when using getResultStream ( https://hibernate.atlassian.net/browse/HHH-14115?atlOrigin=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 )

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=5b34d3b9dab53b667c4df371 )

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=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14115#add-comment?atlOrigin=eyJpIjoiNzY2OTVmMWI4MjM0NDA2Y2I1NjA4NmQwM2E0OWM5YmEiLCJwIjoiaiJ9 )

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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100134- sha1:0043a36 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200723/d250f4c8/attachment-0001.html 


More information about the hibernate-issues mailing list