我正在处理以下情况:
实体类:
@NamedQuery(
name = "Table.getSum",
query = "SELECT SUM(s.price) FROM Table s WHERE
(s.openingDate >= :openingDate AND s.closingDate <= :closingDate)"
)
EJB:
Calendar openingDate = new GregorianCalendar(year, 1, 1, 0, 0, 0);
Calendar closingDate = new GregorianCalendar(year, 12, 31, 23, 59, 59);
BigDecimal salePriceSum = em.createNamedQuery("Table.getSum", BigDecimal.class)
.setParameter("openingDate", openingDate)
.setParameter("closingDate", closingDate)
.getSingleResult();
本机SQL查询:
SELECT SUM(price) FROM Table WHERE openingDate >= 'YYYY-01-01T00:00:00' AND closingDate <= 'YYYY-12-31T23:59:59'
但两笔款项数额相当可观。这让我疯狂。怎么可能?
我正在使用hibernate 4.3.7 with wildfly 8.2.0和当前的mariadb on centos 7。
非常感谢您的任何建议。
答案 0 :(得分:0)