Bartosz Herczyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjg5NWQyYmEx...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16205?atlOrigin=eyJpIjoiNjg5NW...
) HHH-16205 (
https://hibernate.atlassian.net/browse/HHH-16205?atlOrigin=eyJpIjoiNjg5NW...
) EntityGraph does not work when exists query with explicit join fetch (
https://hibernate.atlassian.net/browse/HHH-16205?atlOrigin=eyJpIjoiNjg5NW...
)
Change By: Bartosz Herczyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
I migrated hibernate *5.6.14.Final* to *6.1.7.Final* and I noticed a problem with
entityGraph when exists query with explicit join fetch.
For example:
{noformat} @Query("select c from Company c join fetch c.factory f join fetch
f.carFactory cf where c.id = :id")
Optional<Company> findByIdExplicitFetchFactoryAndCarFactory(long id);
@Query("select c from Company c where c in :company")
@EntityGraph(attributePaths = {"factory.carFactory.cars"})
Optional<Company> findByCompanyFetchCars(Company company);{noformat}
And this method does not fetch _cars_:
{noformat} @Transactional(readOnly = true)
public Company getTwoQueries(long id) {
return repository. findById findByIdExplicitFetchFactoryAndCarFactory (id)
.flatMap(repository:: findByIdExplicitFetchFactoryAndCarFactory findByCompanyFetchCars )
.orElseThrow(EntityNotFoundException::new);
}{noformat}
Example project:
* hibernate 6.1.7 - test failed:
[
https://github.com/bherczyk/hibernate_6_bugs/blob/master/src/test/java/co...]
* hibernate 5.6.14 - test passed:
[
https://github.com/bherczyk/hibernate_6_bugs/blob/hibernate-5/src/test/ja...]
(
https://hibernate.atlassian.net/browse/HHH-16205#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16205#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#100216- sha1:3fa9804 )