i try to use save() method, but the database schema doesn't have incremented value for Id, so it's giving Exception: ids for this class must be manually assigned before calling save()
so i want to do it, how can i do this?
i try to use save() method, but the database schema doesn't have incremented value for Id, so it's giving Exception: ids for this class must be manually assigned before calling save()
so i want to do it, how can i do this?
You can use @GeneratedValue annotation and specify the GenerationType IDENTITY.
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
public Long getId() { ... }
Read more at http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/
There are various other options available for key generation.
See here:
How to choose the id generation strategy when using JPA and Hibernate