我想知道是否有标准的方法来转换这样的东西
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "user"))
@Id
@GeneratedValue(generator = "generator")
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
到没有休眠的标准 JPA 2 模型
编辑:让我们看看两个实体(我只保留了带注释的有趣部分)
@Entity
@Table(name = "author", catalog = "test")
public class Author implements java.io.Serializable {
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "user"))
@Id
@GeneratedValue(generator = "generator")
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
@OneToOne(fetch = FetchType.LAZY)
@JsonBackReference
@PrimaryKeyJoinColumn
public User getUser() {
return this.user;
}
和
@Entity
@Table(name = "user", catalog = "test")
public class User implements java.io.Serializable {
@OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
public Author getAuthor() {
return this.author;
}