You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2006/08/18 19:12:11 UTC
svn commit: r432643 - in
/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb: ./ broker/
broker/sequence/
Author: arminw
Date: Fri Aug 18 10:12:11 2006
New Revision: 432643
URL: http://svn.apache.org/viewvc?rev=432643&view=rev
Log:
add reworked version of database identity column test
Added:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityHsqlTest.java
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMaxDBTest.java
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMySqlTest.java
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityTest.java
Removed:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
Modified:
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java
db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_meta_seq.xml
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java?rev=432643&r1=432642&r2=432643&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/AllTests.java Fri Aug 18 10:12:11 2006
@@ -4,14 +4,15 @@
import junit.framework.TestSuite;
import org.apache.ojb.broker.cache.LocalCacheTest;
import org.apache.ojb.broker.cache.ObjectCacheTest;
+import org.apache.ojb.broker.lob.LOBTest;
+import org.apache.ojb.broker.locking.CommonsLockTestCommittedReads;
+import org.apache.ojb.broker.locking.CommonsLockTestRepeatableReads;
+import org.apache.ojb.broker.locking.CommonsLockTestSerializable;
+import org.apache.ojb.broker.locking.CommonsLockTestUncommittedReads;
import org.apache.ojb.broker.locking.LockTestCommitedReads;
import org.apache.ojb.broker.locking.LockTestRepeatableReads;
import org.apache.ojb.broker.locking.LockTestSerializable;
import org.apache.ojb.broker.locking.LockTestUncommitedReads;
-import org.apache.ojb.broker.locking.CommonsLockTestSerializable;
-import org.apache.ojb.broker.locking.CommonsLockTestRepeatableReads;
-import org.apache.ojb.broker.locking.CommonsLockTestCommittedReads;
-import org.apache.ojb.broker.locking.CommonsLockTestUncommittedReads;
import org.apache.ojb.broker.metadata.CustomAttributesTest;
import org.apache.ojb.broker.metadata.MetadataMultithreadedTest;
import org.apache.ojb.broker.metadata.MetadataTest;
@@ -20,10 +21,11 @@
import org.apache.ojb.broker.metadata.RepositoryElementsTest;
import org.apache.ojb.broker.metadata.RepositoryPersistorTest;
import org.apache.ojb.broker.sequence.AutoIncrementTest;
-import org.apache.ojb.broker.sequence.NativeIdentifierTest;
+import org.apache.ojb.broker.sequence.DatabaseIdentityHsqlTest;
+import org.apache.ojb.broker.sequence.DatabaseIdentityMySqlTest;
import org.apache.ojb.broker.sequence.SMMultiThreadedTest;
import org.apache.ojb.broker.sequence.SequenceManagerTest;
-import org.apache.ojb.broker.lob.LOBTest;
+import org.apache.ojb.broker.sequence.DatabaseIdentityMaxDBTest;
/**
* the facade to all TestCases in this package.
@@ -93,7 +95,6 @@
suite.addTestSuite(MultipleTableExtentAwareQueryTest.class);
suite.addTestSuite(RepositoryElementsTest.class);
suite.addTestSuite(ConnectionFactoryTest.class);
- suite.addTestSuite(NativeIdentifierTest.class);
suite.addTestSuite(AnonymousFieldsTest.class);
suite.addTestSuite(AbstractExtentClassTest.class);
suite.addTestSuite(NestedFieldsTest.class);
@@ -127,6 +128,9 @@
suite.addTestSuite(LOBTest.class);
suite.addTestSuite(JdbcJavaObjectTest.class);
suite.addTestSuite(StoredProcedureMaxDBTest.class);
+ suite.addTestSuite(DatabaseIdentityHsqlTest.class);
+ suite.addTestSuite(DatabaseIdentityMySqlTest.class);
+ suite.addTestSuite(DatabaseIdentityMaxDBTest.class);
// BRJ: ensure shutdown of hsqldb
suite.addTestSuite(HsqldbShutdown.class);
Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityHsqlTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityHsqlTest.java?rev=432643&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityHsqlTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityHsqlTest.java Fri Aug 18 10:12:11 2006
@@ -0,0 +1,53 @@
+package org.apache.ojb.broker.sequence;
+
+/* Copyright 2002-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
+
+/**
+ * Test database identity columns for Hsql.
+ *
+ * @version $Id: $
+ */
+public class DatabaseIdentityHsqlTest extends DatabaseIdentityTest
+{
+ public static void main(String[] args)
+ {
+ String[] arr = {DatabaseIdentityHsqlTest.class.getName()};
+ junit.textui.TestRunner.main(arr);
+ }
+
+ public DatabaseIdentityHsqlTest(String s)
+ {
+ super(s);
+ }
+
+ protected void initDBDependend() throws Exception
+ {
+ databaseName = "Hsql";
+ dropConstraintMainTable = "ALTER TABLE NATIVE_MAIN_OBJECT DROP CONSTRAINT MAIN_REF_FK";
+ createMainTable = "CREATE TABLE NATIVE_MAIN_OBJECT(NATIVE_ID IDENTITY NOT NULL PRIMARY KEY, REF_ID int,NAME VARCHAR(250))";
+ createRefTable = "CREATE TABLE NATIVE_REFERENCE_OBJECT (NATIVE_ID IDENTITY NOT NULL PRIMARY KEY," +
+ " NAME VARCHAR(250), OJB_CONCRETE_CLASS VARCHAR(250), FK_ID int, REF_ID int, SINGLE_REF_FK BIGINT" +
+ " , FOREIGN KEY (FK_ID) REFERENCES NATIVE_MAIN_OBJECT (NATIVE_ID) )";
+
+ }
+
+ protected boolean isSupportedDatabase()
+ {
+ return platform instanceof PlatformHsqldbImpl;
+ }
+}
Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMaxDBTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMaxDBTest.java?rev=432643&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMaxDBTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMaxDBTest.java Fri Aug 18 10:12:11 2006
@@ -0,0 +1,55 @@
+package org.apache.ojb.broker.sequence;
+
+/* Copyright 2002-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.ojb.broker.platforms.PlatformMaxDBImpl;
+import org.apache.ojb.broker.platforms.PlatformSapdbImpl;
+
+/**
+ * Test database identity columns for MaxDB/SapDB.
+ *
+ * @version $Id: $
+ */
+public class DatabaseIdentityMaxDBTest extends DatabaseIdentityTest
+{
+ public static void main(String[] args)
+ {
+ String[] arr = {DatabaseIdentityMaxDBTest.class.getName()};
+ junit.textui.TestRunner.main(arr);
+ }
+
+ public DatabaseIdentityMaxDBTest(String s)
+ {
+ super(s);
+ }
+
+ protected void initDBDependend() throws Exception
+ {
+ databaseName = "MaxDB/SapDB";
+ dropConstraintMainTable = "ALTER TABLE NATIVE_MAIN_OBJECT DROP FOREIGN KEY MAIN_REF_FK";
+ createMainTable = "CREATE TABLE NATIVE_MAIN_OBJECT" +
+ "(NATIVE_ID SERIAL PRIMARY KEY, REF_ID FIXED(10), NAME VARCHAR(250))";
+ createRefTable =
+ "CREATE TABLE NATIVE_REFERENCE_OBJECT(NATIVE_ID SERIAL PRIMARY KEY," +
+ " NAME VARCHAR(250), OJB_CONCRETE_CLASS VARCHAR(250), FK_ID FIXED(10), REF_ID FIXED(10)," +
+ " SINGLE_REF_FK FIXED(10), FOREIGN KEY (FK_ID) REFERENCES NATIVE_MAIN_OBJECT (NATIVE_ID) )";
+ }
+
+ protected boolean isSupportedDatabase()
+ {
+ return platform instanceof PlatformMaxDBImpl || platform instanceof PlatformSapdbImpl;
+ }
+}
Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMySqlTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMySqlTest.java?rev=432643&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMySqlTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityMySqlTest.java Fri Aug 18 10:12:11 2006
@@ -0,0 +1,53 @@
+package org.apache.ojb.broker.sequence;
+
+/* Copyright 2002-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.ojb.broker.platforms.PlatformMySQLImpl;
+
+/**
+ * Test database identity columns for MySQL.
+ *
+ * @version $Id: $
+ */
+public class DatabaseIdentityMySqlTest extends DatabaseIdentityTest
+{
+ public static void main(String[] args)
+ {
+ String[] arr = {DatabaseIdentityMySqlTest.class.getName()};
+ junit.textui.TestRunner.main(arr);
+ }
+
+ public DatabaseIdentityMySqlTest(String s)
+ {
+ super(s);
+ }
+
+ protected void initDBDependend() throws Exception
+ {
+ databaseName = "MySQL";
+ dropConstraintMainTable = "ALTER TABLE NATIVE_MAIN_OBJECT DROP FOREIGN KEY MAIN_REF_FK";
+ createMainTable = "CREATE TABLE NATIVE_MAIN_OBJECT(NATIVE_ID int(11) NOT NULL PRIMARY KEY auto_increment,REF_ID int(11),NAME VARCHAR(250))";
+ createRefTable =
+ "CREATE TABLE NATIVE_REFERENCE_OBJECT (NATIVE_ID int(11) NOT NULL PRIMARY KEY auto_increment," +
+ " NAME VARCHAR(250), OJB_CONCRETE_CLASS VARCHAR(250), FK_ID int, REF_ID int(11), SINGLE_REF_FK BIGINT" +
+ " , FOREIGN KEY (FK_ID) REFERENCES NATIVE_MAIN_OBJECT (NATIVE_ID) )";
+ }
+
+ protected boolean isSupportedDatabase()
+ {
+ return platform instanceof PlatformMySQLImpl;
+ }
+}
Added: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityTest.java?rev=432643&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityTest.java (added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sequence/DatabaseIdentityTest.java Fri Aug 18 10:12:11 2006
@@ -0,0 +1,1368 @@
+package org.apache.ojb.broker.sequence;
+
+/* Copyright 2002-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.ojb.broker.Identity;
+import org.apache.ojb.broker.PersistenceBrokerFactory;
+import org.apache.ojb.broker.TestHelper;
+import org.apache.ojb.broker.metadata.MetadataManager;
+import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
+import org.apache.ojb.broker.metadata.SequenceDescriptor;
+import org.apache.ojb.broker.platforms.Platform;
+import org.apache.ojb.broker.query.Criteria;
+import org.apache.ojb.broker.query.QueryByCriteria;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl;
+import org.apache.ojb.junit.PBTestCase;
+import org.apache.ojb.odmg.OJB;
+import org.apache.ojb.odmg.TransactionExt;
+import org.odmg.Database;
+import org.odmg.Implementation;
+import org.odmg.Transaction;
+
+/**
+ * Test case for {@link org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl}. These test check
+ * support for native database identity columns. Test case only works for
+ * Hsql and Mysql.
+ *
+ * @version $Id: NativeIdentifierTest.java 379900 2006-02-22 22:11:53 +0100 (Mi, 22 Feb 2006) arminw $
+ */
+abstract public class DatabaseIdentityTest extends PBTestCase
+{
+
+ /**
+ * Override this method to implement other databases.
+ * @throws Exception
+ */
+ abstract protected void initDBDependend() throws Exception;
+
+ /**
+ * Override this check for each database dependend implementation.
+ * @return Return <em>true</em> if the
+ */
+ abstract protected boolean isSupportedDatabase();
+
+ protected String databaseName;
+
+ // Statements for MainObject table
+ protected String dropMainTable = "DROP TABLE NATIVE_MAIN_OBJECT";
+ protected String dropRefTable = "DROP TABLE NATIVE_REFERENCE_OBJECT";
+ protected String insertDummyRowMainTable = "INSERT INTO NATIVE_MAIN_OBJECT (NAME) VALUES ('Dummy_1')";
+ protected String insertDummyRowRefTable = "INSERT INTO NATIVE_REFERENCE_OBJECT (NAME) VALUES ('Dummy_2')";
+
+ protected String addConstraintMainTableToRefTable = "ALTER TABLE NATIVE_MAIN_OBJECT ADD CONSTRAINT " +
+ "MAIN_REF_FK FOREIGN KEY (REF_ID) REFERENCES NATIVE_REFERENCE_OBJECT (NATIVE_ID)";
+
+ protected String dropConstraintMainTable;
+ protected String createMainTable;
+ protected String createRefTable;
+
+ protected Platform platform;
+ private Class oldSequenceManager;
+
+ public DatabaseIdentityTest(String s)
+ {
+ super(s);
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ MetadataManager mm = MetadataManager.getInstance();
+ platform = broker.serviceConnectionManager().getSupportedPlatform();
+ if(isSupportedDatabase())
+ {
+ initDBDependend();
+ try{executeStatement(dropConstraintMainTable);}catch(Exception e){}
+ try{executeStatement(dropRefTable);}catch(Exception e){}
+ try{executeStatement(dropMainTable);}catch(Exception e){}
+ executeStatement(createMainTable);
+ executeStatement(createRefTable);
+ executeStatement(addConstraintMainTableToRefTable);
+ executeStatement(insertDummyRowMainTable);
+ executeStatement(insertDummyRowRefTable);
+ }
+
+ SequenceDescriptor sd = mm.connectionRepository().getDescriptor(broker.getPBKey()).getSequenceDescriptor();
+ oldSequenceManager = sd.getSequenceManagerClass();
+ // set the sequence manager
+ sd.setSequenceManagerClass(SequenceManagerNativeImpl.class);
+ broker.close();
+
+ // check usage of correct SequenceManager implementation
+ PersistenceBrokerFactory.releaseAllInstances();
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+
+ sd = mm.connectionRepository().getDescriptor(broker.getPBKey()).getSequenceDescriptor();
+ assertEquals(SequenceManagerNativeImpl.class, sd.getSequenceManagerClass());
+ }
+
+ public void tearDown() throws Exception
+ {
+ MetadataManager mm = MetadataManager.getInstance();
+ SequenceDescriptor sd = mm.connectionRepository().getDescriptor(broker.getPBKey()).getSequenceDescriptor();
+ sd.setSequenceManagerClass(oldSequenceManager);
+ broker.close();
+
+ PersistenceBrokerFactory.releaseAllInstances();
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+
+ sd = mm.connectionRepository().getDescriptor(broker.getPBKey()).getSequenceDescriptor();
+ assertEquals(oldSequenceManager, sd.getSequenceManagerClass());
+
+ super.tearDown();
+ }
+
+ protected void executeStatement(String statement) throws Exception
+ {
+ try
+ {
+ broker.beginTransaction();
+ Connection con = broker.serviceConnectionManager().getConnection();
+ Statement stmt = con.createStatement();
+ stmt.execute(statement);
+ stmt.close();
+ broker.commitTransaction();
+ }
+ catch(Exception e)
+ {
+ if(broker != null) broker.abortTransaction();
+ throw e;
+ }
+ }
+
+ public void testSimpleInsert_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, false);
+ doTestSimpleInsert();
+ }
+
+ public void testSimpleInsert_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, true);
+ doTestSimpleInsert();
+ }
+
+ public void doTestSimpleInsert() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testSimpleInsert_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_2 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_3 = new DatabaseIdentityTest.MainObject(null, name);
+
+ broker.beginTransaction();
+ broker.store(obj_1);
+// System.out.println("obj_1: "+obj_1);
+ broker.store(obj_2);
+// System.out.println("obj_2: "+obj_2);
+ broker.store(obj_3);
+// System.out.println("obj_3: "+obj_3);
+ broker.commitTransaction();
+
+ Criteria crit = new Criteria();
+ crit.addEqualTo("name", name);
+ QueryByCriteria query = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, crit);
+ int result = broker.getCount(query);
+ assertEquals("Not all objects created", 3, result);
+ assertNotNull(obj_1.getIdentifier());
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_3.getIdentifier().longValue() > 0);
+ }
+
+ public void testSimpleInsertODMG_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ int none = ObjectReferenceDescriptor.CASCADE_NONE;
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, none, none, false);
+ }
+
+ public void testSimpleInsertODMG_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ int none = ObjectReferenceDescriptor.CASCADE_NONE;
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, none, none, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, none, none, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, none, none, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, none, none, true);
+ }
+ public void doTestSimpleInsertODMG() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testSimpleInsert_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_2 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_3 = new DatabaseIdentityTest.MainObject(null, name);
+
+ Implementation odmg = OJB.getInstance();
+ Database db = odmg.newDatabase();
+ db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
+
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
+ tx.lock(obj_1, Transaction.WRITE);
+ tx.lock(obj_2, Transaction.WRITE);
+ tx.lock(obj_3, Transaction.WRITE);
+ tx.commit();
+
+ Criteria crit = new Criteria();
+ crit.addEqualTo("name", name);
+ QueryByCriteria query = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, crit);
+ int result = broker.getCount(query);
+ assertEquals("Not all objects created", 3, result);
+ assertNotNull(obj_1.getIdentifier());
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_3.getIdentifier().longValue() > 0);
+ }
+
+ public void testReferenceInsertUpdate_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, false);
+ doTestReferenceInsertUpdate();
+ }
+
+ public void testReferenceInsertUpdate_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, true);
+ doTestReferenceInsertUpdate();
+ }
+
+ public void doTestReferenceInsertUpdate() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testReferenceInsert_main_" + timestamp;
+ String nameRef = "testReferenceInsert_reference_" + timestamp;
+ String nameSingleRef = "testReferenceInsert_single_reference_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_2 = new DatabaseIdentityTest.MainObject(null, name);
+
+ DatabaseIdentityTest.SingleReference s_ref_1 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+ DatabaseIdentityTest.SingleReference s_ref_2 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+
+ DatabaseIdentityTest.CollectionReference ref_1 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_2 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_3 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_4 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ ref_1.setSingleReference(s_ref_1);
+ ref_4.setSingleReference(s_ref_2);
+
+ DatabaseIdentityTest.SingleReference s_ref_3 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+ DatabaseIdentityTest.SingleReference s_ref_4 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+
+ obj_1.addReference(ref_1);
+ obj_1.addReference(ref_2);
+ obj_1.addReference(ref_3);
+ obj_1.addReference(ref_4);
+
+ obj_1.setSingleReference(s_ref_3);
+ s_ref_3.setMainObject(obj_1);
+ obj_2.setSingleReference(s_ref_4);
+ s_ref_3.setMainObject(obj_1);
+
+ broker.beginTransaction();
+ // first store a reference
+ broker.store(ref_1);
+// System.out.println("ref_1: "+ref_1);
+ // then store main object with other references
+ broker.store(obj_1);
+// System.out.println("obj_1: "+obj_1);
+ // store second object without references
+ broker.store(obj_2);
+// System.out.println("obj_2: "+obj_2);
+ broker.commitTransaction();
+
+ // try to find both objects
+ Criteria crit = new Criteria();
+ crit.addEqualTo("name", name);
+ QueryByCriteria query = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, crit);
+ int result = broker.getCount(query);
+ assertEquals("Wrong object count", 2, result);
+
+ // pk have to set and have to be different
+ assertNotNull(obj_1.getIdentifier());
+ assertNotNull(obj_2.getIdentifier());
+ assertNotSame(obj_1.getIdentifier(), obj_2.getIdentifier());
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ assertTrue(s_ref_3.getId().longValue() > 0);
+ assertTrue(ref_3.getRefIdentifier().longValue() > 0);
+
+ // get Identity objects
+ Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
+ Identity oid_2 = broker.serviceIdentity().buildIdentity(obj_2);
+ // get identifier (PK) values
+ Long id_1 = obj_1.getIdentifier();
+ Long id_2 = obj_2.getIdentifier();
+
+ broker.clearCache();
+
+ // get object with references
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(obj_1);
+ List references = obj_1.getAllReferences();
+ assertNotNull(references);
+ assertEquals("4 references expected for object: "+obj_1, 4, references.size());
+ Iterator it = references.iterator();
+ while (it.hasNext())
+ {
+ DatabaseIdentityTest.CollectionReference ref = (DatabaseIdentityTest.CollectionReference) it.next();
+ assertEquals("Main object fk expected", obj_1.getIdentifier(), ref.fkIdentifier);
+ assertTrue("We expect a positive value, identity columns have to start > 0",
+ (ref.getRefIdentifier().longValue() > 0));
+ }
+ assertNotNull(obj_1.getSingleReference());
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ assertNotNull(obj_2.getSingleReference());
+ assertTrue(obj_2.getSingleReference().getId().longValue() > 0);
+ assertTrue(obj_1.getSingleReference().getId().longValue() > 0);
+ assertNotSame(obj_1.getSingleReference(), obj_2.getSingleReference());
+ broker.clearCache();
+
+ // get references only
+ Criteria crit_2 = new Criteria();
+ crit_2.addEqualTo("refName", nameRef);
+ QueryByCriteria query_2 = QueryFactory.newQuery(DatabaseIdentityTest.CollectionReference.class, crit_2);
+ int result_2 = broker.getCount(query_2);
+ assertEquals("Not all objects created", 4, result_2);
+ assertNotNull(ref_3.getRefIdentifier());
+
+ broker.clearCache();
+
+ // get second object
+ DatabaseIdentityTest.MainObject retObj = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ List refList = retObj.getAllReferences();
+ assertNotNull(refList);
+ assertEquals("object do not have references", 0, refList.size());
+
+ // add new reference to object
+ DatabaseIdentityTest.CollectionReference ref_5 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_6 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ obj_1.addReference(ref_5);
+ obj_2.addReference(ref_6);
+ broker.beginTransaction();
+ broker.store(obj_1);
+ broker.store(obj_2);
+ broker.commitTransaction();
+ assertNotNull(ref_5.getRefIdentifier());
+ assertNotNull(ref_6.getRefIdentifier());
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(obj_1);
+ references = obj_1.getAllReferences();
+ assertNotNull(references);
+ assertEquals("5 references expected for object: "+obj_1, 5, references.size());
+
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ // now update main objects
+ obj_1.setName(name+"_update");
+ obj_2.setName(name+"_update");
+ broker.beginTransaction();
+ broker.store(obj_1);
+ broker.store(obj_2);
+ broker.commitTransaction();
+
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+
+ assertNotNull(obj_1);
+ assertNotNull(obj_2);
+ assertEquals(obj_1.getName(), name+"_update");
+ assertEquals(obj_2.getName(), name+"_update");
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ // now update reference
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ DatabaseIdentityTest.CollectionReference ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ ref.setRefName(nameRef+"_update");
+ broker.beginTransaction();
+ broker.store(obj_2);
+ broker.commitTransaction();
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ assertEquals(nameRef+"_update", ref.getRefName());
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+ }
+
+ /**
+ * critical test case, because single broker instance (PB-api) is concurrent used
+ * with the ODMG-api, take care of caches
+ */
+ public void testReferenceInsertUpdateODMG_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare metadata for odmg-api
+ int none = ObjectReferenceDescriptor.CASCADE_NONE;
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, none, none, false);
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testReferenceInsert_main_" + timestamp;
+ String nameRef = "testReferenceInsert_reference_" + timestamp;
+ String nameSingleRef = "testReferenceInsert_single_reference_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_2 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.SingleReference s_ref_4 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+ obj_2.setSingleReference(s_ref_4);
+
+ Implementation odmg = OJB.getInstance();
+ Database db = odmg.newDatabase();
+ db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
+
+ TransactionExt tx = (TransactionExt) odmg.newTransaction();
+ tx.begin();
+ db.makePersistent(s_ref_4);
+ db.makePersistent(obj_2);
+ tx.commit();
+
+ tx.begin();
+
+ // try to find object
+ Criteria crit = new Criteria();
+ crit.addEqualTo("name", name);
+ QueryByCriteria query = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, crit);
+
+ int result = tx.getBroker().getCount(query);
+ assertEquals("Wrong object count", 1, result);
+ // pk have to set and have to be different
+ assertNotNull(obj_2.getIdentifier());
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ // no collection reference set
+ List references = obj_2.getAllReferences();
+ assertTrue(references == null || references.size() == 0);
+ // get Identity objects
+ Identity oid_2 = tx.getBroker().serviceIdentity().buildIdentity(obj_2);
+ // get identifier (PK) values
+ Long id_2 = obj_2.getIdentifier();
+
+ tx.getBroker().clearCache();
+ obj_2 = (DatabaseIdentityTest.MainObject) tx.getBroker().getObjectByIdentity(oid_2);
+
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ assertNotNull(obj_2.getSingleReference());
+ assertTrue(obj_2.getSingleReference().getId().longValue() > 0);
+ // no collection reference set
+ references = obj_2.getAllReferences();
+ assertTrue(references == null || references.size() == 0);
+
+ tx.getBroker().clearCache();
+ // get references only
+ Criteria crit_2 = new Criteria();
+ crit_2.addEqualTo("refName", nameRef);
+ QueryByCriteria query_2 = QueryFactory.newQuery(DatabaseIdentityTest.CollectionReference.class, crit_2);
+ int result_2 = tx.getBroker().getCount(query_2);
+
+ assertEquals(0, result_2);
+
+ tx.getBroker().clearCache();
+ // get object
+ DatabaseIdentityTest.MainObject retObj = (DatabaseIdentityTest.MainObject) tx.getBroker().getObjectByIdentity(oid_2);
+
+ List refList = retObj.getAllReferences();
+ assertNotNull(refList);
+ assertEquals("object do not have references", 0, refList.size());
+ tx.commit();
+
+ // add new reference to object
+ DatabaseIdentityTest.CollectionReference ref_6 = new DatabaseIdentityTest.CollectionReference(null, "###_new_" + nameRef);
+ tx.begin();
+ tx.lock(obj_2, Transaction.WRITE);
+ obj_2.addReference(ref_6);
+ tx.commit();
+
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+
+
+ assertNotNull(ref_6.getRefIdentifier());
+ // check FK setting
+ Long fk = ref_6.getFkIdentifier();
+ assertNotNull(fk);
+ assertEquals(obj_2.getIdentifier(), fk);
+ assertEquals(id_2, obj_2.getIdentifier());
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+ assertNotNull(references);
+
+ tx.begin();
+ obj_2 = (DatabaseIdentityTest.MainObject) tx.getBroker().getObjectByIdentity(oid_2);
+ // we don't change the main object, only add an reference, so the
+ // cached version of the object isn't up to date
+ tx.getBroker().retrieveAllReferences(obj_2);
+ tx.commit();
+
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("Reference expected for object", 1, references.size());
+
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ // now update main objects
+ tx.begin();
+ tx.lock(obj_2, Transaction.WRITE);
+ obj_2.setName(name+"_update");
+ tx.commit();
+
+ broker.close();
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ broker.close();
+
+ assertNotNull(obj_2);
+ assertEquals(obj_2.getName(), name+"_update");
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ broker.close();
+
+ // now update reference
+ assertNotNull(obj_2);
+ tx.begin();
+ tx.lock(obj_2, Transaction.WRITE);
+ references = obj_2.getAllReferences();
+ DatabaseIdentityTest.CollectionReference ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ tx.lock(ref, Transaction.WRITE);
+ ref.setRefName(nameRef+"_update");
+ tx.commit();
+
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ assertEquals(nameRef+"_update", ref.getRefName());
+ assertEquals(id_2, obj_2.getIdentifier());
+ }
+
+ /**
+ * critical test case, because single broker instance (PB-api) is concurrent used
+ * with the ODMG-api, take care of caches
+ */
+ public void testReferenceInsertUpdateODMG_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare metadata for odmg-api
+ int none = ObjectReferenceDescriptor.CASCADE_NONE;
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, none, none, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, none, none, false);
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testReferenceInsert_main_" + timestamp;
+ String nameRef = "testReferenceInsert_reference_" + timestamp;
+ String nameSingleRef = "testReferenceInsert_single_reference_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+ DatabaseIdentityTest.MainObject obj_2 = new DatabaseIdentityTest.MainObject(null, name);
+
+ DatabaseIdentityTest.SingleReference s_ref_1 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+ DatabaseIdentityTest.SingleReference s_ref_2 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+
+ DatabaseIdentityTest.CollectionReference ref_1 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_2 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_3 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_4 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ ref_1.setSingleReference(s_ref_1);
+ ref_4.setSingleReference(s_ref_2);
+
+ DatabaseIdentityTest.SingleReference s_ref_3 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+ DatabaseIdentityTest.SingleReference s_ref_4 = new DatabaseIdentityTest.SingleReference(nameSingleRef);
+
+ obj_1.addReference(ref_1);
+ obj_1.addReference(ref_2);
+ obj_1.addReference(ref_3);
+ obj_1.addReference(ref_4);
+
+ obj_1.setSingleReference(s_ref_3);
+ obj_2.setSingleReference(s_ref_4);
+
+ Implementation odmg = OJB.getInstance();
+ Database db = odmg.newDatabase();
+ db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
+
+ Transaction tx = odmg.newTransaction();
+ tx.begin();
+ db.makePersistent(s_ref_1);
+ db.makePersistent(s_ref_2);
+ db.makePersistent(s_ref_3);
+ db.makePersistent(s_ref_4);
+
+ db.makePersistent(obj_1);
+ db.makePersistent(obj_2);
+ tx.commit();
+
+ // try to find both objects
+ Criteria crit = new Criteria();
+ crit.addEqualTo("name", name);
+ QueryByCriteria query = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, crit);
+ int result = broker.getCount(query);
+ assertEquals("Wrong object count", 2, result);
+
+ // pk have to set and have to be different
+ assertNotNull(obj_1.getIdentifier());
+ assertNotNull(obj_2.getIdentifier());
+ assertNotSame(obj_1.getIdentifier(), obj_2.getIdentifier());
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ assertTrue(s_ref_3.getId().longValue() > 0);
+ assertTrue(ref_3.getRefIdentifier().longValue() > 0);
+
+ // no collection reference set
+ List references = obj_2.getAllReferences();
+ assertTrue(references == null || references.size() == 0);
+ // check anonymous FK setting
+ Long fk = (Long) broker.getClassDescriptor(DatabaseIdentityTest.MainObject.class)
+ .getFieldDescriptorByName("refFK")
+ .getPersistentField().get(obj_1);
+ assertTrue("The assigned FK should be > 0 after store of main object, but was " + fk.longValue(), fk.longValue() > 0);
+
+ // get Identity objects
+ Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
+ Identity oid_2 = broker.serviceIdentity().buildIdentity(obj_2);
+ // get identifier (PK) values
+ Long id_1 = obj_1.getIdentifier();
+ Long id_2 = obj_2.getIdentifier();
+
+ broker.clearCache();
+
+ // get object with references
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(obj_1);
+ references = obj_1.getAllReferences();
+ assertNotNull(references);
+ assertEquals("4 references expected for object: "+obj_1, 4, references.size());
+ Iterator it = references.iterator();
+ while (it.hasNext())
+ {
+ DatabaseIdentityTest.CollectionReference ref = (DatabaseIdentityTest.CollectionReference) it.next();
+ assertEquals("Main object fk expected", obj_1.getIdentifier(), ref.fkIdentifier);
+ assertTrue("We expect a positive value, identity columns have to start > 0",
+ (ref.getRefIdentifier().longValue() > 0));
+ }
+ assertNotNull(obj_1.getSingleReference());
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertTrue(obj_1.getIdentifier().longValue() > 0);
+ assertTrue(obj_2.getIdentifier().longValue() > 0);
+ assertNotNull(obj_2.getSingleReference());
+ assertTrue(obj_2.getSingleReference().getId().longValue() > 0);
+ assertTrue(obj_1.getSingleReference().getId().longValue() > 0);
+ assertNotSame(obj_1.getSingleReference(), obj_2.getSingleReference());
+ // no collection reference set
+ references = obj_2.getAllReferences();
+ assertTrue(references == null || references.size() == 0);
+ broker.clearCache();
+
+ // get references only
+ Criteria crit_2 = new Criteria();
+ crit_2.addEqualTo("refName", nameRef);
+ QueryByCriteria query_2 = QueryFactory.newQuery(DatabaseIdentityTest.CollectionReference.class, crit_2);
+ int result_2 = broker.getCount(query_2);
+ assertEquals("Not all objects created", 4, result_2);
+ assertNotNull(ref_3.getRefIdentifier());
+
+ broker.clearCache();
+
+ // get second object
+ DatabaseIdentityTest.MainObject retObj = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ List refList = retObj.getAllReferences();
+ assertNotNull(refList);
+ assertEquals("object do not have references", 0, refList.size());
+
+ // add new reference to object
+ DatabaseIdentityTest.CollectionReference ref_5 = new DatabaseIdentityTest.CollectionReference(null, "##new ref 1_" + nameRef);
+ DatabaseIdentityTest.CollectionReference ref_6 = new DatabaseIdentityTest.CollectionReference(null, "##new ref 2_" + nameRef);
+ tx.begin();
+ tx.lock(obj_1, Transaction.WRITE);
+ tx.lock(obj_2, Transaction.WRITE);
+ obj_1.addReference(ref_5);
+ obj_2.addReference(ref_6);
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+ tx.commit();
+
+ assertNotNull(ref_5.getRefIdentifier());
+ assertNotNull(ref_6.getRefIdentifier());
+ // check FK setting
+ fk = ref_5.getFkIdentifier();
+ assertNotNull(fk);
+ assertEquals(obj_1.getIdentifier(), fk);
+ fk = ref_6.getFkIdentifier();
+ assertNotNull(fk);
+ assertEquals(obj_2.getIdentifier(), fk);
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+
+ // refresh used broker instance to avoid problems with session cache (when used)
+ broker.close();
+ broker = PersistenceBrokerFactory.defaultPersistenceBroker();
+
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(obj_1);
+ references = obj_1.getAllReferences();
+ assertNotNull(references);
+ assertEquals("5 references expected for object: "+obj_1, 5, references.size());
+
+ // we don't change the main object, only add an reference, so the
+ // cached version of the object isn't up to date. So we have to retrieve
+ // all referenced objects to make it work with all cache implementations
+ // or evict the whole cache instead
+ // broker.clearCache();
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ broker.retrieveAllReferences(obj_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ assertNotNull(references);
+ assertEquals("1 references expected for object: "+obj_2, 1, references.size());
+
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ // now update main objects
+ tx.begin();
+ tx.lock(obj_1, Transaction.WRITE);
+ tx.lock(obj_2, Transaction.WRITE);
+ obj_1.setName(name+"_update");
+ obj_2.setName(name+"_update");
+ tx.commit();
+
+ obj_1 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+
+ assertNotNull(obj_1);
+ assertNotNull(obj_2);
+ assertEquals(obj_1.getName(), name+"_update");
+ assertEquals(obj_2.getName(), name+"_update");
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+
+ // now update reference
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ tx.begin();
+ tx.lock(obj_2, Transaction.WRITE);
+ references = obj_2.getAllReferences();
+ DatabaseIdentityTest.CollectionReference ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ tx.lock(ref, Transaction.WRITE);
+ ref.setRefName(nameRef+"_update");
+ tx.commit();
+
+ obj_2 = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_2);
+ assertNotNull(obj_2);
+ references = obj_2.getAllReferences();
+ ref = (DatabaseIdentityTest.CollectionReference) references.get(0);
+ assertEquals(nameRef+"_update", ref.getRefName());
+ assertEquals(id_1, obj_1.getIdentifier());
+ assertEquals(id_2, obj_2.getIdentifier());
+ }
+
+ public void testDelete_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, false);
+ doTestDelete();
+ }
+
+ public void testDelete_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, true);
+ doTestDelete();
+ }
+
+ public void doTestDelete() throws Exception
+ {
+ long timestamp = System.currentTimeMillis();
+ String name = "testDelete_main_" + timestamp;
+ String nameRef = "testDelete_reference_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+
+ DatabaseIdentityTest.CollectionReference ref_1 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_2 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+
+ obj_1.addReference(ref_1);
+ obj_1.addReference(ref_2);
+ broker.beginTransaction();
+ broker.store(obj_1);
+ broker.commitTransaction();
+ Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
+
+ DatabaseIdentityTest.MainObject result = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(result);
+ assertNotNull(result.getAllReferences());
+ assertEquals(2, result.getAllReferences().size());
+ Long fk = ((DatabaseIdentityTest.CollectionReference) result.getAllReferences().get(0)).getFkIdentifier();
+ assertNotNull(result.getIdentifier());
+ assertEquals(result.getIdentifier(), fk);
+
+ broker.beginTransaction();
+ broker.delete(obj_1);
+ broker.commitTransaction();
+
+ result = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNull(result);
+ Criteria crit_2 = new Criteria();
+ crit_2.addEqualTo("refName", nameRef);
+ QueryByCriteria query_2 = QueryFactory.newQuery(DatabaseIdentityTest.CollectionReference.class, crit_2);
+ int result_2 = broker.getCount(query_2);
+ assertEquals(0, result_2);
+ }
+
+ public void testDeleteTwo_1() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, false);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, false);
+ doTestDeleteTwo();
+ }
+
+ public void testDeleteTwo_2() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ // prepare for PB-api test
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.MainObject.class, "allReferences", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.CollectionReference.class, "singleReference", true, true, true, true);
+ ojbChangeReferenceSetting(DatabaseIdentityTest.SingleReference.class, "mainObject", true, true, true, true);
+ doTestDeleteTwo();
+ }
+
+ public void doTestDeleteTwo() throws Exception
+ {
+ if(!isSupportedDatabase())
+ {
+ this.ojbSkipTestMessage("Skip " + databaseName + " specific test");
+ return;
+ }
+
+ long timestamp = System.currentTimeMillis();
+ String name = "testDeleteTwo_main_" + timestamp;
+ String nameRef = "testDeleteTwo_reference_" + timestamp;
+
+ DatabaseIdentityTest.MainObject obj_1 = new DatabaseIdentityTest.MainObject(null, name);
+
+ DatabaseIdentityTest.CollectionReference ref_1 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+ DatabaseIdentityTest.CollectionReference ref_2 = new DatabaseIdentityTest.CollectionReference(null, nameRef);
+
+ obj_1.addReference(ref_1);
+ obj_1.addReference(ref_2);
+
+ // chaotic operations
+ broker.beginTransaction();
+ //System.out.println("1. "+obj_1);
+ broker.store(obj_1);
+ //System.out.println("2. "+obj_1);
+ broker.delete(obj_1);
+ //System.out.println("3. "+obj_1);
+ broker.store(obj_1);
+ //System.out.println("4. "+obj_1);
+ broker.delete(obj_1);
+ //System.out.println("5. "+obj_1);
+ broker.store(obj_1);
+ //System.out.println("6. "+obj_1);
+ broker.delete(obj_1);
+ //System.out.println("7. "+obj_1);
+ broker.store(obj_1);
+ //System.out.println("8. "+obj_1);
+ broker.commitTransaction();
+
+ Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
+ DatabaseIdentityTest.MainObject result = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNotNull(result);
+ assertNotNull(result.getAllReferences());
+ assertEquals(2, result.getAllReferences().size());
+ Long fk = ((DatabaseIdentityTest.CollectionReference) result.getAllReferences().get(0)).getFkIdentifier();
+ assertNotNull(result.getIdentifier());
+ //System.out.println("## Result: " + result);
+ //System.out.println("## Result: " + result.getAllReferences());
+ assertEquals(result.getIdentifier(), fk);
+
+ // we should find exactly one object
+ Criteria c = new Criteria();
+ c.addEqualTo("name", name);
+ QueryByCriteria q = QueryFactory.newQuery(DatabaseIdentityTest.MainObject.class, c);
+ Collection col = broker.getCollectionByQuery(q);
+ assertNotNull(col);
+ assertEquals(1, col.size());
+
+ broker.beginTransaction();
+ broker.delete(obj_1);
+ broker.commitTransaction();
+
+ result = (DatabaseIdentityTest.MainObject) broker.getObjectByIdentity(oid_1);
+ assertNull(result);
+ Criteria crit_2 = new Criteria();
+ crit_2.addEqualTo("refName", nameRef);
+ QueryByCriteria query_2 = QueryFactory.newQuery(DatabaseIdentityTest.CollectionReference.class, crit_2);
+ int result_2 = broker.getCount(query_2);
+ assertEquals(0, result_2);
+ }
+
+// public void testAllInOne() throws Exception
+// {
+// // sleep thread to make timestamp based tests work
+// testSimpleInsert();
+// ojbSleep();
+// ojbSleep();
+// testSimpleInsert();
+// ojbSleep();
+// ojbSleep();
+// testReferenceInsertUpdate();
+// ojbSleep();
+// ojbSleep();
+// // testReferenceInsertUpdate_2();
+// ojbSleep();
+// ojbSleep();
+// testReferenceInsertUpdate();
+// }
+
+// void ojbChangeReferenceSetting(Class clazz, String referenceField, boolean autoRetrieve, int autoUpdate, int autoDelete, boolean useProxy)
+// {
+// ClassDescriptor cld = broker.getClassDescriptor(clazz);
+// ObjectReferenceDescriptor ref = cld.getCollectionDescriptorByName(referenceField);
+// if(ref == null) ref = cld.getObjectReferenceDescriptorByName(referenceField);
+// ref.setLazy(useProxy);
+// ref.setCascadeRetrieve(autoRetrieve);
+// ref.setCascadingStore(autoUpdate);
+// ref.setCascadingDelete(autoDelete);
+// }
+//
+// void ojbChangeReferenceSetting(Class clazz, String referenceField, boolean autoRetrieve, boolean autoUpdate, boolean autoDelete, boolean useProxy)
+// {
+// ClassDescriptor cld = broker.getClassDescriptor(clazz);
+// ObjectReferenceDescriptor ref = cld.getCollectionDescriptorByName(referenceField);
+// if(ref == null) ref = cld.getObjectReferenceDescriptorByName(referenceField);
+// ref.setLazy(useProxy);
+// ref.setCascadeRetrieve(autoRetrieve);
+// ref.setCascadeStore(autoUpdate);
+// ref.setCascadeDelete(autoDelete);
+// }
+
+
+ //========================================================================
+ // inner classes, used for test
+ //========================================================================
+
+ public static interface MainObjectIF extends Serializable
+ {
+ public DatabaseIdentityTest.SingleReferenceIF getSingleReference();
+ public void setSingleReference(DatabaseIdentityTest.SingleReferenceIF singleReference);
+ public List getAllReferences();
+ public void addReference(DatabaseIdentityTest.CollectionReference reference);
+ public void setAllReferences(List allReferences);
+ public Long getIdentifier();
+ public void setIdentifier(Long identifier);
+ public String getName();
+ public void setName(String name);
+ }
+
+ public static class MainObject implements DatabaseIdentityTest.MainObjectIF
+ {
+ private Long identifier;
+ private String name;
+ private List allReferences;
+ // we use anonymous field for FK
+ private DatabaseIdentityTest.SingleReferenceIF singleReference;
+
+
+ public MainObject()
+ {
+ }
+
+ public MainObject(Long identifier, String name)
+ {
+ this.identifier = identifier;
+ this.name = name;
+ }
+
+ public DatabaseIdentityTest.SingleReferenceIF getSingleReference()
+ {
+ return singleReference;
+ }
+
+ public void setSingleReference(DatabaseIdentityTest.SingleReferenceIF singleReference)
+ {
+ this.singleReference = singleReference;
+ }
+
+ public List getAllReferences()
+ {
+ return allReferences;
+ }
+
+ public void addReference(DatabaseIdentityTest.CollectionReference reference)
+ {
+ if (allReferences == null)
+ {
+ allReferences = new ArrayList();
+ }
+ allReferences.add(reference);
+ }
+
+ public void setAllReferences(List allReferences)
+ {
+ this.allReferences = allReferences;
+ }
+
+ public Long getIdentifier()
+ {
+ return identifier;
+ }
+
+ public void setIdentifier(Long identifier)
+ {
+ this.identifier = identifier;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("identifier", identifier).append("name", name)
+ .append("allReferences", (allReferences != null ? allReferences.toString() : "null"))
+ .append("singleReference", (singleReference != null ? singleReference.getClass().toString(): "null"))
+ .toString();
+ }
+ }
+
+ public static interface SingleReferenceIF extends Serializable
+ {
+ public DatabaseIdentityTest.MainObjectIF getMainObject();
+ public void setMainObject(DatabaseIdentityTest.MainObjectIF mainObject);
+ public Long getId();
+ public void setId(Long id);
+ public String getName();
+ public void setName(String name);
+ }
+
+ public static class SingleReference implements DatabaseIdentityTest.SingleReferenceIF
+ {
+ Long id;
+ String name;
+ String ojbConcreteClass;
+ DatabaseIdentityTest.MainObjectIF mainObject;
+
+ public SingleReference()
+ {
+ this(null);
+ }
+
+ public SingleReference(String name)
+ {
+ this.name = name;
+ ojbConcreteClass = DatabaseIdentityTest.SingleReference.class.getName();
+ // id = new Long((long)(Math.random() * Integer.MAX_VALUE));
+ }
+
+ public String getOjbConcreteClass()
+ {
+ return ojbConcreteClass;
+ }
+
+ public void setOjbConcreteClass(String ojbConcreteClass)
+ {
+ this.ojbConcreteClass = ojbConcreteClass;
+ }
+
+ public DatabaseIdentityTest.MainObjectIF getMainObject()
+ {
+ return mainObject;
+ }
+
+ public void setMainObject(DatabaseIdentityTest.MainObjectIF mainObject)
+ {
+ this.mainObject = mainObject;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("id", id).append("name", name)
+ .append("mainObject", mainObject != null ? mainObject.getClass().toString() : "null").toString();
+ }
+ }
+
+ public static interface CollectionReferenceIF extends Serializable
+ {
+ public Long getRefIdentifier();
+ public void setRefIdentifier(Long refIdentifier);
+ public DatabaseIdentityTest.SingleReferenceIF getSingleReference();
+ public void setSingleReference(DatabaseIdentityTest.SingleReferenceIF singleReference);
+ public Long getFkIdentifier();
+ public void setFkIdentifier(Long fkIdentifier);
+ public String getRefName();
+ public void setRefName(String refName);
+ }
+
+ public static class CollectionReference implements DatabaseIdentityTest.CollectionReferenceIF
+ {
+ private Long refIdentifier;
+ private String refName;
+ private Long fkIdentifier;
+ String ojbConcreteClass;
+ private DatabaseIdentityTest.SingleReferenceIF singleReference;
+
+ public CollectionReference()
+ {
+ ojbConcreteClass = DatabaseIdentityTest.CollectionReference.class.getName();
+ }
+
+ public CollectionReference(Long refIdentifier, String refName)
+ {
+ this();
+ this.refIdentifier = refIdentifier;
+ this.refName = refName;
+ }
+
+ public String getOjbConcreteClass()
+ {
+ return ojbConcreteClass;
+ }
+
+ public void setOjbConcreteClass(String ojbConcreteClass)
+ {
+ this.ojbConcreteClass = ojbConcreteClass;
+ }
+
+ public Long getRefIdentifier()
+ {
+ return refIdentifier;
+ }
+
+ public void setRefIdentifier(Long refIdentifier)
+ {
+ this.refIdentifier = refIdentifier;
+ }
+
+ public DatabaseIdentityTest.SingleReferenceIF getSingleReference()
+ {
+ return singleReference;
+ }
+
+ public void setSingleReference(DatabaseIdentityTest.SingleReferenceIF singleReference)
+ {
+ this.singleReference = singleReference;
+ }
+
+ public Long getFkIdentifier()
+ {
+ return fkIdentifier;
+ }
+
+ public void setFkIdentifier(Long fkIdentifier)
+ {
+ this.fkIdentifier = fkIdentifier;
+ }
+
+ public String getRefName()
+ {
+ return refName;
+ }
+
+ public void setRefName(String refName)
+ {
+ this.refName = refName;
+ }
+
+ public String toString()
+ {
+ return new ToStringBuilder(this).append("id", refIdentifier).append("name", refName)
+ .append("fkIdentifier", fkIdentifier)
+ .append("singleReference", singleReference != null ? singleReference.toString() : "null")
+ .toString();
+ }
+ }
+}
Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_meta_seq.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_meta_seq.xml?rev=432643&r1=432642&r2=432643&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_meta_seq.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_meta_seq.xml Fri Aug 18 10:12:11 2006
@@ -509,11 +509,13 @@
</class-descriptor>
- <!-- NOTE: This test class is specific for hsql, the database table was
- generated at runtime
+
+ <!--
+ NOTE: This class mapping is used to test native database identity column
+ support, the database table was generated at runtime
-->
<class-descriptor
- class="org.apache.ojb.broker.sequence.NativeIdentifierTest$MainObject"
+ class="org.apache.ojb.broker.sequence.DatabaseIdentityTest$MainObject"
table="NATIVE_MAIN_OBJECT"
>
<field-descriptor
@@ -540,31 +542,32 @@
<reference-descriptor
name="singleReference"
- class-ref="org.apache.ojb.broker.sequence.NativeIdentifierTest$SingleReference"
+ class-ref="org.apache.ojb.broker.sequence.DatabaseIdentityTest$SingleReference"
proxy="false"
auto-retrieve="true"
- auto-update="false"
- auto-delete="false">
+ auto-update="none"
+ auto-delete="none">
<foreignkey field-ref="refFK"/>
</reference-descriptor>
<collection-descriptor
name="allReferences"
- element-class-ref="org.apache.ojb.broker.sequence.NativeIdentifierTest$CollectionReference"
+ element-class-ref="org.apache.ojb.broker.sequence.DatabaseIdentityTest$CollectionReference"
auto-retrieve="true"
- auto-update="false"
- auto-delete="false"
+ auto-update="none"
+ auto-delete="none"
>
<orderby name="refIdentifier" sort="DESC"/>
<inverse-foreignkey field-ref="fkIdentifier"/>
</collection-descriptor>
</class-descriptor>
-<!-- NOTE: This test class is specific for hsql, the database table was
- generated at runtime
+ <!--
+ NOTE: This class mapping is used to test native database identity column
+ support, the database table was generated at runtime
-->
<class-descriptor
- class="org.apache.ojb.broker.sequence.NativeIdentifierTest$CollectionReference"
+ class="org.apache.ojb.broker.sequence.DatabaseIdentityTest$CollectionReference"
table="NATIVE_REFERENCE_OBJECT"
>
<field-descriptor
@@ -603,20 +606,21 @@
<reference-descriptor
name="singleReference"
- class-ref="org.apache.ojb.broker.sequence.NativeIdentifierTest$SingleReference"
+ class-ref="org.apache.ojb.broker.sequence.DatabaseIdentityTest$SingleReference"
proxy="false"
auto-retrieve="true"
- auto-update="false"
- auto-delete="false">
+ auto-update="none"
+ auto-delete="none">
<foreignkey field-ref="singleRefFK"/>
</reference-descriptor>
</class-descriptor>
- <!-- NOTE: This test class is specific for hsql, the database table was
- generated at runtime
+ <!--
+ NOTE: This class mapping is used to test native database identity column
+ support, the database table was generated at runtime
-->
<class-descriptor
- class="org.apache.ojb.broker.sequence.NativeIdentifierTest$SingleReference"
+ class="org.apache.ojb.broker.sequence.DatabaseIdentityTest$SingleReference"
table="NATIVE_REFERENCE_OBJECT"
>
<field-descriptor
@@ -649,7 +653,7 @@
<reference-descriptor
name="mainObject"
- class-ref="org.apache.ojb.broker.sequence.NativeIdentifierTest$MainObject"
+ class-ref="org.apache.ojb.broker.sequence.DatabaseIdentityTest$MainObject"
proxy="false"
auto-retrieve="true"
auto-update="false"
@@ -657,6 +661,7 @@
<foreignkey field-ref="refFK"/>
</reference-descriptor>
</class-descriptor>
+
<!-- ************************************************* -->
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org