0

我正在使用 Cassandra 作为存储在 Azure 中的数据库构建 Springboot 后端。我面临一个随机发生的奇怪问题,通常在应用程序的第一次启动时发生。

我的数据模型:

@Table("product_user_habit")
public class ProductUserHabitDTO {

    @Column
    @PrimaryKey
    private ProductUserKey puk;
    @Column
    private String product_name;
    @Column
    private String category;
    @Column
    private int quantity;
    @Column
    private String brand;

    public ProductUserHabitDTO() {
    }

    public ProductUserHabitDTO(ProductUserKey puk,
                               String product_name,
                               String category, String brand, int quantity) {
        this.puk = puk;
        this.product_name = product_name;
        this.category = category;
        this.quantity = quantity;
        this.brand = brand;
    }

我的存储库:

@Repository
public interface ProductUserHabitsRepository extends CassandraRepository<ProductUserHabitDTO, ProductUserKey> {
    @AllowFiltering
    ProductUserHabitDTO findProductUserHabitDTOByPuk_UseridAndPuk_Code(String username, String code);
}

当我调用这个方法时,它会抛出这个(通常在第一次启动时):

"Query; CQL [SELECT * FROM product_user_habit WHERE userid='bbbbbbbb' AND code='3274080005003' ALLOW FILTERING;]; Expected size of integer 8: Got 13 bytes; nested exception is com.datastax.driver.core.exceptions.InvalidQueryException: Expected size of integer 8: Got 13 bytes","trace":"org.springframework.data.cassandra.CassandraInvalidQueryException: Query; CQL [SELECT * FROM product_user_habit WHERE userid='bbbbbbbb' AND code='3274080005003' ALLOW FILTERING;]; Expected size of integer 8: Got 13 bytes;"

有时它工作正常。我不明白,因为我的查询中没有任何整数。同样对于我的测试,我总是使用相同的查询,以便用户 ID 和代码工作。

有人知道发生了什么吗?这让我疯狂 :(

谢谢 !

4

1 回答 1

0

Cosmos DB 的 Cassandra API 不正式支持此驱动程序。在此处查看受支持驱动程序的完整列表,Azure Cosmos DB Cassandra API 支持的 Apache Cassandra 功能

谢谢。

于 2020-05-23T21:29:39.693 回答