Columna de clave principal de anotación de Hibernate sin incremento automático
I want to map a column from my database as primary key which is not auto-increment. Please suggest me how to create hibernate annotation for this column
preguntado el 27 de noviembre de 13 a las 05:11
Use @Id annotation which defines the mapping of that property to the primary key column. Don't use @GeneratedValue annotation.
@Id @Column(name = "id") Integer id;
When doing this as you suggested as I try to insert in database it is executing select query - Ashish Nayal
when I am using @generatedvalue for primary key the insert query is executing correctly but otherwise not - Ashish Nayal
as you said your primary key column is not auto-increment, you need to set primary key during insert operation. But if you want hibernate to set primary key then use @generatedvalue which is you said have been using. - Vipul Paralikar
when I am giving primary key value from user interface,and inserting it using hibernate with annotation it is not executing insert query.Is it necessary in hibernate that we cannot assign value to primary key it is auto generated. - Ashish Nayal
referirse a stackoverflow.com/questions/3194721/… - Vipul Paralikar
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas hibernate or haz tu propia pregunta.
Bydefalut primary key column is not auto-increament untill you add any annotation for making it auto-increment - MayurB
but when I try to insert in database it is executing select query with this primary key column in the where clause - Ashish Nayal