在Spring数据中,按日期发现日期无法正常工作,数据库中的beacuase'bookingDate'数据类型是没有时区的时间戳(Postgre SQL),我需要按日期查找避免列的时间
域
@Entity
@Table(name = "BOOKING")
public class Booking extends AbstractAuditingEntity {
ManyToOne
@JoinColumn(name = "BOOK_ID")
private Book book;
@Column(name = "SEAT_NO")
private String seatNo;
@Column(name = "BOOKING_DATE")
private Date bookingDate;
存储库
public interface BookingDAO extends JpaRepository<Booking, Long> {
Booking findFirst1BySeatNoAndBookingDateOrderByBookingDateDesc(String seatNo, Date date);
}
答案 0 :(得分:0)
使用@Temporal
,您会想要它。
Booking findFirst1BySeatNoAndBookingDateOrderByBookingDateDesc(String seatNo, @Temporal(TemporalType.DATE) Date date);