Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-19034 Fix use of findCompatibleFetchJoin
The problem was that you had a different SQL query depending on the order the fetch and join operations were created when defining a criteria query. For example: ``` // Example 1: Root<Book> from = criteriaQuery.from( Book.class ); Fetch<Object, Object> fetch = from.fetch( "authors" ); Join<Object, Object> join = from.join( "authors" ); ``` it was different than ``` // Example 2: Root<Book> from = criteriaQuery.from( Book.class ); Join<Object, Object> join = from.join( "authors" ); Fetch<Object, Object> fetch = from.fetch( "authors" ); ``` In the first example, `fetch` and `join` were exactly the same object, causing issues if the association `authors` appeared in the `where` clause. For example: ``` criteriaQuery.where( cb.equal( join.get( "id" ), 2L ) ); ``` Note that now we always rung an extra join even when not necessary. But this is consistent with what happen with HQL, and we can figure out how to add this improvement in a different issue.
- Loading branch information