-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native Queries throwing LazyInitializationException for EAGER fetches after upgrading to version 3 #2780
Comments
This sounds very much like a Hibernate issue, since all the JPA mapping is done by it. If you think this is actually a Spring Data issue, please provide a reproducer for the issue including a test case that demonstrates the correct behaviour using the |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
Sorry for the delay here. https://hibernate.atlassian.net/browse/HHH-16191 thanks for the heads up |
I have the following Entity:
Note:
@ManyToOne
'sfetch
attribute defaults toFetchType.EAGER
. The issue is also present if I set it explicitly.This is the Spring Data JPA Repository I'm using, that contains two similar queries, one using JPQL and the other using a native query:
This is the main application class from where I call these methods:
This functionality was working fine, but after upgrading to Boot 3 (which implies using Spring Data 3), the native query doesn't correctly log
Foo
entries, because theBar
association has not been fetched Eagerly as established by the relationship.This is the log output for the first query (I have added the
spring.jpa.show-sql=true
Boot property to clearly see the queries the framework is performing on the logs):but the second one (the native one) is logging the following INFO (?) console messages:
With the 2.x version, my application was correctly fetching the associated
Bar
association eagerly as you can appreciate in the following logs:I couldn't find any relevant information that could guide me here in the 'Spring Data 2022.0 (Turing) Release Notes' docs
The text was updated successfully, but these errors were encountered: