I'm trying out the example from here:
http://docs.jboss.org/hibernate/core/3. ... l-join-121When I create a person, set it's address and save, all tables are filled, Person,Address and PersonAddress.
But when I set an address on an existing person and update, the address is saved but PersonAddress, the join table is not filled.
This is the mapping (I just added cascade="all"):
<class name="Person" table="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
<join table="PersonAddress" optional="true" >
<key column="personId" unique="true"/>
<many-to-one name="address" column="addressId" not-null="true" unique="true" cascade="all"/>
</join>
</class>
<class name="Address">
<id name="id" column="addressId">
<generator class="native"/>
</id>
</class>
And with this code :
Person person = new Person();
session.save(person);
Address address =new Address();
person.setAddress(address);
session.update(person);
I get this output:
Hibernate: insert into Person default values
Hibernate: insert into Address default values
Hibernate: update PersonAddress set addressId=? where personId=?
So the PersonAddress is updated but no insert occurs first.
Any idea what's missing?
Bart