Fetch graph is ignored when entity is retrieved from second-level cache

Description

I have a one-to-many relationship defined as below

Now in my DAL, i'm calling this method

Since i have loaded Parent with Children, i should be able to use children collection outside of the transaction. But i'm getting Lazyinitialization Exception. This happens only when hibernate level 2 cache - ehcache is enabled and entity is getting loaded from the cache instead of the database (i.e. it is already loaded from another transaction and saved in the cache). If i disable it from config, it works as expected. Also if i initialize collection explicitly after find, it works as expected. I'm using Hibernate 5.2.6.Final with JPA 2.1.

Suitable Test Case can be found here: TestCase

Environment

JDK8, JPA 2.1

Assignee

Unassigned

Reporter

Harsh Panchal

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

Affects versions

Priority

Major
Configure