非主键的一对一映射

时间:2019-09-12 09:03:11

标签: java jpa

我必须使具有主键的实体和在其他实体中具有简单条目的同一列,但其值与第一个实体主键相同。

我想使用单调映射从拥有主键的第一个实体中获取数据。

Line.java:

/**
 * Line ID
 */
@Id
@Column(name = "c_idline", insertable = false, updatable = false)
@TableGenerator(name = "idLine_seq", table = TeamiumConstants.TeamiumSequenceTable, pkColumnName = TeamiumConstants.TeamiumSequencePkColumnName, pkColumnValue = "record_line_idline_seq", valueColumnName = TeamiumConstants.TeamiumSequenceColumnValue, initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "idLine_seq")
private Long id;

/**
 * The linked project
 */
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "c_idrecord")
private Record record;

/**
 * Function
 */
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "c_idfunction")
private RatedFunction function;

UserBooking.java:

@Column(name = "c_user_start_time")
private Date userStartTime;

/**
 * Night Time
 */
@Column(name = "c_user_end_time")
private Date userEndTime;

/**
 * Booking
 */
@Column(name = "c_booking_id")
private Long bookingId;

其中行实体的ID与用户预订实体中的bookingId具有相同的值

0 个答案:

没有答案