users@glassfish.java.net

Re: JPA relationship pattern question

From: <glassfish_at_javadesktop.org>
Date: Fri, 04 May 2007 09:14:58 PDT

> 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?

Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

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