I have this class Person mapping two tables: Persons and PersonsAUD (audit):
<class catalog="test" name="test.Person" table="Persons" entity-name="Person">
<id name="id" type="int">
<column name="Id"/>
<generator class="increment"/>
</id>
<property name="name" type="string">
<column length="30" name="Name" not-null="true"/>
</property>
...
</class>
<class catalog="test" name="test.Person" table="PersonsAUD" entity-name="PersonAUD">
<id name="idAudit" type="int">
<column name="IdAudit"/>
<generator class="increment"/>
</id>
<property name="name" type="string">
<column length="30" name="Name" not-null="true"/>
</property>
<property name="action" type="string">
<column length="10" name="Action" not-null="true"/>
</property>
...
</class>
I'm trying to save this object in the two tables like this:
session.save("Person", person);
session.save("PersonAUD", person);
But only the first row is inserted, not the audit row; probably hibernate check the person's state and confirms that is already saved.
Any chance to force hibernate to save in both tables the same object?
Thanks in advance.