这个问题可能很容易。我正在尝试读取IBM Maximo应用程序的字段,并在方法getList()中使用此值。我想要使用的值尚未保存在数据库中。
这是一些伪代码:
@Override
public MboSetRemote getList() throws MXException, RemoteException {
MboSetRemote result = super.getList();
//Here is where i dont know how to do it
Date field = getFieldValue(FieldName)
//Here is where i want to use the value
String string = "....field..."
result.setWhere(string);
return result;
}
谢谢大家, 此致
答案 0 :(得分:0)
我认为在where子句中使用字段值的最简单和最安全的方法是使用绑定变量,如下所示:
@Override
public MboSetRemote getList() throws MXException, RemoteException {
MboSetRemote result = super.getList();
//Here is where i want to use the value
String string = "....:fieldName...";
result.setWhere(string);
return result;
}
请注意:fieldName
中string
正面的冒号。当Maximo看到这个时,它会在当前记录/ Mbo上查找(不区分大小写)名为fieldName
的属性,并将:fieldName
替换为属性中的值 - 用引号或其他方式包装,适用于属性的类型(ALN,UPPER,DATE等)。
这种方法比你提出的方法更好,因为它将采用Maximo的框架来防止SQL注入攻击等。
那就是说,获得字段值的方法如下:
Date fieldValue = getMboValue("FieldName").getDate();
此外,我强烈建议您自己获取Maximo JavaDocs的副本。你可以这样做here。