persistence@glassfish.java.net

Re: Outer joins for secondary tables?

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 03 Aug 2006 12:34:37 -0700

Hello Gordon,

Will TopLink throw an exception if the user changes such entity?
Or will it allow the database to win (i.e. it'll update successfully
only those entities that have rows in both tables)?
How about a delete?

thanks,
-marina

Gordon Yorke wrote:
> Hello Markus, This customization is both in TopLink and TopLink Essentials.
> It does require use of TopLink API directly and is not exposed through the
> JPA. It is the user's responsibility to either treat the class as readonly
> or mark all of the mappings read-only (updatable, insertable = false in JPA).
> The best way to map this relationship is as a OneToOne.
>
> --Gordon
>
> -----Original Message----- From: Markus.Fuchs_at_Sun.COM
> [mailto:Markus.Fuchs_at_Sun.COM]On Behalf Of Markus Fuchs Sent: Thursday, August
> 03, 2006 2:14 PM To: Gordon Yorke Cc: persistence_at_glassfish.dev.java.net
> Subject: Re: Outer joins for secondary tables?
>
>
> [including a broader audience]
>
> Hi Gordon,
>
> Thanks for your information! I have a couple of further questions:
>
> Gordon Yorke wrote:
>
>
>> Hello Markus, In TopLink a user can customize the
>> MultipleTableJoinExpression in the DescriptorQueryManager. TopLink uses
>> this expression when joining, updating this expression to use outer joins
>> will cause TopLink to use outerjoins for secondary tables.
>>
>>
>>
>
> Is this customization a TopLink product feature? I understand it is not part
> of TopLink-Essentials.
>
>
>> This method, however, will only work for read-only objects as TopLink will
>> be unable to update any secondary fields for objects that did not have a
>> row in the secondary table. TopLink has no way of determining if the row
>> was there once the object was built. Having this functionality would be a
>> very large undertaking and would proportionally be of little value.
>>
>>
>>
>
> Does customizing the MultipleTableJoinExpression make the entity read-only
> automatically or is it the user's responsibility to treat that class as
> read-only? If the class is read-only automatically, would it be possible to
> treat only the fields actually mapped to the secondary table as read-only? In
> a JPA context, would it be sufficient to mark the secondary table fields
> "updatable=false"?
>
> Thanks!
>
> -- markus.
>
>
>> This sort of relationship should be mapped as an OneToOne.
>>
>> --Gordon
>>
>> -----Original Message----- From: Markus.Fuchs_at_Sun.COM
>> [mailto:Markus.Fuchs_at_Sun.COM]On Behalf Of Markus Fuchs Sent: Wednesday,
>> August 02, 2006 7:27 PM To: Tom Ware; Gordon Yorke Subject: Outer joins for
>> secondary tables?
>>
>>
>> Hi Tom, Gordon,
>>
>> I remember from one telephone meeting that TopLink can be switched
>
>> from generating inner joins for secondary tables to outer
>
>> joins.
>>
>> Looking into the code, I couldn't find such option. What am I missing? I
>> couldn't even find an indicator in ClassDescriptor like
>> "hasSecondaryTableMapping()". Is it possible to assume that the class has
>> secondary table mappings, that if
>> ClassDescriptor#additionalTablePrimaryKeyField != null?
>>
>> Thanks so much,
>>
>> -- markus.
>>
>>
>>
>>