Is there any other way to bind data type through IN clause using PreparedStatement(datastax)?
Query looks like that:
SELECT * FROM table WHERE day IN(?)
Day is a date type. There will be N elements (up to user).
It is impossible to bind List of days due to exception which say
Codec not found for requested operation: [date <-> java.util.ArrayList]
According to post https://stackoverflow.com/a/189399/9461706 the only possible way I can see now is the first one - execute for each value but I would not like to do that. It may extend response time to unacceptable value.
Here is how I execute query:
ResultSet rS = dataSource.executePreperedStatement(query, day);
private ConcurrentHashMap<String, PreparedStatement> queryToPrepStmt;
public ResultSet executePreperedStatement(String query, Object... values){
PreparedStatement pS = null;
if(queryToPrepStmt.containsKey(query)){
pS = queryToPrepStmt.get(query);
} else{
pS = session.prepare(query);
queryToPrepStmt.put(query, pS);
}
if(pS!=null){
BoundStatement boundStatement = pS.bind(values);
return session.execute(boundStatement);
}
return null;
}