Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Conditional LEFT JOIN criteria API
Conditional LEFT JOIN criteria API [message #696301] Wed, 13 July 2011 16:40 Go to next message
LA  is currently offline LA Friend
Messages: 13
Registered: June 2011
Junior Member
Hello,

I'm trying to do a Conditional LEFT JOIN with criteria API..but it doesn't work as expected.

Join ed = from.join("somethingCollection", JoinType.LEFT);

Path path = ed.get("some").get("hasEL");
Predicate p = cb.equal(path, Boolean.TRUE);
predicateList.add(p);

this adds a where clause t1.hasEL = true and I need it to be added to the ON expression.

Is it possible?

more details on this issues: http://forums.oracle.com/forums/thread.jspa?threadID=2177735 think is similar to mine

regards,
la00

Re: Conditional LEFT JOIN criteria API [message #698557 is a reply to message #696301] Tue, 19 July 2011 17:25 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Only the relationship join is put in the ON clause in Criteria or JPQL, there is no way to affect the ON clause.

Why do you need the comparison in the ON clause? Use a left join for the path as well to ensure it is outer joined, what is the full query?
Try to re-word it to not require the ON clause.

It is possible in EclipseLink to define a OneToOneQuery key that allows a custom ON clause.

See/vote for bug,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146


James : Wiki : Book : Blog : Twitter
(no subject) [message #698570 is a reply to message #696301] Tue, 19 July 2011 17:25 Go to previous messageGo to next message
James is currently offline JamesFriend
Messages: 272
Registered: July 2009
Senior Member
Only the relationship join is put in the ON clause in Criteria or JPQL, there is no way to affect the ON clause.

Why do you need the comparison in the ON clause? Use a left join for the path as well to ensure it is outer joined, what is the full query?
Try to re-word it to not require the ON clause.

It is possible in EclipseLink to define a OneToOneQuery key that allows a custom ON clause.

See/vote for bug,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: Conditional LEFT JOIN criteria API [message #698827 is a reply to message #696301] Wed, 20 July 2011 10:31 Go to previous message
LA  is currently offline LA Friend
Messages: 13
Registered: June 2011
Junior Member
Already voted...

solved the issue making 2 queries and make the union of both results with CollectionUtils.union

tks
la00
(no subject) [message #698839 is a reply to message #696301] Wed, 20 July 2011 10:31 Go to previous message
LA  is currently offline LA Friend
Messages: 13
Registered: June 2011
Junior Member
Already voted...

solved the issue making 2 queries and make the union of both results with CollectionUtils.union

tks
la00
Previous Topic:(no subject)
Next Topic:XmlInverseReference without the need for mappedBy attribute
Goto Forum:
  


Current Time: Thu Nov 27 11:04:05 GMT 2014

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

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