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