- in postgres I create sequence: user_details_userid_seq
- now I want to use it in my class
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?
@GeneratedValue(strategy = SEQUENCE, generator = "user_details_generator") @SequenceGenerator(name = "user_details_generator", sequenceName="user_details_userid_seq", allocationSize = <your_sequence_increment>)
allocationSize = 1
might not be the most performant solution. However, if other apps can insert data into your table, it is also the least confusing