1

There are two Parent/Children relationship entities. And only have the mapping configuration in child's hbm.xml file. Like this:

    <many-to-one 
    name="child"
    class="com.Child"
    update="true"
    insert="true"
    cascade="save-update">
        <column not-null="false" name="PARENT_ID"></column>
   </many-to-one>

No <one-to-many> configuration in parent's hbm.xml.

Now I want to use ClassMetaData to get all the properties from the entity to verify it dirty or not. But I cannot get the child properties from ClassMetaData because it not configured.

But When I use session.saveAndUpdate(parentEntity), Hibernate knows the child is dirty and can update dirty child entity. How the Hibernate do that? Is there anyway that I can get the dirty state of the child entity?

lephix
  • 1,144
  • 13
  • 23
  • You mean like this: http://stackoverflow.com/questions/5268466/how-does-hibernate-detect-dirty-state-of-an-entity-object ? – Stijn Geukens Jun 05 '13 at 10:42

1 Answers1

1

Some googling reveals that there is no 'simple' way. You need to use hibernate interceptors for this. Your use case is explained in this blog.

Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101