当我从hql编辑器运行查询时出现此异常的原因
org.hibernate.HibernateException: could not instantiate QueryTranslatorFactory: org.hibernate.hql.classic.ClassicQueryTransactionFactory at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:391) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:222) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859) at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:264) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100) at org.hibernate.cfg.SettingsFactory.createQueryTranslatorFactory(SettingsFactory.java:388) ... 7 more Caused by: java.lang.ClassNotFoundException: org.hibernate.hql.classic.ClassicQueryTransactionFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at org.netbeans.ProxyClassLoader.loadClass(ProxyClassLoader.java:262) ... 13 more
答案 0 :(得分:22)
从hibernate 3迁移到hibernate 4时我遇到了同样的异常,但当我试图改变
时<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
与
<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>
它对我有用。
我希望能帮助你。
答案 1 :(得分:3)
新APIS略有变化。 请用
替换属性值org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory.
注意:引入了名为“内部”层次结构的新包。
答案 2 :(得分:0)
经典查询翻译工厂的正确名称是org.hibernate.hql.classic.ClassicQueryTransactorFactory
,在属性中使用它而不是错误的(org.hibernate.hql.classic.ClassicQueryTransactionFactory
)。
答案 3 :(得分:0)
正确的名称是
org.hibernate.hql.classic.ClassicQueryTranslactorFactory
请注意,上一条评论中缺少'l'。