persistence@glassfish.java.net

RE: joins and relationships

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Mon, 6 Mar 2006 09:25:45 -0500

Hello Scott,
        EJBQL provides for fetching both objects at the same time, though the use of the JOIN FETCH keyword. In an example where A has a 1-1 to B through the property b the EJBQL would look like:
SELECT a FROM A a JOIN FETCH a.b
--Gordon

-----Original Message-----
From: Scott.Oaks_at_Sun.COM [mailto:Scott.Oaks_at_Sun.COM]On Behalf Of Scott
Oaks
Sent: Friday, March 03, 2006 6:05 PM
To: persistence_at_glassfish.dev.java.net
Subject: joins and relationships


I have two entities that have a OneToOne relationship, which thus has
EAGER loading. I'd assumed that they would be loaded in a single SQL
statement, but if I trace the SQL, I see two statements, one for each
object. [Ditto for ManyToOne relationships.]

Is there a way to configure the relationship to be obtained through a
single SQL statement utilizing a join?

-Scott