datanucleus + jpa + oracle.表不存在的奇怪错误 [英] datanucleus + jpa + oracle. Strange error with tables not existing
问题描述
当我尝试使用Datanucleus访问Oracle数据库时,我遇到一个奇怪的问题. 简而言之,这是什么:
I have a strange issue when I try to use Datanucleus to access an Oracle database. In short, what happens is this :
- 我运行我的应用程序;当数据核初始化时,它抱怨找不到表(尽管它们在那里).
-
我停止应用程序,删除表格,添加
- I run my application; when datanucleus initializes, it complains that it cannot find the tables (although they are in there).
I stop the application, I drop the tables, I add the
datanucleus.autoCreateSchema = true
... persistence.xml中的属性,一切正常-创建表,然后执行选择.
...property in persistence.xml, and everything works - tables are created and then the select works.
我再次停止应用程序,然后尝试在禁用上述参数的情况下启动它.
I stop the application again, and then I try to start it with the above parameter disabled.
有人可以帮忙吗?
有关我的设置的一些详细信息:
A few details about my setup :
- 我正在使用Oracle瘦驱动程序.
-
我的实体类的注释如下:
- I'm using Oracle thin driver.
My entity classes are annotated like this :
@Entity
@Table(name = "tablename1", schema = "schema2000")
请注意,如果我从注释中删除schema = ...,一切都可以正常进行
Please note that everything works OK if I remove the schema=... from annotation
错误消息是:
16:05:40,216 DEBUG [DataNucleus.Connection] - Setting autocommit=false to connection: com.mchange.v2.c3p0.impl.NewProxyConnection@1dff2e1b
16:05:40,216 DEBUG [DataNucleus.Connection] - Connection "com.mchange.v2.c3p0.impl.NewProxyConnection@1dff2e1b" opened with isolation level "read-committed"
16:05:40,904 DEBUG [DataNucleus.Datastore.Schema] - Check of existence of schema2000.tablename1 returned table type of null
16:05:40,905 DEBUG [DataNucleus.Datastore.Schema] - An error occurred while auto-creating schema elements - rolling back
16:05:41,109 DEBUG [DataNucleus.Connection] - Connection "com.mchange.v2.c3p0.impl.NewProxyConnection@1dff2e1b" non enlisted to a transaction is being committed.
16:05:41,110 DEBUG [DataNucleus.Connection] - Connection "com.mchange.v2.c3p0.impl.NewProxyConnection@1dff2e1b" closed
javax.persistence.PersistenceException: Required table missing : "schema2000.tablename1" in Catalog "" Schema "schema2000". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:274)
at org.datanucleus.api.jpa.JPAEntityManager.merge(JPAEntityManager.java:519)
推荐答案
建议您仔细查看标识符的区分大小写. DataNucleus用如下一行记录JDBC驱动程序所允许的内容
Suggest you look closer at case-sensitivity of your identifiers. DataNucleus logs what the JDBC driver allows with a line like
支持的标识符大小写:"MixedCase"大写"MixedCase-Sensitive"
Supported Identifier Cases : "MixedCase" UPPERCASE "MixedCase-Sensitive"
因此它可能需要大写字母或引用模式(所有RDBMS都是不同的,包括某些RDBMS,这取决于它们所运行的操作系统)
so possibly it requires the schema in UPPERCASE or maybe quoted (all RDBMS are different, and inclusive some differ depending on the operating system they're running on)
显然不建议在注释中嵌入特定于数据存储的信息.
Obviously embedding datastore-specific info in annotations is not recommended.
这篇关于datanucleus + jpa + oracle.表不存在的奇怪错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!