Hi there.
I have a unidirectional many-to-one mapping. There is a requirement that child entity should not be able to update the parent entity.
The mapping is following:
Code:
<hibernate-mapping package="com.system.dao.hibernate">
<class name="com.system.Budget" table="BUDGET">
<id name="id" column="ID" type="long">
<generator class="sequence">
<param name="sequence">SEQ_BUDGET</param>
</generator>
</id>
<property name="name" column="NAME" type="string"/>
<join table="SECURITY_OBJECT" subselect="select OBJECT_ID, SECURITY_GROUP_ID from SECURITY_OBJECT so where so.SECURITY_OBJECT_TYPE_CODE = 'BUDGET'" inverse="true" optional="true">
<key column="OBJECT_ID"/>
<many-to-one name="securityGroup" column="SECURITY_GROUP_ID" class="com.system.security.SecurityGroup" lazy="false" update="false" insert="false" cascade="none" />
</join>
</class>
</hibernate-mapping>
According to the requirement i mentioned above, the following code:
Code:
Budget budget = budgetDao.findById(4L);
budget.getSecurityGroup().setName("the new name");
budgetDao.update(budget);
shouldn't issue "UPDATE SECURITY_GROUP" sql statement. But it does :-(
How can i make that securityGroup wouldn't became updated while saving Budget entity?