在Web应用程序OpenJDK11-Project中找不到NamedQuery

时间:2019-11-27 16:58:22

标签: jpa gradle openjdk-11

我想将Web应用程序(渐变项目)从Java 8迁移到OpenJDK 11。

该构建没有错误运行,但是当我启动该应用程序时,我遇到了以下错误:

java.lang.IllegalArgumentException: NamedQuery of name: Versions.findAll not found.
org.eclipse.persistence.internal.jpa.QueryImpl.getDatabaseQueryInternal(QueryImpl.java:362)
  org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1236)
   org.eclipse.persistence.internal.jpa.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:1257)
de.atune.glue.business.SessionService.getVersions(SessionService.java:22)
de.atune.glue.presentation.GlueSessionPM.init(GlueSessionPM.java:152)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

我的实体类:

@Entity
@NamedQueries({
@NamedQuery(name = "Versions.findAll", query = "SELECT v FROM Versions v")})
public class Versions implements Serializable {

private static final long serialVersionUID = -9145662180316404671L;

public static final String FIND_ALL = "Versions.findAll";

代码服务等级:

Versions versions = new Versions();
EntityManagerFactory factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();
versions = em.createNamedQuery(Versions.FIND_ALL, Versions.class).getResultList().get(0);
em.close();

build.gradle中的条目:

compile group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.jpa', version: '2.7.1'
compile group: 'org.eclipse.persistence', name: 'org.eclipse.persistence.moxy', version: '2.7.1'

0 个答案:

没有答案