【问题标题】:XML mapping with typed criteria queries具有类型化条件查询的 XML 映射
【发布时间】:2011-08-12 13:52:34
【问题描述】:

我正在使用带有 xml 映射的 hibernate 我正在尝试运行一些简单的代码,但没有取得多大成功。我相信映射和类是正确的,因为我能够使用 JPQL 执行其他查询。

这是我的代码的 sn-p:

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]
...
...

有什么建议吗? 谢谢!

【问题讨论】:

    标签: java hibernate criteria-api typed


    【解决方案1】:

    这可能会有所帮助:Bug fix related to CriteriaQuery (JPA) when using XML mappings

    您的问题实际上可能与您的持久类和/或根类中缺少属性定义有关。祝你好运!

    【讨论】:

    • 你说得对,我想我需要一些运气!这似乎是库中的一个该死的错误。
    猜你喜欢
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 2014-08-13
    • 2018-12-21
    • 2017-05-07
    • 1970-01-01
    相关资源
    最近更新 更多