users@glassfish.java.net

Re: JPA relationship pattern question

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Fri, 04 May 2007 13:13:09 -0700

glassfish_at_javadesktop.org wrote:
>>I'd define the pk on partyId and postalAddressId, b/c
>>these values
>>identify the relationship btw Party and
>>PostalAddress.
>
>
> Well, no. A Party may put the same address under two different types. Joe (party id=35) calls 123 Anywhere Street (id=4) his "preferred" and his "mailing" address. Those two records look like this:
>
> 35 | "preferred" | 4
> 35 | "mailing" | 4
>
> Note that 35 and 4 are common here and hence can't be used as the primary key.
>
>
>>This is an overlapping pk/fk situation. In this case,
>>you'd need to
>>map PartyPostalAddressBinding's relationship fields
>>as
>>updatable=false.
>
>
> Something looks interesting here. So you're saying to "double up" on my properties, i.e. do something like this (I'll just do it for the PartyEntity property below):
> [code]// inside the binding class
> @ManyToOne...
> public PartyEntity getPartyEntity() ...
>
> @WhateverTheAnnotationIsForARegularOldJoin(updatable=false)
> public long getPartyEntityID() ...
> [/code]
> ...? Interesting. Would I also have to say insertable=false?

You do if you are using TopLink Essentials (GlassFish default) - there is a bug
that one doesn't work without the other.

regards,
-marina

>
> Laird
> [Message sent by forum member 'ljnelson' (ljnelson)]
>
> http://forums.java.net/jive/thread.jspa?messageID=215577
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>