java - 如何修复 SQLGrammar 异常?
问题描述
我一直在尝试查询从当前日期到过去五天的结果集,但我得到了这个异常:
Exception Caught in UsrpScheduleServiceImpl.doSchedule org.springframework.orm.jpa.JpaSystemException:
org.hibernate.exception.SQLGrammarException: could not extract ResultSet; nested exception is javax.persistence.PersistenceException:
org.hibernate.exception.SQLGrammarException: could not extract ResultSet
这是代码:
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
Calendar now = Calendar.getInstance();
now.add(Calendar.DATE, -5);
java.util.Date fromDate = new java.util.Date(now.getTime().getTime());
Set<String> usrpRequestSet = new HashSet<String> ();
List<UsrpRequest> usrpRequest = usrpRequestDao.findOrdersByRequestStatus(fromDate);
这是被调用的函数:
public List<UsrpResponse> findRecordsByCreatedDate(java.util.Date fromDate) {
LOGGER.debug("find Records By Created Date check "+fromDate);
java.sql.Date fromDate1 = new java.sql.Date(fromDate.getTime());
LOGGER.debug("find Records By Created Date check in Sql format "+ fromDate1);
List<UsrpResponse> resultList = find(FIND_RECORDS_BY_CREATED_DATE_SQL,fromDate1);
return resultList;
}
查询是:
private static final String FIND_RECORDS_BY_CREATED_DATE_SQL = "SELECT c FROM UsrpResponse c WHERE c.createdDate >= ?1 and c.errorText = 'Partial Order Created.' ORDER BY c.createdDate DESC";
有人对如何解决此错误有任何想法吗?
解决方案
推荐阅读
- maven - 总是将工件ID附加到组ID?
- consul - 请求 Consul 指标需要哪些 ACL 规则?
- elasticsearch - 我应该如何配置弹性搜索映射以获得 MySQL“喜欢”的行为?
- elasticsearch - Elastics 搜索查询过滤掉列表中值为 A 但不是 B 的结果
- php - 为PHP转换数组中的日期时间
- sql-server - ODBC 字符串连接到特定表
- scala - 基于类型长度的无形 HList 填充
- java - Kotlin - 如何从注释处理器获取 KClass<*> 注释参数
- python - 停止侦听 Thread 上的输入
- angular - 如何用 observable 重构函数