I see in net.sf.hibernate.collection.Set that add() calls write() (from PersistentCollection) to mark the collection snapshot as dirty; then it calls add() on the underlying hashSet(). So we're dirty whether or not any elements were actually added. OK, so I understand that much... now I just have to figure out why the persister thinks that a new row needs to be inserted in the link table.
Honestly I'm starting to get a little desperate for a breakthrough on this... :-)
Here's the mapping for one end of the association:
Code:
<set
name="subscribedPublications"
table="subscription"
lazy="true"
inverse="true"
cascade="none"
access="property"
>
<key column="subscriber_id"/>
<many-to-many column="publication_id"
class="com.wrinkledog.phydeaux.model.Publication"/>
</set>
...and the other...
Code:
<set
name="subscribers"
table="subscription"
access="field"
lazy="true"
cascade="none"
>
<key column="publication_id"/>
<many-to-many
column="subscriber_id"
class="com.wrinkledog.phydeaux.model.Subscriber"
/>
</set>
...and the DDL for the association table looks like this:
Code:
create table subscription (
subscriber_id varchar(32) not null,
publication_id bigint not null,
primary key(subscriber_id, publication_id),
foreign key subscriber_reference (subscriber_id)
references subscriber(subscriber_id),
foreign key publication_reference (publication_id)
references publication(publication_id)
);
Any help much appreciated!
Thx-a-lot,
- mark