org.hibernate.hql.ast.QuerySyntaxException with Hibernate

后端 未结 7 2008
死守一世寂寞
死守一世寂寞 2021-02-20 01:34

I\'m new to using Hibernate with Java. I\'m getting the following exception. The stuff that I found online regarding this error didn\'t seem to help. Any ideas? The Exception:<

7条回答
  •  时光说笑
    2021-02-20 01:46

    It happened to me until I started to use the full class name, e.g.:

    String queryString = "select count(c) from com.my.classes.package.ApplPerfStats c";
    

    But I don't like this approach, because it's refactoring-unfirendly. A more tractable one would be:

    String queryString = "select count(c) from " + ApplPerfStats.class.getName() +  c";
    

    javashlook's solution seems to be a shortcut for that - but it adds more XML configuration, which I try to avoid. If only there was an annotation-based way to specify that...

提交回复
热议问题