I, i'm using hibernate version 2.1.4,
I am currently migrating to hibernate.
I'm very intersted in
using UID generation feature of hibernate for generating
a part of a primary key.(
Code:
<generator>
mapping element).
But the mapping where i need such a feature contains a composite key.
Here is the mapping:
Code:
<hibernate-mapping>
<class
name="com.atronicsystems.database.data.MessageHistory"
table="SHISMSG"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="id"
class="com.atronicsystems.database.data.MessageHistoryId"
>
<key-property
name="casinoId"
type="java.lang.Integer"
column="ID_CASINO"
length="10"
/>
<key-property
name="messageId"
type="java.lang.String"
column="ID_MSG"
length="21"
/>
</composite-id>
....
I'cant change the primary key, it has to be a composite key!
But i had for each new record to generate a unique id for the
Code:
messageId
property (
Code:
casinoId
property is known).
So if i can't use the generate element in my composite key for the message id attribute, is there a way to
use one of the generator algorithm outside of the mapping.
In order for me to set the
Code:
messageId
attribute with a unique id generated by hibernate. (I don't want to rewrite a generator algorithm code :-( ).
Does anyone have a solution?
Thanks for your help.