[英]java.lang.NoSuchMethodError: javax.persistence.EntityManager.createQuery when using jpa / hibernate
We are running an app in jboss 5.1.0.GA, and it's complaining when we try to use the EntityManager.createQuery method. 我们正在jboss 5.1.0.GA中运行一个应用程序,当我们尝试使用EntityManager.createQuery方法时会抱怨。 An implementation of this method is available in org.hibernate.ejb.AbstractEntityManagerImpl (and probably a few other places included in our code). org.hibernate.ejb.AbstractEntityManagerImpl(以及我们的代码中可能包含的其他一些地方)中提供了此方法的实现。
I suspect that it's picking up an older version of hibernate from the jboss libs directory. 我怀疑它是从jboss libs目录中获取较旧版本的hibernate。
How can I fix this? 我怎样才能解决这个问题?
Code looks something like this: 代码看起来像这样:
List<UserGroup> userGroups= DbHelper.getNonNullEntityManager().createQuery("SELECT ug FROM UserGroup ug", UserGroup.class).getResultList();
Exception is this: 例外是:
java.lang.NoSuchMethodError: javax.persistence.EntityManager.createQuery(Ljava/lang/String;Ljava/lang/Class;)Ljavax/persistence/TypedQuery;
Ok I fixed it by removing the Class parameter from the method. 好的,我通过从方法中删除Class参数来修复它。 Seems that was added in a later method of hibernate: 似乎是在以后的休眠方法中添加的:
List<UserGroup> userGroups= DbHelper.getNonNullEntityManager().createQuery("SELECT ug FROM UserGroup ug").getResultList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.