Ola !!!
Alguém poderia me ajudar para salvar um objeto Cliente (conforme o codigo abaixo) no banco Microsoft Sql Server 2000 ?
Eu estou começando a estudar o Hibernate agora, então estou tendo muitas dificuldades.
@Entity
@Table(name = "Cliente")
public class Cliente {
@Id
@GeneratedValue (strategy = GenerationType.AUTO)
private Long id;
@Column(name = "nome_cliente", nullable = false, length=60)
private String nome;
...
...
No banco, criei a tabela Cliente com o campo "id" c/ identity, auto incrementando em 1.
Porem, ao tentar salvar o objeto Cliente, a seguinte SQLException é lançada:
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot insert explicit value for identity column in table 'Cliente' when IDENTITY_INSERT is set to OFF.
Sei que o hibernate está utilizando a seguinte query DDL:
Hibernate: insert into Cliente (id, idDaCategoria, idade_cliente, nome_cliente) values (null, ?, ?, ?)
Se alguém puder me ajudar, ficarei muito grato.