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");
我明白了:
java.lang.ClassCastException: org.hibernate.internal.SQLQueryImpl cannot be cast to java.util.List
查询正确。如何解决?
最佳答案
您在查询结束时忘记了 .list()
。
应该是这样的
................skill.id where skill.id = 1").list();
引用hibernate documentation了解更多信息。
关于java.lang.ClassCastException : org. hibernate.internal.SQLQueryImpl 无法转换为 java.util.List 如何修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18148482/