Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.2
Mapping documents:
<set
name="masquesChamps"
table="MASQUECHAMP"
lazy="true"
cascade="all"
inverse="false"
>
<key column="ID_MASQUE" />
<one-to-many class="com.orange.greco.persistance.dao.masque.bean.MasqueChampsTO" />
</set>
...
<class
name="com.orange.greco.persistance.dao.masque.bean.MasqueChampsTO"
table="MASQUECHAMP"
>
<composite-id >
<key-many-to-one name="masque" class="com.orange.greco.persistance.dao.masque.bean.MasqueTO" column="ID_MASQUE" />
<key-many-to-one name="champ" column="ID_CHAMPAFFICHE" class="com.orange.greco.persistance.dao.references.bean.ChampsAfficheTO" />
</composite-id>
<property name="rangChampsAffiche" type="java.lang.Integer" column="RANG" />
</class>
When I try to save a MasqueTO Object, Hibernate issue an update statement onto children MasqueChampsTO objects instead of insert statement.
After browsing through documentation, possible solutions are :
-Adding Timestamp column to MasqueChampsTO table
( this solution is not possible to me)
- using Interceptor for MasqueChampsTO entity in order to find out if the object must be saved or updated.
Setting up the interceptor for MasqueChampsTO entities is not obvious to me.
Must an interceptor be bound to the hibernate session ?
In such case, I can register only one interceptor into my application and my interceptor code must switch between every entity instance.
I believe a better solution exists
Could anyone explain me how to register an Entity interceptor for a single class to the Hibernate Session ?
Sincerely,
Bob