I was trying to create an Accessor interface in a Java application communicating with cassandra. The interface looked something like this:
import java.util.Date; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import com.custom.package.Order; @Accessor public interface OrderAccessor { @Query("SELECT * FROM orders WHERE checkout_date = ?") Result<Order> findAllOrdersByCheckoutDate(Date checkoutDate); }
When I was trying to run the query, I got the following exception:
Codec not found for requested operation: [date <-> java.util.Date]
It turned out that for the Cassandra date
type, the correct Java type to use is com.datastax.driver.core.LocalDate
Changing my java.util.Date
to this resolved the issue.