4

我正在使用 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
4

1 回答 1

4

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

现在我强烈建议你不要设置<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>. 是的,有一些支持,但这会让你很头疼。看看我很久以前写的一篇关于增强过程的博客文章......这应该会让你滚动。

于 2010-10-25T18:44:47.187 回答