hibenate sql报Not all named parameters have been set: [:timestamp] 错

我使用的是postgresql
StringBuffer sb = new StringBuffer();

sb.append("SELECT a.name as name,.....FROM 表名 a,表名 b WHERE 1 = 1 AND a.card_no = b.card_no
AND a.out_time <= now()::TIMESTAMP AND a.out_time >= CURRENT_DATE::TIMESTAMP AND b.card_type = 0")

this.getSession().createSQLQuery(query).lsit();
报org.hibernate.QueryException: Not all named parameters have been set: [:timestamp]
以上sql查询语句在postgresql查询无问题,但在hibernate就报错,估计是hibernate底层的原因。
使用 cast as解决
SELECT
a.name as name,
        .......
FROM
表名 a,
表名b
WHERE
1 = 1
AND a.card_no = b.card_no
AND a.out_time <= cast(now() as TIMESTAMP)
AND a.out_time >= cast (CURRENT_DATE as TIMESTAMP)
AND b.card_type = 0

你可能感兴趣的:(hibenate sql报Not all named parameters have been set: [:timestamp] 错)