I have an embeddable class that is like this
@Data
@Embeddable
@NoArgsConstructor
@AllArgsConstructor
public class BookingDetail {
@OneToOne
private Player player;
@Column(name = "booking_status")
private String bookingStatus;
}
and the second class
@Data
@Entity
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bookings")
public class Booking {
//...Id and other fields
@ElementCollection
@CollectionTable(name = "player_booking_details", joinColumns = @JoinColumn(name = "booking_id"))
private List<BookingDetail> playerBookingDetails;
}
now I want the Player class to contains all booking items, for now, I have his class:
@Data
@Builder(builderMethodName = "toBuild")
@Entity
@NoArgsConstructor
@AllArgsConstructor
public class Player {
//Id and other fields
@OneToMany(mappedBy = "?")
private Set<Booking> bookings;
}
but this doesn't work, I need to know what should be the value of mappedBy
, as you can see the bookings
field in Player
class is a list of an embeddable item, when I run the project without adding mappedBy
JPA will create 3 tables, player
, player_booking_details
and player_bookings
, and player_bookings
always is empty, I know need to add mappedBy
but the problem is with List<BookingDetail>
can somebody guide me to solve this problem and remove the extra created table player_bookings
from the domain?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…