Reputation: 309
If I'm using hibernate Pojo class using annotations as below - as I'm using GenerationType.AUTO
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
Is there any need to add "auto-increment" in database side also for an entity...?
Upvotes: 3
Views: 458
Reputation: 241
You can use other generator types for that like table or sequence generators. You will not have to "auto-increment" in the column. But there will be a change in the Pojo class and you will have to create sequence in your DB.
Please refer below link for different types of generator- HIbernate id generators
Upvotes: 0
Reputation: 40348
Yes,You need to add in database also
Example:
SQL>field_name dataType NOT NULL AUTO_INCREMENT,
Upvotes: 2