0

我有一些值存储在 mysal 表中。基本上,它们是一些保持值上升或下降的字符串。

我想获取表中的数据并比较它们是否等于向上或向下

这是代码

String up = "up";
String down = "down";

@SuppressWarnings("deprecation")
Query query = currentSession.createSQLQuery(
           "select * from trades where trade_session_status=:trade_session_status AND trade_profit_worker_status=:trade_profit_worker_status");
query.setParameter("trade_session_status", "DONE");
query.setParameter("trade_profit_worker_status", "UNDONE");
@SuppressWarnings("rawtypes")
List < Object[] > result = query.list();

for (Object[] objects: result) {
Integer id = (Integer) objects[0];
String trade_prediction = (String) objects[10];
String trade_result = (String) objects[11];


if(trade_prediction.equals(up) && trade_result.equals(up)) {
}

代码有效,我可以测试字符串是否相等,但在某处,我在这一行出现错误

if(trade_prediction.equals(up) && trade_result.equals(up)) {

但该程序仍然有效。

我收到这个错误

严重:计划任务中发生意外错误。com.boilerplate.components.Scheduler.profit_cron 处的 java.lang.NullPointerException(Scheduler.java:396)

这是第 396 行

if(trade_prediction.equals(up) && trade_result.equals(up)) { }

什么可能导致错误?

4

0 回答 0