So whenever I want to associate employees to a department I either
create a new employee or move employee from some other department ?
I am talking about the case when a "employee" object is currently
without any associated department. When we want to assign it to a
department the following query will not include the employee I am
interested in - 
"select * from DEPARTMENT left outer join EMPLOYEE on DEPARTMENT.ID =
EMPLOYEE.DEPARTMENTID "
A right join on the other hand will leave out all the 'departmemt'
objects without any employee.

Thanks 
-Umesh Tyagi


-----Original Message-----
From: Kevin Williams [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 23, 2007 12:43 PM
To: [email protected]
Subject: Re: RDB DAS - How to create non containment association ?

If you want departments and their related employees then you would
typically use a left join rather than a full join.  At least, this is
the scenario I see used most often.  Our test case:

RelationshipTests.testRelationshipModification2()

demonstrates this.

Thanks,

--Kevin



To read a set of departments and related employees you would typically
use a left outer join rather than a full join since you want

On 4/21/07, Umesh Tyagi (utyagi) <[EMAIL PROTECTED]> wrote:
>
> How to create non containment association between two existing objects
?
> For example, lets assume the following relationship is a non 
> containment association i.e. both objects can exist independently of 
> each other -
>
> ------------                  ----------
> |DEPARTMENT| 1______________* |EMPLOYEE|
> ------------                  ----------
>
> Playing with samples code I have noticed that in order to create 
> association between two object they need to be part of the same data 
> graph generated by a single query. So for the following line to work -
>
> department.getList("employees").add(employee)
>
> both 'department' and 'employee' dataobjects must be under same root 
> DataObject instance. To achieve this I tried to do a full outer join 
> between DEPARTMENT and EMPLOYEE but it is not supported by derby or 
> hsql. The equivalent union result is not typed to DEPARTMENT and 
> EMPLOYEE by DAS. The other option is to set the foreign key value 
> explicitly in the 'employee' object, but it is not desirable. Any 
> other ideas ?
>
> -Umesh Tyagi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to