2

How to convert the mongo db query into JPQL query I have tried the followings but its returning empty list.

Query query = manager.createQuery("SELECT p FROM Person p WHERE p.pid =:pid AND p.email =:email");
query.setParameter("pid", 1);
query.setParameter("email", "test@gmail.com");
List recs = query.getResultList();
Saisha
  • 21
  • 4
  • This look good. Would you try **SELECT p FROM Person p** only(without parameter) and verify result if that contains result – Swarit Agarwal Feb 18 '20 at 05:07
  • Yes, it contains the result – Saisha Feb 18 '20 at 06:31
  • Please try to use Ordinal Parameters it means SELECT p FROM Person p WHERE p.pid =?1 AND p.email =?2". query.setParameter("1, 1001); query.setParameter(2, "test@gmail.com"); – Swarit Agarwal Feb 18 '20 at 07:02
  • i have already tried the above suggestion – Saisha Feb 18 '20 at 07:04
  • How does the `Person` entity look like? Does it have an attribute `pid`, or is it the name of the database column? – kidney Feb 18 '20 at 07:08
  • In that case, Please update your question with possible ways you have tried, as well as response after **Select p from Person p**. I don't see any issue they way you defining query. Try to hardcode string in query and try once, If that does give you response. – Swarit Agarwal Feb 18 '20 at 07:09

0 Answers0