Cannot insert the value Null into column "ID" - Hibernate

Viewed 2450

I have created a table and its api which I am verifying through postman. Here is my primary key of the the table:

 @Data
 @AllArgsConstructor
 @NoArgsConstructor
 @Entity
 @Table(name = "ALERT")
 public class Table Name{

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ALERTID")
private Integer id; 

When I verify this api using Postman it gives me this error :

  SQL [n/a]; constraint [null]; nested exception is 
 org.hibernate.exception.ConstraintViolationException: could not execute statement] with root cause

com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert the value NULL 
  into column 'ID', table 
  'CRM.dbo.ALERT'; 
  column does not allow nulls. INSERT fails.

I have created many other tables and their apis using this same way and they are working fine. But only this table is giving me this error. Any idea why am I getting this error?

1 Answers
Related