Datanucleusを使用してOracleデータベースにアクセスしようとすると、奇妙な問題が発生します。要するに、何が起こるかはこれです:
- アプリケーションを実行します。datanucleusが初期化されると、テーブルが見つからないと文句を言います(テーブルはそこにありますが)。
アプリケーションを停止し、テーブルを削除し、追加します
datanucleus.autoCreateSchema = true
... persistence.xmlのプロパティ、およびすべてが機能します-テーブルが作成されてから、selectが機能します。
アプリケーションを再度停止してから、上記のパラメータを無効にして起動しようとします。
- そもそもテーブルを作成したのはDatanucleusでしたが、エラーが戻ってきて、テーブルが見つからないと文句を言います。
- また、同じセットアップがpostgresqlデータベースで問題なく機能することにも注意してください。
誰か助けてもらえますか?
私のセットアップに関するいくつかの詳細:
- Oracleシンドライバを使用しています。
私のエンティティクラスは次のように注釈が付けられています:
@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)