Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to use eclipselink.batch with em.find()?(eclipselink.batch will speed up queries -- but how to use with em.find()?)
How to use eclipselink.batch with em.find()? [message #1064252] Tue, 18 June 2013 12:24 Go to next message
Markus KARG is currently offline Markus KARG
Messages: 28
Registered: June 2011
Junior Member
It is common sense that eclipselink.batch hint will speed up queries. But how can this be used to speed up @OneToMany relationships when running em.find()? As the query is implied, one doesn't know the QL Name to provide as the value of eclipselink.batch!
Re: How to use eclipselink.batch with em.find()? [message #1064301 is a reply to message #1064252] Tue, 18 June 2013 15:04 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can only use a batch fetch on a query that returns multiple objects. find() only returns a single objects, so batch fetching would have not benefit.

If you are trying to batch fetch a relationship of the target of the OneToMany, then you could use the @BatchFetch annotation on the target's relationship.


James : Wiki : Book : Blog : Twitter
Re: How to use eclipselink.batch with em.find()? [message #1064403 is a reply to message #1064301] Wed, 19 June 2013 06:28 Go to previous messageGo to next message
Markus KARG is currently offline Markus KARG
Messages: 28
Registered: June 2011
Junior Member
Okay I forgot to mention that the single entity returned has a fetch=EAGER relationship with loads lots of child entities. That is what I want to speed up. Smile
Re: How to use eclipselink.batch with em.find()? [message #1064404 is a reply to message #1064403] Wed, 19 June 2013 06:30 Go to previous messageGo to next message
Markus KARG is currently offline Markus KARG
Messages: 28
Registered: June 2011
Junior Member
I know that I can use @BatchFetch Annotation. The problem is that my code must not load Eclipse-specific classes, since it must stay portable. So I *must* use a hint at the em.find() command. I should have told the whole story right from the start to make it more clear.
Re: How to use eclipselink.batch with em.find()? [message #1065379 is a reply to message #1064404] Tue, 25 June 2013 13:52 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You can also define @BatchFetch in your EclipseLink orm.xml.

You could probably also change your find() to instead use a Query and define the batch fetch on both the relationship and the child relationship.

RE: one doesn't know the QL Name to provide as the value of eclipselink.batch
Well this QL name is ignored anyway, you should be able to put any alias you want there as long as the syntax is correct.


James : Wiki : Book : Blog : Twitter
Previous Topic:Could not load the method for the property name
Next Topic:Validation on preUpdate checks unchanged entities
Goto Forum:
  


Current Time: Thu Oct 02 02:26:29 GMT 2014

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

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