为了账号安全,请及时绑定邮箱和手机立即绑定

引用表中的JpaRepository findBy字段

引用表中的JpaRepository findBy字段

拉风的咖菲猫 2021-05-10 18:45:06
@Entity@Table(name="seance")@Datapublic class Seance {    @Id    @GeneratedValue(strategy = GenerationType.AUTO)    @Column(nullable = false, unique = true)    private Integer id;    private java.time.LocalTime displayTime;    @ManyToMany(mappedBy = "seances")    @JsonIgnore    private List<Repertoire> repertoires = new ArrayList<>();    @OneToMany(mappedBy = "reservationSeance", cascade = CascadeType.ALL, fetch = FetchType.LAZY)    @JsonIgnore    private List<Reservation> reservations = new ArrayList<>();}@Entity@Table(name="reservation")@Datapublic class Reservation {    @Id    @GeneratedValue(strategy = GenerationType.AUTO)    @Column(nullable = false, unique = true)    private Integer id;    private java.time.LocalDate reservationDate;    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)    @JoinColumn(name = "id_seance")    private Seance reservationSeance;   .........}我有两个与ManyToOne有关的实体,我尝试扩展JpaRepositorypublic interface ReservationRepository extends JpaRepository<Reservation,Integer> {    List<Reservation> findReservationsByReservationSeance(Seance seance);}但是由于参数我必须使用所有Object Seance,因此可以使用JpaRepository仅通过Seance表中的id和displayTime查找保留,还是需要编写自己的方法?
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 397 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信