java - 未找到使用 OpenJPA 和 RuntimeUnenhancedClasses 的类型的元数据

标签 java jpa entity openjpa

我正在使用 JPA (OpenJPA)。我的 persistence.xml 中有以下条目:

<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>

我还在 persistence.xml 中列出了 Serviceoffering 类。 当我尝试运行与 JPA 相关的代码时出现以下异常。可能是什么问题?

No metadata was found for type "class com.XYZ.cloud.bss.client.db.data.Serviceoffering".  Ensure that the class is enhanced (if necessary), that the class has appropriate metadata, and that if you list your persistent classes, the class is included in your list.
C = null
<openjpa-1.2.1-SNAPSHOT-r422266:686069 fatal user error> org.apache.openjpa.persistence.ArgumentException: No metadata was found for type "class com.XYZ.cloud.bss.client.db.data.Serviceoffering".  Ensure that the class is enhanced (if necessary), that the class has appropriate metadata, and that if you list your persistent classes, the class is included in your list.
    at org.apache.openjpa.meta.MetaDataRepository.getImplementorMetaDatas(MetaDataRepository.java:1108)
    at org.apache.openjpa.kernel.QueryImpl.createExecutor(QueryImpl.java:720)
    at org.apache.openjpa.kernel.QueryImpl.compileForDataStore(QueryImpl.java:692)
    at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:674)
    at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
    at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
    at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
    at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:293)
    at c

最佳答案

添加<class>com.XYZ.cloud.bss.client.db.data.Serviceoffering</class>添加到您的 persistence.xml 文件,并确保在执行查询之前类 Serviceoffering 已由 JVM 加载。

现在我要强烈建议您不要设置<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/> .是的,有一些支持,但它会让你很头疼。浏览 blog post我很久以前就写过关于增强过程的文章......这应该会让你开始。

关于java - 未找到使用 OpenJPA 和 RuntimeUnenhancedClasses 的类型的元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4013662/

相关文章:

xml - fo : entity referenced but not declared

java - 在目录中查找具有两个关键字之一的文件

Hibernate/JPA - 如何在不触发延迟加载的情况下获取@ManyToOne 字段的 id

python - 是否有一种有效的方法来重写 appengine 实体中的 get() 和 put() 方法以使其使用内存缓存?

hibernate - TransientObjectException - 对象引用未保存的 transient 实例 - 在刷新之前保存 transient 实例

java - Hibernate HQL "Path expected for join!"@ManyToOne 关系

mysql - 通过 Entity Framework 中的多个表获取值?

java - 检测输入重定向文件

java - CountDownTimer 取消()不工作

java - 如何使用 spymemcached 动态添加 memcached 节点