title: problem with named parameter query in hibernate
body: <p>In order to prevent SQL Injection i am trying to convert dynamic queries to named parameter query.. however, when i am using this code - </p>
  
  <pre><code>String query = "from Ad a left join fetch a.adQueries left join fetch a.aduser u left join fetch u.profile where a.id =:identifier";
          Query q = s.createQuery(query);
          q.setParameter("identifier", id);
  </code></pre>
  
  <p><b>No data is returned from DB even though the data is there and the same query in dynamic form return data</b></p>
  
  <p>and when i use this code - </p>
  
  <pre><code>String query = "from Ad a left join fetch a.adQueries left join fetch a.aduser u left join fetch u.profile where a.id =:identifier";
          Query q = s.createQuery(query);
          q.setLong("identifier", id);
  </code></pre>
  
  <p>it throws a Null pointer exception..</p>
  
  <p>Please let me know where i am going wrong</p>
  
  <p>Thanks</p>