org.springframework.dao.DataIntegrityViolationException:无法执行语句;
@Entity
@Table(name = "GROUP")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContactGroup implements Serializable{
private static final long serialVersionUID = 7161778136151592279L;
@Id
@GenericGenerator(name = "increment", strategy = "increment")
@GeneratedValue(generator = "increment")
@Column(name = "GRP_ID")
private Long id;
}
在我的实体中,id是第一次插入数据时的主键,并且插入ID为1,如果我再次运行它会给出错误你能告诉我我错了什么
答案 0 :(得分:0)
如果你的桌子有自动增量,可以使用
@GeneratedValue(strategy=GenerationType.IDENTITY)