不同记录的HQL查询

时间:2013-07-17 16:04:09

标签: java hql

请在运行我的应用程序时得到此错误....任何帮助请。

    java.lang.IllegalArgumentException: node to traverse cannot be null!
        org.hibernate.hql.internal.ast.util.NodeTraverser.traverseDepthFirst(NodeTraverser.java:63)
        org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:272)
        org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180)
        org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
        org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
        org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
        org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)


org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
        org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
        org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
        org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:285)
        sun.reflect.GeneratedMethodAccessor31.invoke(Unknown Source)

这是我的存储库类中的代码

@Query("distinct v from voucher v where v.voucherType.typeID = :typeID ")
       public List<Voucher> findDistinctByVoucherType(@Param("typeID") Long voucherTypeId);

1 个答案:

答案 0 :(得分:0)

查询没有问题。以上异常表明

distinct v from voucher v where v.voucherType.typeID = :typeID

没有返回任何结果