Spring JPA:如何查找包含列表的所有枚举的行

时间:2020-07-16 22:33:15

标签: java spring postgresql

我在Postgres中有一个保留表,其中有bookingdate(postgres日期)和reservationstate(postgres枚举)。我使用了{v3-mihalcea的@ vlad-mihalcea的库,用于讨论here来映射Java枚举和postgress枚举,并且从存储库接口进行以下查询工作正常

//returns all Reservations in date range with A specified reservationState
 List<Reservation> findByReservationStateAndBookingDateBetween(EReservationState state, Instant from, Instant to);

//returns all Reservations in date range with ANY of the specified reservationStates
 List<Reservation> findByReservationStateInAndBookingDateBetween(List<EReservationState> states, Instant from, Instant to);

如何编写查询以返回用户具有所有指定的reservationStates的日期范围内的所有行(换句话说,我要拉出所有具有STATE1 / BOOKED,STATE2 / COMPLETED,STATE3 / ABSENTEE,STATE4的行/ RESCHEDULED等)?下面的示例查询需要修复

//give me all users in specified date range, that has all specified states(BOOKED+RESCHEDULED+COMPLETED) given in the first parameter(list)
 List<Reservation> findByAllReservationStatesAndBookingDateBetween(List<EReservationState> states, Instant from, Instant to);
//Ex: List of BOOKED+RESCHEDULED states will give only those users who has the state of BOOKED and RESCHEDULED but no other state in the given date range

0 个答案:

没有答案
相关问题