当我尝试使用Datanucleus访问Oracle数据库时,我遇到了一个奇怪的问题。 简而言之,会发生什么:
我停止了应用程序,我删除了表,我添加了
datanucleus.autoCreateSchema = true
... persistence.xml中的属性,一切正常 - 表创建然后选择有效。
我再次停止应用程序,然后尝试在禁用上述参数的情况下启动它。
有人可以帮忙吗?
有关我的设置的一些细节:
我的实体类注释如下:
@Entity
@Table(name = "tablename1", schema = "schema2000")
请注意,如果我从注释中删除schema = ...,一切正常
错误信息是:
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)
答案 0 :(得分:3)
建议您仔细查看标识符的区分大小写。 DataNucleus使用类似
的行记录JDBC驱动程序允许的内容支持的标识符案例:“MixedCase”UPPERCASE“MixedCase-Sensitive”
所以它可能需要UPPERCASE中的模式或者引用(所有RDBMS都不同,并且包含一些根据它们运行的操作系统而有所不同)
显然不建议在注释中嵌入特定于数据存储区的信息。