openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject Re: Multiple join fetches
Date Fri, 10 Apr 2009 15:34:49 GMT
On Thu, Apr 9, 2009 at 9:20 PM, Daryl Stultz <daryl@6degrees.com> wrote:

>
> I gave this a good testing and have some interesting (to me) results. My
> real object model isn't quite like this, it's a little more complicated.


Things seem to be running bad this morning tho' I haven't changed anything
fundamentally from last night. The core of my real model looks like this:

Module
   KeyGroup
    Key
      LocalizedString

At present I have in the database 1 module, 11 key groups, 99 keys and 99
localized strings (one localized strings per key, keys spread over key
groups).
All relationships are LAZY.

This is my main line:

        OpenJPAEntityManager em = OpenJPAPersistence.cast(entityManager);

        FetchPlan plan = em.getFetchPlan();
        plan.addField(Module.class, "keyGroups");
        plan.addField(KeyGroup.class, "keys");
        plan.addField(Key.class, "localizedStrings");

        Module module = Module.findById(2); // gets em, runs query
containing "join fetch m.keyGroups"
        module.printGraph(System.out);

If I comment out everything but the last 2 lines, I get the full set of data
with queries interleaved in my output as expected. Running the above gets me
the module, all key groups and all keys but only localized strings for one
key group. Interestingly this key group is the last to be retrieved in my
native test query with no ordering:

select Modules.name, KeyGroups.name, Keys.name, LocalizedStrings.value
from Modules
left join KeyGroups on KeyGroups.moduleId = Modules.moduleId
left join Keys on Keys.keyGroupId = KeyGroups.keyGroupId
left join LocalizedStrings on LocalizedStrings.keyId = Keys.keyId

Any idea what I could be doing wrong?

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message