Pyae Phyo Aung
Pyae Phyo Aung

Reputation: 161

JPQL didn't get parameter

There is my code. Can someone tell me what is wrong?

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());

Upvotes: 0

Views: 73

Answers (1)

Mikko Maunu
Mikko Maunu

Reputation: 42104

Query is syntactically incorrect because there is no named parameter commenmanceDate in query string. If commenmanceDate should be named parameter, then it must be prefixed with ':'.

Also then query likely have some semantic problems, because all values included to date comparisons are already known before executing query.

Upvotes: 2

Related Questions