Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Re: bidirectional one-to-many relationship with join-table

Frank Schwarz

2008-08-11

Replies: Find Java Web Hosting

Author LoginPost Reply


Pinaki Poddar wrote:
>
> Hi,
>
> Address address = person.getAddresses().iterator().next();
> person.getAddresses().remove(address);
> address.setPerson(null);
>
> Generally speaking, in JPA world, nulling a relation or removing an
> element from a collection do not imply that the corresponding database
> record is deleted. To delete records from database, em.remove() needs to
> be invoked.
>
> However, delete-orphan behavior that your example code implies is
> supported by OpenJPA with @Dependent/@(protected)
> relation.
>

Please note that I was referring to the join-table, not the "entity"-tables.
I consider nullifying one side of the join-table not to be efficient for
dissolving a relationship. It will probably do no harm, but the join-table
will gradually be messed up with these "half-null"-tupels.

If you enforce integrity so that the Address_Phone id has to be unique in
the join-table (otherwise it would be a many-to-many relationship type), you
will never be able to establish new Person-Address connection with that
particular address object.

-- Frank



--
Sent from the OpenJPA Users mailing list archive at Nabble.com.

©2008 gg3721.com - Jax Systems, LLC, U.S.A.