我的回答可能为时已晚,但出于参考目的,您可以试试这个:
XpcSecurity credentials = ud.getCredentials();
Xpc xpc = new Xpc(credentials);
xpc.start("training.getEmployees","select");
StringBuffer whereClause = new StringBuffer();
//In xpc this is the equivalent of "id between idLower and idUpper"
whereClause.append("<whereClause>\n");
whereClause.append(" <expr op='and' returnType='char'>\n");
whereClause.append(" <expr op='ge' returnType='char'>\n");
whereClause.append(" <operand>id</operand>\n");
whereClause.append(" <operand type='literal'>"+idLower+"</operand>\n");
whereClause.append(" </expr>\n");
whereClause.append(" <expr op='le' returnType='char'>\n");
whereClause.append(" <operand>id</operand>\n");
whereClause.append(" <operand type='literal'>"+idUpper+"</operand>\n");
whereClause.append(" </expr>\n"); whereClause.append(" </expr>\n");
whereClause.append("</whereClause>\n");
xpc.input(whereClause);
XData result = xpc.run();
对于表连接:
我看到你已经在使用 xpc 类了。在这个类中把它放在初始化函数中:
mapEntity("training.getEmployees");
addLevel("employees");
mapTable("employee", "employee", null);
mapColumn("employee_id", "employeeId", "employeeId", true, false);
mapColumn("first_name", "firstName", "firstName", false, false);
mapColumn("last_name", "lastName", "lastName", false, false);
mapTable("time_track", "timeTrack", null);
mapColumn("time_track_id", "timeTrackId", "timeTrackId", true, false);
mapColumn("time_in", "timeIn", "timeIn", false, false);
mapColumn("time_out", "timeOut", "timeOut", false, false);
mapColumn("employee_id", "employeeId", "employeeId", false, false);
addJoin("employee", "employeeId", "timeTrack", "employeeId");
这相当于 Select * from employee a internal join time_track b on a.employee_id = b.employee_id
您现在可以在选择时应用条件