This is my Object that represent my table:
@Entity
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class Motivo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long codigomotivo;
private String descricaomotivo;
private Integer codrubricadominio;
private String tipo;
}
My column codigomotivo
in database is identity
, she autoincrement values. In this form, i receive error:
com.microsoft.sqlserver.jdbc.SQLServerException: DEFAULT or NULL are not allowed as explicit identity values.
this is a insert that hibernate generate in log:
Hibernate: insert into Motivo (codigomotivo, codrubricadominio, descricaomotivo, tipo) values (null, ?, ?, ?)
I Have tried too @GeneratedValue(strategy = GenerationType.AUTO)
and receive this message in log:
Hibernate: call next value for hibernate_sequence com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'value'
And too only @GeneratedValue
and receive same error above.
How i can insert values in my table in this configuration PK in Sql Server
?
只需将您的方言更改为:
org.hibernate.dialect.SQLServerDialect
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.