【发布时间】:2015-09-30 13:10:24
【问题描述】:
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 时的主键,如果我再次运行它会给出错误你能告诉我我做错了什么
【问题讨论】:
-
使用非标准生成器,所以不是 JPA。 JPA 标准中为绝大多数用例提供了充足的选项
标签: java hibernate jpa spring-data-jpa