key « Fetch « JPA Q&A





1. key-many-to-one and n+1 query problem with fetch join    forum.hibernate.org

Hi I am mapping my objects to a legacy database that uses composite keys. I have hit a problem with a query that seems to be resulting in an "N+1" type problem - i.e., a new query is run for each row returned despite having requested a fetch join. Here is the HQL: select benefit from Benefit benefit inner join fetch ...

2. Possible to join fetch the keys of a MapKeyManyToMany?    forum.hibernate.org

Is it possible to specify in HQL that the key objects of a MapKeyManyToMany are eagerly join fetched? HQL: select myClass from MyClass as myClass left join fetch myClass.attribValues This HQL statement will eagery join fetch the map values, but not the map keys. @Entity public class MyClass { @ManyToMany @MapKeyManyToMany(joinColumns = @JoinColumn(name = "attribId")) @JoinTable(name = "AttribValue", joinColumns = @JoinColumn(name ...