When I have an entity containing a map, for example
@Entity
public class TestEntity {
@ElementCollection(fetch = FetchType.EAGER)
Map<String, String> strings = new HashMap<String, String>();
}
and I select multiple objects (SELECT z FROM TestEntity z), OpenJPA 2.0 does one query for each test to get a map, although I used FetchType.EAGER. This also happens when the map value is an entity, and I use @OneToMany instead of @ElementCollection. In principle, this can be done more efficiently with a single query that selects all map entries for all returned TestEntities. For Collection-value fields, OpenJPA already does this by default (openjpa.jdbc.EagerFetchMode "value =" parallel "), but it doesn't seem to work on this simple entity. (A similar problem with value =" join ").
Can I do something wrong? Is there an easy way to tell OpenJPA not to execute a request for each object, but only one? Or has any work already been planned to improve this (I submitted it under https://issues.apache.org/jira/browse/OPENJPA-1920 )?
This is a problem for us, because we want to get (and separate) a list of about 1900 products, which takes almost 15 seconds with OpenJPA. It takes less than a second with my own own request.
, , , StringI18N, ( ), .
, , .
EDIT: JOIN FETCH :
"SELECT z FROM TestEntity z JOIN FETCH z.strings"
OpenJPA TRACE - , SQL TestEntity.