我正在尝试在liferay门户中编写自定义sql查询。以下是查询。
SELECT sum(score) as total FROM ratingsentry r WHERE r.modifiedDate>?;
util函数如下。
String sql = CustomSQLUtil.get("GET_TODAY_COUNT");
SQLQuery q = dbSession.createSQLQuery(sql);
QueryPos qPos = QueryPos.getInstance(q);
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1);
java.sql.Timestamp timestamp = CalendarUtil.getTimestamp(cal.getTime());
qPos.add(timestamp);
q.addScalar("total", Type.LONG );
Object count=q.uniqueResult();
从上面的util方法中,te count总是返回为0。
非常感谢任何帮助。
答案 0 :(得分:0)
请改为尝试:
Timestamp timestamp = new Timestamp(cal.getTimeInMillis());