Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gokman/0c94e18aee1af45fa831dbeafe44d41c to your computer and use it in GitHub Desktop.
Save gokman/0c94e18aee1af45fa831dbeafe44d41c to your computer and use it in GitHub Desktop.
Spring data jpa primary key with sequence in postgresql
//user_id_seq is the sequence that defined in posgresql database for id column
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_id_seq")
@SequenceGenerator(name = "user_id_seq", sequenceName = "user_id_seq")
@Column(name = "id")
public int getId() {
return id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment