I would like to be able to store the different states of my object instance through time.
So, I added a timestamped version property to my object.
The thing is that version obviously just update the property value to work with the detached instances.
so here is my mapping file :
Code:
<class name="Demande" table="DEMANDE" optimistic-lock="version">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">demande_seq</param>
</generator>
</id>
<version type="timestamp" column="DATE_ETAT" name="dateEtat" />
<property name="contenu" type="text"/>
<property name="dateArrivee" type="timestamp"
column="DATE_ARRIVEE" />
<many-to-one name="etat" column="ETAT_ID"/>
<!-- more irrelevant things -->
</class>
I would like to things this way so I could get an easy trace of the evolution of the object. In fact, the
etat property contains the state of the instance, and that is quite the only thing I want to follow through time.
If I want to work on THE instance, I would just retrieve the later timestamped instance. If I want to see the complete trace for this isntance, I would get all the versions of the instance.