annotations - Auto Increment A Column With Hibernate -
i have situation need increment non primary key column upon insert of every new record. column not primary key. has unique constraint. how can use hibernate annotations accomplish auto increment of particular column? know can done quite primary keys, want same thing done non primary key column (meaning without using @id annotation?)
--thanks
as far can see, can use hibernate specific annotation @generated
. field this:
@generated(value="generationtime.insert") @genericgenerator(name="fieldgenerator", strategy="sequence") private x field;
you can read different types of strategies here.
i'm 90% sure should work. if doesn't let me know.
Comments
Post a Comment