users@glassfish.java.net

Re: JPQL: outer join on entity beans without association

From: <glassfish_at_javadesktop.org>
Date: Tue, 20 Mar 2007 04:43:50 PST

Hi,

is there any issue defining a ManyToOne relationship between Employee and Project? This would make it much easier:
SELECT e.name, p FROM Employee e LEFT JOIN e.project p

I do not have a good solution for the entity classes without relationship. You could run two separate queries. One query returning the employees being involved in a project:
SELECT e.name, p FROM Employee e, Project p WHERE e.projectID = p.projectID
And another query returning the employees without project:
SELECT e.name FROM Employee e WHERE e.projectID IS NULL

I thought about using an OR expression:
SELECT e.name, p FROM Employee e, Project p WHERE e.projectID IS NULL OR e.projectID = p.projectID
But this would combine any employee without a project with all the projects stored in the database and this is certainly not what you want.

Regards Michael
[Message sent by forum member 'mb124283' (mb124283)]

http://forums.java.net/jive/thread.jspa?messageID=208917