我的错误在哪里?
SELECT m FROM Message m WHERE m.tabId = :idTab AND BETWEEN :startDate AND :endDate ORDER BY m.id DESC
我有这个错误:
Exception Description: Syntax error parsing the query ... , line 1, column 63: unexpected token [BETWEEN].
Internal Exception: NoViableAltException(11@[634:7: (n= NOT )?])
在我的 Java 代码中,我有:
// Exception line
Query query = em.createQuery(queryBuilder.toString());
////
query.setParameter("idTab", idTablet);
if (limit > 0) {
query.setMaxResults(limit);
}
if (dateFrom != null) {
query.setParameter("startDate", dateFrom, TemporalType.DATE);
if (dateTo == null) {
dateTo = new Date();
}
query.setParameter("endDate", dateTo, TemporalType.DATE);
}
messages = (List<MessageEntity>) query.getResultList();