0

I'm building a Springboot Backend using Cassandra as a database stored in Azure. I'm facing a weird issue which happens randomly, and usually at the first start of the application.

My data model :

@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;
    }

My Repository :

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

When I call this method, it throws this (usually at first starts) :

"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;"

And sometimes it works fine. I don't understand because I don't have any integer in my query. Also for my tests I always use the same query so the userid and code work.

Do someone has a clue of what is happening ? It's driving me crazy :(

Thanks !

kmalki
  • 15
  • 4
  • I'm confused. How does this query work at all? You're filtering for userid and code, neither of which I see in your table. – Mark Brown May 23 '20 at 16:48
  • Userid and code are in ProductUserKey puk, that’s why I specify Puk_* in the name method. Spring Cassandra will convert it to CQL but I don’t understand why it talks about integer size, and why it works almost all the time but get sometimes this error. – kmalki May 23 '20 at 17:26
  • ah got it. strange error though. Have you tried another driver to see if this is isolated to the driver itself? – Mark Brown May 23 '20 at 18:11
  • btw, I should point out. We don't officially support this driver. See the list here, https://learn.microsoft.com/en-us/azure/cosmos-db/cassandra-support – Mark Brown May 23 '20 at 18:16
  • 1
    Oh nice thank you I didn't now that. I was using spring-boot-starter-data-cassandra. Will try with one in the link. – kmalki May 23 '20 at 18:28
  • you bet. Will make this answer. Please mark as answer if you could so people can find it. Thanks! – Mark Brown May 23 '20 at 21:28

1 Answers1

0

This driver is not officially supported for Cosmos DB's Cassandra API. See the full list of supported drivers here, Apache Cassandra features supported by Azure Cosmos DB Cassandra API.

Thanks.

Mark Brown
  • 8,113
  • 2
  • 17
  • 21