ChrisGeo
ChrisGeo

Reputation: 3917

Hibernate Auto-Increment Non-ID column

I have a column "val" lets say, which is not an id column and I want to set it as auto-increment. Is there any way I can do that with a Hibernate/JPA annotation?

Upvotes: 0

Views: 2175

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

Yes, there is a way. Annotate the auto-generated field with @Generated, to let Hibernate know that it has to re-read the entity after an insert and/or update to get the value of the generated value.

Upvotes: 1

Related Questions