小编yon*_*s88的帖子

比较DB2日期

我在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)

我如何比较日期?

db2

11
推荐指数
2
解决办法
8万
查看次数

加入fetch:"查询指定的连接提取,但获取的关联的所有者在选择列表中不存在"

我有以下代码:

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)

结果我想得到的只是代码.

java hibernate hql

6
推荐指数
1
解决办法
3万
查看次数

标签 统计

db2 ×1

hibernate ×1

hql ×1

java ×1