我在DB2表中有一个DB2 DATE类型字段.我想通过日期过滤器选择数据.例如:
SELECT *
FROM table
WHERE registrationdate > '2002-10-01';
Run Code Online (Sandbox Code Playgroud)
从上面的查询,我得到注册日期从'1943-10-01'开始的记录,但这是不正确的.
这些也不起作用:
registrationdate > date('2002-10-01')
date(registrationdate) > date('2002-10-01')
date(registrationdate) > '2002-10-01'
Run Code Online (Sandbox Code Playgroud)
我如何比较日期?
我有以下代码:
public class ValueDAO implements BusinessObject<Long> {
private Long id;
private String code;
private ClassDAO classDAO ;
....
}
public List<String> getCodesByCodeClass(Long classId) {
String select = "select distinct val.code from ValueDAO val left " +
"join fetch val.classDAO ";
String where = "where val.classDAO.id = ? order by val.code";
return getHibernateTemplate().find(select + where, classId);
}
Run Code Online (Sandbox Code Playgroud)
它引发了一个例外:
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list
Run Code Online (Sandbox Code Playgroud)
结果我想得到的只是代码.