openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Wellmann <>
Subject Eager fetch problem with map collections
Date Wed, 15 Sep 2010 10:17:30 GMT

I have an entity with a map collection, and I'm trying to select a list of
these entities with an eager fetch for the map collection. 

I read about OpenJPA's Eager Fetch Modes NONE, PARALLEL and JOIN, and I've
experimented with various global or per-query settings, but I'm always
getting the NONE behaviour with 1+n selects, instead of the expected 1+1
selects for PARALLEL or a single select for JOIN.

Could it be that the JOIN mode is not yet supported for maps (I'm using
OpenJPA 2.0.1)? Or am I overlooking anything?

Here is my entity:

class OsmNode
    private long id;

    private int longitude;
    private int latitude;

    @ElementCollection(fetch = FetchType.EAGER)
    @MapKeyColumn(name = "k")
    @Column(name = "v")
    @CollectionTable(name = "node_tags", joinColumns = @JoinColumn(name =
    private Map<String, String> tags;

The JPQL query is

select n from OsmNode n join fetch n.tags

and even with openjpa.jdbc.EagerFetchMode=join, I'm getting the following
1+n SQL selects:

SELECT, t0.latitude, t0.longitude FROM osm.nodes t0
SELECT t0.k, t0.v FROM osm.node_tags t0 WHERE = ?

TIA for any help!

Best regards,

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message