0

有我的代码。有人可以告诉我有什么问题吗?

for(String motorProposalId : proposalMap.keySet()) {
    MotorPolicy mp = policyMap.get(motorProposalId);
    String query = "SELECT  p From Payment Where p.referenceNo = :motorProposalId"+
        " AND commenmanceDate >= :startDate AND commenmanceDate <= :endDate";
    Query qu = em.createQuery(query);
    qu.setParameter("commenmanceDate", mp.getCommenmanceDate());
    qu.setParameter("motorProposalId", motorProposalId);
    qu.setParameter("startDate", motorDailyCriteria.getStartDate());
    qu.setParameter("endDate", motorDailyCriteria.getEndDate());
4

1 回答 1

2

查询在语法上不正确,因为查询字符串中没有命名参数commenmanceDate。如果commenmanceDate应该命名参数,那么它必须以':'为前缀。

此外,查询可能存在一些语义问题,因为包含在日期比较中的所有值在执行查询之前都是已知的。

于 2013-05-31T07:02:53.380 回答