Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to mutliple-join-fetch?
How to mutliple-join-fetch? [message #379279] Thu, 14 August 2008 22:19 Go to next message
Jason Drake is currently offline Jason Drake
Messages: 13
Registered: July 2009
Junior Member
I have a named query to retrieve an object which has multiple OneToMany
relationships. Since I need to display some values from these other side
relationships in a table, I thought I could use a join-fetch query hint,
however only the last declared hint seems to be used.

<named-query name="Stamp.FindByCountry">
<query>SELECT DISTINCT stamp FROM Stamp AS stamp WHERE
stamp.country.id=:country_id</query>
<hint name="eclipselink.join-fetch" value="stamp.catalogueNumbers"/>
<hint name="eclipselink.join-fetch" value="stamp.stampOwnerships"/>
</named-query>

Based on the apparant performance and queries in the logs, it appears the
relationship stamp.stampOwnerships is navigated with the query, but then
each catalogueNumber is loaded individually.

(The following is the output included strictly for reference....) The
calls to Albums and Catalogues can be ignored since there are only a few
of these for the whole dataset (these are linked off the stampOwnership
relationship (ie. a ManyToOne relationship)


[EL Fine]: 2008.08.14
17:12:33.660--ServerSession(27575732)--Connection(9775365)-- Thread(Thread[pool-1-thread-1,5,main])--SELECT
DISTINCT t1.ID, t1.CREATESTAMP, t1.MODIFYSTAMP, t1.DESCRIPTION,
t1.DENOMINATION, t1.PRINTING, t1.COUNTRY_ID, t0.ID, t0.CREATESTAMP,
t0.MODIFYSTAMP, t0.PRICE, t0.PURCHASED, t0.GRADE, t0.THECONDITION,
t0.IMAGE, t0.NOTES, t0.CURRENCY, t0.STAMP_ID, t0.ALBUM_ID FROM OWNERSHIP
t0, COUNTRIES t2, STAMPS t1 WHERE ((t2.ID = ?) AND ((t2.ID =
t1.COUNTRY_ID) AND (t0.STAMP_ID = t1.ID)))
bind => [3201]
[EL Fine]: 2008.08.14
17:12:33.947--ServerSession(27575732)--Connection(10181026)- -Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3951]
[EL Fine]: 2008.08.14
17:12:33.952--ServerSession(27575732)--Connection(9775365)-- Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, NAME, DESCRIPTION, CREATESTAMP, MODIFYSTAMP, ISSUE, TYPE, CURRENCY
FROM CATALOGUES WHERE (ID = ?)
bind => [1]
[EL Fine]: 2008.08.14
17:12:33.956--ServerSession(27575732)--Connection(10181026)- -Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, NAME, DESCRIPTION, CREATESTAMP, MODIFYSTAMP, COLLECTION_ID FROM ALBUMS
WHERE (ID = ?)
bind => [202]
[EL Fine]: 2008.08.14
17:12:33.963--ServerSession(27575732)--Connection(9775365)-- Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3952]
[EL Fine]: 2008.08.14
17:12:33.967--ServerSession(27575732)--Connection(10181026)- -Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3953]
[EL Fine]: 2008.08.14
17:12:33.986--ServerSession(27575732)--Connection(9775365)-- Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3954]
[EL Fine]: 2008.08.14
17:12:33.991--ServerSession(27575732)--Connection(10181026)- -Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3955]
[EL Fine]: 2008.08.14
17:12:33.995--ServerSession(27575732)--Connection(9775365)-- Thread(Thread[pool-1-thread-1,5,main])--SELECT
ID, CREATESTAMP, MODIFYSTAMP, CATALOGUEVALUE, ACTIVE, CAT_CONDITION,
NUMBER, CATALOGUE_REF, STAMP_ID FROM CATALOGUENUMBERS WHERE (STAMP_ID = ?)
bind => [3956]
Re: How to mutliple-join-fetch? [message #379580 is a reply to message #379279] Sun, 17 August 2008 20:02 Go to previous messageGo to next message
Jason Drake is currently offline Jason Drake
Messages: 13
Registered: July 2009
Junior Member
An update.... if I comment out the query hint in orm.xml and add it as a
query hint in "code" after getting the named query, it does appear to
perform the join-fetch on both object relationships. So either the way I
am declaring multiple join-fetch statements in orm.xml is wrong, or there
is some bug here which works if the join-fetch's are added via code.

Thoughts?
Re: How to mutliple-join-fetch? [message #379596 is a reply to message #379279] Mon, 18 August 2008 17:44 Go to previous message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Seems to be a bug in hints, from the code they are stored as a Map, which
obviously will not work for fetch-join or batch. Please log a bug.

For now, the code workaround is probably best.

-- James
Previous Topic:User Guide as PDF?
Next Topic:Sequence with Table for mapped-superclass
Goto Forum:
  


Current Time: Wed Sep 17 23:57:38 GMT 2014

Powered by FUDForum. Page generated in 0.01611 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software