开发者

XML mapping with typed criteria queries

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开发者_Python百科.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!


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜