from FAQ:
Q: I have a composite key where one column holds a generated value - how can I get Hibernate to generate and assign the value?
A: We regard this as an extremely strange thing to want to do. If you have a generated surrogate key, why not just make it be the primary key?
However, if you must do this, you can do it by writing a CompositeUserType for the composite identifier class, and then defining a custom IdentifierGenerator that populates the generated value into the composite key class.
I'd need some information regarding the solution. How do we write and define a CompositeUserType and associate the IdentifierGenerator they are talking about?
Here is the composite key I have to handle (see below). They are both generated by Sequence numbers. We never update a user row because the client whants to keep every revision or every users. Instead we keep a sequence (1+) for every userId (1+).
Code:
<composite-id name="id" class="gouv.ssss.rsipa.modele.entity.Rsipa04t02UsagrId" >
<key-property name="idUsagr" type="big_decimal">
<column name="ID_USAGR" precision="22" scale="0" />
</key-property>
<key-property name="noSeqncUsagr" type="big_decimal" >
<column name="NO_SEQNC_USAGR" precision="22" scale="0" />
</key-property>
</composite-id>