【发布时间】:2013-03-24 20:43:53
【问题描述】:
我成功发送了日期值。我检查了“作用域变量”。
这是我的 bean 中的一个函数,它调用了 helper 中的一个函数:
public DataModel getFt() {
ftDataModel = new ListDataModel((List) fthelper.getByBeginDate(beginDate));
return ftDataModel;
}
这是将beginDate 发送到Hibernate 的函数。但是在这里它返回null。为什么?
public FinancialTransactions getByBeginDate(String beginDate){
List<FinancialTransactions> FtList = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("from FinancialTransactions where DATE='" + beginDate + "'");
FtList = (List<FinancialTransactions>) q.list();
} catch (Exception e) {
e.printStackTrace();
}
return FtList.get(0);
}
【问题讨论】:
-
因为查询没有找到任何东西?
-
可能查询没有返回数据,尝试单独运行查询,查看返回多少行
-
是否打印了异常堆栈跟踪?
-
旁注:你真的应该清理你的输入。这是开放的注射。 See here.
-
@Brian 是的,这个
where DATE='" + beginDate + "'"很好吃:-D