title: magic npe in hibernate
body: <p>When I write</p>
  
  <pre><code>Session session = sessionFactory.getCurrentSession();
  List&lt;Candidate&gt; candidates = (List&lt;Candidate&gt;) session.createQuery(
          "select Candidate from Candidate as candidate  left outer join"
          + " candidate.skills as skill    where skill.id =" + 1).list();
  </code></pre>
  
  <p>I have npe at second line</p>
  
  <p>if I write</p>
  
  <pre><code>Session session = sessionFactory.getCurrentSession();
  List&lt;Candidate&gt; candidates = (List&lt;Candidate&gt;) session.createSQLQuery(
          "select candidate.* from candidate inner join candidate_skill"
          + " on candidate.id = candidate_skill.candidate_id"
          + " inner join skill on candidate_skill.skill_id = skill.id"
          + " where skill.id = 1").list();
  </code></pre>
  
  <p>I have good result</p>
  
  <p>why I have NPE in first example?</p>
  
  <blockquote>
    <p>SEVERE: Servlet.service() for servlet [appServlet] in context with path [/ui] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
        java.lang.NullPointerException
            at org.hibernate.dialect.function.SQLFunctionRegistry.findSQLFunction(SQLFunctionRegistry.java:41)</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/8XGjQ.png" alt="enter image description here"></p>