| Left outer join on a unidirectional many to one mapping [message #518116] |
Wed, 03 March 2010 02:08  |
Andreas Christoforides Messages: 6 Registered: July 2009 |
Junior Member |
|
|
I have a many to one relationship from object A to object B.
When I use a bidirectional mapping I can executed the following JPQL query:
SELECT b, a FROM B b LEFT OUTER JOIN b.a a
How can I achieve the same result if I have a unidirectional mapping?
I know it can be done in SQL but I would like to implement it in JPQL.
Thanks,
Andreas
|
|
|
|
|
|
| Re: Left outer join on a unidirectional many to one mapping [message #519383 is a reply to message #518116] |
Mon, 08 March 2010 11:52  |
James Sutherland Messages: 1844 Registered: July 2009 |
Senior Member |
|
|
That is what,
"Select b, a from A a left join a.b b"
would generate? I assume you want "B b LEFT OUTER JOIN A a" though.
I guess there is no way to do this in JPA without adding the bidirectional relationship, or using native SQL.
In EclipseLink, you can add a OneToOneQueryKey that allows you to define a relationship without having a mapping for it. You can then use the query key in EclipseLink Expression queries. Unfortunately, query keys are not currently supported in JPQL queries (please log a bug for this and vote for it).
James : Wiki : Book : Blog
|
|
|
Powered by
FUDForum. Page generated in 0.07386 seconds