带有类型化条件查询的 XML 映射
我正在使用带有 xml 映射的 hibernate 我试图运行一些简单的代码,但没有取得太大成功。我确信映射和类是正确的,因为我能够使用 JPQL 执行其他查询。
这是我的代码片段:
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<Report> myquery = qb.createQuery(Report.class);
Root<Report> report = myquery.from(Report.class);
List<Report> result = em.createQuery(myquery).getResultList();
这是堆栈:
Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: null near line 1, column 29 [select generatedAlias0 from null as generatedAlias0]
...
...
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: null near line 1, column 29 [select generatedAlias0 from null as generatedAlias0]
...
...
有什么建议吗? 谢谢!
I'm using hibernate with xml mapping I'm trying to run some simple code without much success. I am confident that mapping and classes are correct as I am able to perform other queries using JPQL.
This is a snippet of my code:
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<Report> myquery = qb.createQuery(Report.class);
Root<Report> report = myquery.from(Report.class);
List<Report> result = em.createQuery(myquery).getResultList();
And this is the Stack:
Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: null near line 1, column 29 [select generatedAlias0 from null as generatedAlias0]
...
...
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: null near line 1, column 29 [select generatedAlias0 from null as generatedAlias0]
...
...
Any suggestion?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能会有所帮助:使用 XML 映射时与 CriteriaQuery (JPA) 相关的错误修复
您的问题可能是实际上与持久类和/或根类中缺少属性定义有关。祝你好运!
This might help: Bug fix related to CriteriaQuery (JPA) when using XML mappings
Your problem may actually be related to missing attribute definitions in your persistent and/or root classes. Good luck!