如何在Cassandra [java]中正确存储日期?

时间:2017-05-25 16:47:33

标签: java cassandra spring-data

我有以下实体:

    @Table("room_booked_by_guest_and_date")
    public class RoomByGuestAndDate {
        @PrimaryKeyColumn(name = "guest_id", type = PARTITIONED)
        private UUID guestId;
        @PrimaryKeyColumn(name = "booking_date", type = CLUSTERED, ordering = DESCENDING)
        private Date bookingDate;
        @Column("roomNumber")
        private Integer roomNumber;
        @Column("hotel_id")
        private UUID hotelId;
        @Column("confirmation_number")
        private String confirmationNumber;
     }

我想使用Spring Data for C *(CassandraRepository<RoomByGuestAndDate>)存储它 当我进行保存时,我得到以下异常:

"Expected 4 byte long for date (8); nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Expected 4 byte long for date (8)"

当我将Date更改为DataStax LocalDate时,我得到LocalDate cannot be cast to the Serializable的另一个例外。

所以,问题是如何将这个Java POJO正确地保存到C *列族?

0 个答案:

没有答案