I\'m selecting two id columns but get error specified:
org.hibernate.QueryException: **query specified join fetching, but the owner of the fetched associatio
As you need the join fetch, removing the fetch is won't meet your need.
What you should do instead is specify a count query together with it.
Assuming you are paginating the result, below is jpa query that takes id as param and will cause the problem you specified and the second query solves this by adding count query to it.
Note: fk_field is the attribute in tableA that has the one-to-many rln. The count query does not use join fetch.
@Query(value = "from TableA a LEFT JOIN FETCH a.fk_field where a.id = :id")
@Query(value = "from TableA a LEFT JOIN FETCH a.fk_field where a.id = :id",
countQuery = " select count(a) from TableA a left join a.fk_field where a.id = :id")