Hi,
We are implementing auditing/logging of object changes with the hibernate3 Event architecture. At the moment we have a problem with unidirectional one-to-many associations.
Here is a simplified example of the problem:
I have a unidirectional one-to-many association with the following mapping:
Code:
<hibernate-mapping >
<class name="Parent" table="parent">
<id name="id" column="id_parent" type="long"/>
<set name="children" lazy="false">
<key column="id_parent" foreign-key="fk_child_parent"/>
<one-to-many class="Child"/>
</set>
</class>
</hibernate-mapping>
<hibernate-mapping >
<class name="Child" table="child">
<id name="id" column="id_simplechild" type="long"/>
<property name="name" column="x_name" type="string" />
</class>
</hibernate-mapping>
We wrote a PostInsertEventListener to log the changes on the objects. While handling the event for Child objects we have this problem:
Is there a way to find the parent Object for this Child object. The problem is, that there is no navigation from the Child to the Parent Object and there also is no property in the hibernate mapping for this navigation. I searched the api docu for the PostInsertEvent and the related classes but found nothing that helped me further.
I know that a possible solution would be to design the association bidrectional. But unfortunately I can't change the design of the associations.
We work with hibernate 3.2.3
Thanks for any help you can give me.
Tom