Created
February 27, 2017 08:37
-
-
Save gokman/da89078e606b02efde0d40f05b8d9219 to your computer and use it in GitHub Desktop.
Spring JPA - non-primary auto generated field mapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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