使用OpenJPA和RuntimeUnenhancedClasses找不到类型的元数据

时间:2010-10-25 10:27:47

标签: java jpa entity openjpa

我正在使用JPA(OpenJPA)。我在persistence.xml

中有以下条目
<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>

我还在Serviceoffering中列出了persistence.xml类。 当我尝试运行与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

1 个答案:

答案 0 :(得分:4)

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

现在我要强烈推荐您没有设置<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>。是的,有一些支持,但它会给你带来很多麻烦。看一下blog post,我写了很长一段时间来讨论增强过程....这应该让你滚动。