【发布时间】:2020-04-01 05:43:43
【问题描述】:
据本文https://vladmihalcea.com/hibernate-and-uuid-identifiers/ 我想为我的班级生成休眠 UUID。 IntelliJ 说'无法解析'GenericGenerator''。它也不识别 GenericGenerator 导入。
Entity.java:
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
import org.hibernate.annotations.GenericGenerator;
@MappedSuperclass
public abstract class Entity {
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid")
@Column(columnDefinition = "CHAR(32)")
@Id
protected String id;
public BaseEntity() {
}
}
我的 build.gradle 中有这些依赖项:
compile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
runtime group: 'org.hibernate', name: 'hibernate-core', version: '5.4.9.Final'
【问题讨论】: