I have an Entity A which contains a @OneToOne relation to the Entity B and Entity C. Entity B and Entity C have, in turn, a @OneToOne relation to Entity B1 and Entity C1:
I need to select all data of Entity A with some fields of Entity B and Entity C. Fields of Entity B1 and C1 have to be ignored.
Executing the query method, I’m expecting the execution of a single query,on User table, fetching right on Badge and Address tables.
But with Bytecode Enhancement enabled, three different query are executed.
It seems that hibernate ignore configured fetches into criteria query
Instead, without bytecode enhancement, a single query is righty executed:
Spring Boot 2.1.0.RELEASE with Spring Data JPA
MySql Community Server 8.0
Facing exactly the same issue with Spring Boot 2.1.3 and Hibernate 5.3.7.
Marcus, regardless of this issue, I reccomend to use Projections in order to get only data you really want.
We have the same problem with ManyToOne. The values get fetched from database, but the lazy attributes will not be initialized (or marked as initialized). The problem at least exists in 5.4.6, 5.3.13, 5.2.17.