谁能告诉我为什么下面的代码在最后一行导致错误,命令“执行”和错误消息:
Query 类型中的方法 execute(Object, Object, Object) 不适用于参数(Long、Long、Date、Date)
Query q = pm.newQuery(Appointment.class,"AdminID == AID"+
" && EmployeeID == CEID"+
" && Time > STime"+
" && Time < ETime");
q.declareImports("import java.util.Date");
q.declareParameters("Long AID, Long CEID, Date STime, Date ETime");
q.setOrdering("Time");
Appointments = (List<Appointment>) q.execute(AdminID, CurrentEmployeeID, Time1, Time2);
据我所知(由错误消息暗示,执行函数最多只能进行 3 次争论,如果是这种情况,谁能建议如何实现我想要做的事情?我尝试了以下代码,但每次运行时都会出现解析错误!
Query q = pm.newQuery(Appointment.class,"AdminID == "+AdminID+
" && EmployeeID == "+CurrentEmployeeID+
" && Time > "+Time1+
" && Time < "+Time2);
q.declareImports("import java.util.Date");
q.setOrdering("Time");
Appointments = (List<Appointment>) q.execute();
我得到的解析错误是:
org.datanucleus.store.query.QueryCompilerSyntaxException:无法解析表达式的一部分:BST 2012 年 8 月 13 日 11:44:55 && 时间 < Mon Aug 13 11:45:05 BST 2012