I ran into similar problem, where I was trying to save an object where his id was a primitive field (long), and at the time of create the object, the id was set to 0 by default, and Hibernate assumed I wanted to update the row with id = 0 (which obviously doesn't exist). My solution was change the id field to Long (wrapper), and that way, when I create a new instance the id is set to null, and Hibernate understands I am inserting a new element to the database. I hope it helps. Thanks.
Last active
April 21, 2016 11:22
-
-
Save baybatu/67922ae32f5576e8c2604b69a4e4f583 to your computer and use it in GitHub Desktop.
Why we must use wrapper type such as Long instead of primitive ones such as long for entity ID in Hibernate?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment