Columna de clave principal de anotación de Hibernate sin incremento automático
Frecuentes
Visto 2,144 veces
1 Respuestas
0
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;
respondido 27 nov., 13:05
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