OK, I didn't put code because I thought it wasn't neccessary in this case, but here it is:
<hibernate-mapping>
<class name="MyClass" table="my_class">
<id
name="id"
type="java.lang.Long"
column="id">
<generator class="native" />
</id>
<property
name="oneProperty"
type="java.lang.String"
column="one_property"
length="10"/>
<many-to-one
name="nestedObject"
class="NestedObject"
not-null="true"
cascade="all">
<column name="id_nested_object" />
</many-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="NestedObject" table="nested_object">
<id
name="id"
type="java.lang.Long"
column="id">
<generator class="native" />
</id>
<property
name="anotherProperty"
type="java.lang.String"
column="another_property"
length="10"/>
</class>
</hibernate-mapping>
Java code:
myObject = ses.load(myClass, some_id);
BeanUtils.copyProperties(myBean,myObject);
myBean.setOneProperty('mec');
myBean.getNestedObject().setAnotherProperty('mic');
BeanUtils.copyProperties(myObject,myBean);//PROBLEM: here, a new Instance of nestedObject has been created; the old reference it's been lost
ses.saveOrUpdate(myObject); //NonUniqueObjectException on nestedObject; tried with saveOrUpdateCopy but didn't work because of this, I think:
http://forum.hibernate.org/viewtopic.ph ... texception