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/com/example/hibernate_6_bugs/Hibernate6BugsApplicationTests.java#L75|https://github.com/bherczyk/hibernate_6_bugs/blob/master/src/test/java/com/example/hibernate_6_bugs/Hibernate6BugsApplicationTests.java#L75|smart-link] * hibernate 5.6.14 - test passed: [https://github.com/bherczyk/hibernate_6_bugs/blob/hibernate-5/src/test/java/com/example/hibernate_6_bugs/Hibernate6BugsApplicationTests.java#L75|https://github.com/bherczyk/hibernate_6_bugs/blob/hibernate-5/src/test/java/com/example/hibernate_6_bugs/Hibernate6BugsApplicationTests.java#L75|smart-link] |
|