I'm pretty stump on this issue. Please help.

sql = "SELECT * FROM scheduler_assignment a WHERE a.start < #bind($end)";
SQLTemplate query = new SQLTemplate(Assignment.class, sql);
query.setFetchingDataRows(true);
Map<String, Object> params = new HashMap<String, Object>();
params.put("end", end);
query.setParameters(params);
ObjectContext context = BaseContext.getThreadObjectContext();
List<DataRow> rows = context.performQuery(query);

end is a Date object. When I change end to its equivalent String, the query works correctly. Does anyone know why passing in the Date object would not work for the bind directive? Thank you!

有帮助吗?

解决方案

First possibility: 'scheduler_assignment.start' column is not a date in the database. It could be a VARCHAR or something.

If this is not the case, you may have to pass the type of the argument in the #bind directive for Cayenne to use the right driver method. E.g.:

#bind($end 'TIMESTAMP')
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top