Sunday, January 27, 2013

hibernate mapping create a unique constraint


That’s pretty simple in a hibernate mapping file. Also hbm2java generations works out of the box,.

<property name="field_one" type="int" unique-key="UNIQUE_GAME_XX" />
<property name="field_two" type="int" unique-key="UNIQUE_GAME_XX" />

Put the unique-key=”UNIQUE_GAME_XX” to every field or asociation you like to add to your constraint.

No comments:

Post a Comment