2

I have written a namedQuery in my Entity class as @NamedQuery(name="Place.findByPlaceCode", query="select p from Place p where p.Code = :placeCode")

I execute the named query with the following :

List<Country> result = getEntityManager()
            .createNamedQuery("Place.findByPlaceCode")
            .setParameter("placeCode", placeCode)
            .getResultList();       
return processResult(result);

However, it is returning nothing .

If I write an SQL query in the database it runs fine but this namedQuery is not working. I tried setting the parameter manually to the value "Beach" and also tried "Beach " to check if it was the whitespaces causing the issue but it did'nt make any difference. How should I check the values returned by this query ?

MindBrain
  • 7,398
  • 11
  • 54
  • 74
  • Are you sure you are connecting to the same database/schema etc? Set EclipseLink logging to finest to see where it is connecting and the SQL it is generating using . You might also try turning parameter binding off for this query using query.setHint(QueryHints.BIND_PARAMETERS, HintValues.FALSE) to see if it is a driver/database string handling issue. – Chris Jul 26 '12 at 13:59

0 Answers0