Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eager OneToOne relationship not using JOIN
Eager OneToOne relationship not using JOIN [message #653898] Fri, 11 February 2011 18:16 Go to next message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
Member
An entity A has an eager one to one relationship with B(ore many to one).

When I run "Select a FROM A a", I'd like to eclipselink build just one sql select clause with a A e B joined.

But, unfortunally, eclipslinks build many sql select clause. One for listing A, and for each A instance a sql select for B.

How can I configure eclipselink in order to buld just one select clause?

Thanks. Mauro
Re: Eager OneToOne relationship not using JOIN [message #653901 is a reply to message #653898] Fri, 11 February 2011 18:31 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello Mauro,

You can add a fetch join into the JPQL:
"Select a FROM A a left join fetch a.b"
You can also use a query hint or set the mapping to always join using the @JoinFetch Annotation described here:
http://wiki.eclipse.org/Optimizing_the_EclipseLink_Applicati on_(ELUG)#How_to_Use_Batch_and_Join_Reading_for_Optimization

Best Regards,
Chris
Re: Eager OneToOne relationship not using JOIN [message #653908 is a reply to message #653898] Fri, 11 February 2011 20:01 Go to previous message
Mauro Flores is currently offline Mauro FloresFriend
Messages: 84
Registered: September 2009
Location: Brasil
Member
Thanks, Chris. I didn't know that.

But, why do I need to explicitally say that I want a join in this case?
In my oppinion the default should be the faster implementation.
One select with a left join would always be faster than many selects.

That's the behaviour of openjpa implementation.

Is there a property in persistence.xml to make the left join default for all application?

Thanks.




Previous Topic:CriteriaQuery<Boolean> fails with NoResultException but works when running generated SQL manua
Next Topic:RCP and concurrency
Goto Forum:
  


Current Time: Sat Apr 20 04:24:41 GMT 2024

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

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

Back to the top