Try using hibernate.show_sql = true
to print the queries and confirm if lazy loading is working or not:
<bean id= "entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
...
<property name="jpaProperties" >
<props>
...
<prop key="hibernate.show_sql" >true</ prop>
<prop key="hibernate.format_sql" >true</ prop>
<prop key="hibernate.use_sql_comments">true</prop>
...
use_sql_comments
is especially important, as it will print a comment at the beginning of the query stating the reason why the query is written: one-to-many, named query name, criteria query text, etc.
Then by putting breakpoints it's possible to see if the collection is fetched at the moment you inspect it with the debugger.
If it's not the case, and the getter is not called, then it could be that the lazy loading is being triggered directly inside the class via direct access to the property neurologicalFindingList
.
Are you accessing the property directly inside PatientEntity
, for example in equals and hashcode? If so by removing it from the equals and hashcode the problem should be fixed.