Hello,
I need some help in the following issue:
I have a composite id of three fields, and one of them has to be unique.
I know that the Hibernate specifications says NOT to use composite id, but the database design demands it.
My issue is that I have to generate unique values and I would like that the database to set them - pretty much like autoincrement.
I have searched all over internet, "Hibernate in Action", etc., for setting an autoincrement column inside a composite id, but there seems there is no way using Hibernate and XDoclet (yes, I'm using XDoclet for generating the hbm.xml files).
If anyone knows a way of creating unique values either by adding an autoincrement column inside a composite id using Hibernate and/or XDoclet, either by using some very simple and robust mechanism, please let me know.
Thank you in advance !
PS: I'm using Hibernate 3.1.0 and XDoclet 1.2.3.
The database is MySQL 4.1.5, but in the future I will use Oracle (so please provide a solution compatible with MySQL and Oracle - in fact a more generic solution will be better :) ).
|