Hibernate一对一entity设置

tech2024-05-13  91

主表

@FrontField(description="旷工统计汇总") @OneToOne(mappedBy="attendanceOriginal") private VariousHoursStatistics vHoursStatistics;

子表

@JsonBackReference @FrontField(description="考勤ID") @OneToOne(fetch=javax.persistence.FetchType.EAGER) @JoinColumn(name = "attendance_original_id") private AttendanceOriginal attendanceOriginal;

两边set后各自保存

vHoursStatistics.setAttendanceOriginal(attendanceOriginal); attendanceOriginal.setVHoursStatistics(vHoursStatistics); variousHoursStatisticsService.save(vhsEntity); attendanceOriginalService.save(entity);

最新回复(0)