Hibernate version: 3.2
Code:
// Person.hbm
<hibernate-mapping package="">
<class name="Person"
table="person"
<set name="PermissionModifiers"
inverse="true"
cascade="save-update">
<key column="person" />
<one-to-many class="PersonPermission" />
</set>
</hibernate-mapping>
// PersonPermission.hbm
<hibernate-mapping package="">
<class
name="PersonPermission"
table="person_permission"
>
<meta attribute="sync-DAO">false</meta>
<!-- need to define Interceptor.isUnsaved()
<composite-id>
<key-many-to-one name="Person" class="Person" column="person" />
<key-many-to-one name="Permission" class="Permission" column="permission" />
</composite-id>
-->
<id
name="Id"
type="string"
column="id"
>
<generator class="assigned"/>
</id>
<many-to-one
name="Person"
column="person"
class="Person"
not-null="true"
>
</many-to-one>
<many-to-one
name="Permission"
column="permission"
class="Permission"
not-null="true"
>
</many-to-one>
<property
name="Permitted"
column="permitted"
type="boolean"
not-null="true"
/>
</class>
</hibernate-mapping>
postgres database
I create new PersonPermission objects and set the collection on the person and then try to persist using
session.saveOrUpdate(person);
session.flush();
But it only inserts never updates the state of the Permitted attribute for previously inserted rows.
The id is assigned in the Java and the database table is correctly populated.
So I get a row like
4:1, 4, 1, false
then I create a new PersonPermission object that has Permitted=true but is otherwise identical, add it to a collection and set the collection on the person, then persist as above. But the update never happens.
Any clues people?
Thanks.
[/code]