そのようなものを変換する標準的な方法があるかどうか知りたい
@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;
}