Ankit Bansal
Ankit Bansal

Reputation: 2348

Cassandra Error : expected 8 or 0 byte long for date

I am using spring data cassandra

My this code is working

@Query("SELECT count(*) as cnt FROM notifications where userid = ?0 and typeofnotification=?1  "
            + "and notificationId > minTimeuuid('2019-09-12') and category = ?3 allow filtering")

    public Integer findCountForCategoryForDate(int userId, String typeOfNotification, String category);

But when i am trying to give date as param, it is giving error

@Query("SELECT count(*) as cnt FROM notifications where userid = ?0 and typeofnotification=?1  "
            + "and notificationId > minTimeuuid(?2) and category = ?3 allow filtering")

public Integer findCountForCategoryForDate(int userId, String typeOfNotification,String date, String category);

What am i missing?

notificationId column is timeuuid in DB

Upvotes: 3

Views: 3681

Answers (2)

Manas Kumar Maharana
Manas Kumar Maharana

Reputation: 935

You can use SimpleDateFormatter then create date instance and assign that value to TimeStamp column. See mapping between Java type and CQL types.

Enjoy :)

Upvotes: 0

Alex Ott
Alex Ott

Reputation: 87069

the mintimeuuid function expects timestamp as parameter, but you pass a string. You need to pass variable with java.util.Date type instead. See the documentation for mapping between Java type and CQL types.

Upvotes: 4

Related Questions