Description
Hi,
not sure if this is a bug or a feature - I did not find any clarification on Stackoverflow or Baeldung and whatever Google brings up in the first 5 pages of results...
So I have some entity model where I am querying an entity with both a m:n and a n:1 relationship, and that one has another n:1 child.
Together a hibernate query results in a query for 100+ fields combined from that entities - of which I need just 8.
This is my find method in the repository:
@EntityGraph(
attributePaths = [
"id",
"code",
"status",
"configurations.id",
"configurations.attributeKey",
"configurations.attributeValue",
"configurations.type.grp",
"configurations.type.description",
"configurations.type.curr"
]
)
fun findByUsers_Id(id: String): List<SkillWithConfigurationsProjection>
SkillWithConfigurationsProjection
is an interface following example on Baeldung - Spring Data JPA Projections:
interface SkillWithConfigurationsProjection {
fun getStatus(): RecordStatus
fun getId(): Int
fun getCode(): String
fun getConfigurations(): List<ConfigWithTypeProjection>
}
I was of the impression that @EntityGraph
should hint hibernate which collections need to be eager loaded (that works) and the projection hints which fields should be queried?
I tried with type = EntityGraph.EntityGraphType.LOAD
but it did not change the number of columns either.
Where does the problem sit now?