Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gokman/da89078e606b02efde0d40f05b8d9219 to your computer and use it in GitHub Desktop.

Select an option

Save gokman/da89078e606b02efde0d40f05b8d9219 to your computer and use it in GitHub Desktop.
Spring JPA - non-primary auto generated field mapping
//If you have auto generated field and it is not primary key. So you need below mapping for that column:
@Basic
@Column(name = "id", insertable = false)
public long getId() {
return id;
}
//on above the important point is "insertable=false" statement
//if you use insertable=false db will generate and insert on its own to that column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment