报错内容
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
俩个实体类
@Entity
@Table(name="systemdictionarydetail")
@JsonIgnoreProperties( value={"hibernateLazyInitializer","handler"})
public class Systemdictionarydetail extends Base{
private String name;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="types_id")
private Systemdictionarytype types;
@Entity
@Table(name="systemdictionarytype")
@JsonIgnoreProperties( value={"hibernateLazyInitializer","handler"})
public class Systemdictionarytype extends Base{
public static final String PRODUCT_BRAND="productBrand";
public static final String PRODUCT_UNIT="productUnit";
private String name;
@Column(updatable = false)
private String sn;
错误原因
必填属性id为空
解决方法:设置id值或者设置下拉框选择