eclipse下openJPA问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eclipse下openJPA问题相关的知识,希望对你有一定的参考价值。
运行时提示A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.错误。
完整错误信息如下:
15 Dali-Demo INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.1
Exception in thread "main" <openjpa-1.2.1-r752877:753278 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:74)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:784)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:561)
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1265)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:863)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:854)
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at com.te.AnimalIMP.persistAnimal(AnimalIMP.java:13)
at com.te.MainFrame.main(MainFrame.java:15)
不明白的别瞎JB说
使用带有 RuntimeUnenhancedClasses 的 OpenJPA 找不到类型的元数据
【中文标题】使用带有 RuntimeUnenhancedClasses 的 OpenJPA 找不到类型的元数据【英文标题】:No metadata found for type using OpenJPA with RuntimeUnenhancedClasses 【发布时间】:2011-04-30 03:28:04 【问题描述】:我正在使用 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
【问题讨论】:
【参考方案1】:将<class>com.XYZ.cloud.bss.client.db.data.Serviceoffering</class>
添加到您的persistence.xml 文件中,并确保在执行查询之前JVM 已加载Serviceoffering 类。
现在我要强烈建议不要设置<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
。是的,有一些支持,但这会让你很头疼。看看blog post 我很久以前写过关于增强过程的文章......这应该会让你滚动。
【讨论】:
以上是关于eclipse下openJPA问题的主要内容,如果未能解决你的问题,请参考以下文章
如何确定 OpenJPA 中 FetchBatchSize 的数量?