org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present

Hi everyone,
I hope someone in this Hibernate forum can enlighten me on a problem

I use the Specification interface to build my own criterion of a Model class, which is linked to a Brand class by ManyToOne relationship
in the ModelSpecification class which implements the Specification interface : I include all the columns of the table with the following code : [rootModel.fetch(“brand”)]
and so after calling the findAll(ModelSpecification) function its work ,

but if I add a pagination that is less than the number of line returns I get an error: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list

yet I checked the resulting query in the console and all the columns of the model table and the brand table are present so

I don’t understand why

Share the code you use to construct the query and the full stack trace please.

You should ask this question in the Spring Data forum. You are join fetching an association in your specification and Spring Data is apparently not able to generate a proper count query for this.

so it isn’t a hibernate problem ?

Like I wrote, the count query that Spring Data generates is wrong. Why it does that, I don’t know. Ask the Spring community.