Reputation: 339
public class UserDetails {
@Id
private int userId;
I want what userId would read and generate next value of user_details_userid_seq (which is defined in databas). How to do this?
Upvotes: 0
Views: 43
Reputation: 339
Thanks crizzis for keywords to search, but solution:
@GeneratedValue(generator="my_seq_gen")
@SequenceGenerator(name="my_seq_gen", sequenceName="user_details_userid_seq", allocationSize = 1)
where the parameter allocationSize = 1
defines your sequence-increment as 1
.
Upvotes: 1