这是我必须编写的内容,以使UUID作为主键工作,在hibernate中使用完整的UUID类型(在所有目的上)。由于这依赖于一些特定于Hibernate的代码,我需要做些什么才能将此代码转换为在eclipselink上工作?
package com.lm.model;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.UUID;
@Entity
@Table(name = "tasks")
public class Task {
@Id
@NotNull
@Type(type = "pg-uuid")
@GeneratedValue(generator = "myUUIDGenerator")
@GenericGenerator(name = "myUUIDGenerator", strategy = "uuid2")
@Column(name = "task_id", columnDefinition = "uuid")
private UUID id;
@NotNull
@Size(min = 1, max = 100)
private String description;
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
public UUID getId() {
return id;
}
public void setId(final UUID id) {
this.id = id;
}
}