RIGHT OUTER JOIN [message #898643] |
Fri, 27 July 2012 02:06 |
Nik s Messages: 3 Registered: July 2012 |
Junior Member |
|
|
I am new to JPA/Eclipse link -
i have created entity and mapping ManyToOne from issue to queue and OneToMany from Queue to Issue. i am able to fire a query with left join but not right join ...
Please can some one help how to achieve this.?
I am trying to do simple query test which is
select count(c.issue_id), q.queue_name from issue i RIGHT OUTER JOIN queue q
on
q.queue_id = i.issue_queue_id group by q.queue_name having i.issue_type = 'local'
----------
issue:
----------
issue_id int (PK)
issue_queue_id (FK ref to queue table queue_id )
issue_name varchar2(50),
issue_type varchar2(10)
----------
queue:
----------
queue_id int (PK)
queue_name varchar2(10)
[Updated on: Fri, 27 July 2012 02:07] Report message to a moderator
|
|
|
|
|
|
Re: RIGHT OUTER JOIN [message #899668 is a reply to message #899106] |
Wed, 01 August 2012 17:58 |
|
JPQL is normally defined in terms of objects, not data, so no ON clause is normally required,
select count(c.issue_id), q.queue_name from Issue i LEFT JOIN i.queue q group by q.queue_name having i.issue_type = 'local'
or,
select count(c.issue_id), q.queue_name from Queue q LEFT JOIN q.issues i group by q.queue_name having i.issue_type = 'local'
James : Wiki : Book : Blog : Twitter
|
|
|
|
Re: RIGHT OUTER JOIN [message #900785 is a reply to message #900390] |
Wed, 08 August 2012 13:17 |
|
You are probably better off using a native SQL query for a query this complex.
JPA does not support subselects in the FROM clause, but EclipseLink does have some support for this in 2.4. You would need to define the subselects as valid JPQL.
FROM queue_state q LEFT JOIN (Select i.queueStateKey from Issues i where i.type = 'xyz') iss ON (iss.queueStateKey = q.queueStateKey) GROUP BY q.queueName order by q.queueSequence asc
James : Wiki : Book : Blog : Twitter
|
|
|
Powered by
FUDForum. Page generated in 0.03566 seconds