【发布时间】:2020-10-21 18:16:14
【问题描述】:
我创建了一个表及其 api,我正在通过邮递员进行验证。 这是我的表的主键:
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ALERT")
public class Table Name{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ALERTID")
private Integer id;
当我使用 Postman 验证这个 api 时,它给了我这个错误:
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.
我用同样的方式创建了许多其他表和它们的 api,它们工作正常。但只有这张桌子给了我这个错误。知道为什么我会收到此错误吗?
【问题讨论】:
-
那么
generalCoService.saveAlert(obj)长什么样子? -
请查看我更新的问题@BenjaminMaurer
标签: java hibernate visual-studio-code