当我写
Session session = sessionFactory.getCurrentSession();
List<Candidate> candidates = (List<Candidate>) session.createQuery(
"select Candidate from Candidate as candidate left outer join"
+ " candidate.skills as skill where skill.id =" + 1).list();
我在第二行有 npe
如果我写
Session session = sessionFactory.getCurrentSession();
List<Candidate> candidates = (List<Candidate>) 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();
我有好结果
为什么我在第一个例子中有 NPE?
严重:servlet [appServlet] 在路径 [/ui] 的上下文中的 Servlet.service() 引发异常 [请求处理失败;嵌套异常是 java.lang.NullPointerException],根本原因 java.lang.NullPointerException 在 org.hibernate.dialect.function.SQLFunctionRegistry.findSQLFunction(SQLFunctionRegistry.java:41)