0
は、私は<strong>は3つのテーブル</strong>に参加することはできません
3つのテーブル(Hibernateの注釈例外、OneToMany、mappedBy)が参加します。上の図を参照してください。あなたが見ることができるように、すべてのレストランには多くのテーブルがあり、すべてのテーブルには多くの予約があります。
レストランエンティティ:
@Entity
@Table(name = "restaurant")
public class Restaurant {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
private String name;
@Column(name = "aadress")
private String aadress;
@OneToMany(mappedBy = "restaurant")
private List<RestaurantTable> restaurantTables;
}
RestaurantTableエンティティ:
@Entity
@Table(name = "restaurant_table")
public class RestaurantTable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "restaurant_id")
private Restaurant restaurant;
@Column(name = "number")
private int number;
@Column(name = "count")
private int count;
@OneToMany(mappedBy = "restaurant_table")
private List<Booking> bookings;
}
予約エンティティ:
@Entity
@Table(name = "booking")
public class Booking {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "restaurant_table_id")
private RestaurantTable restaurantTable;
...
}
Hibernateの注釈例外:
org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: Booking.restaurant in RestaurantTable.bookings
ご協力いただきありがとうございます。