Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 24336 invoked from network); 22 Mar 2005 15:04:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2005 15:04:58 -0000 Received: (qmail 53030 invoked by uid 500); 22 Mar 2005 15:04:57 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 52994 invoked by uid 500); 22 Mar 2005 15:04:57 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 52979 invoked by uid 500); 22 Mar 2005 15:04:56 -0000 Received: (qmail 52976 invoked by uid 99); 22 Mar 2005 15:04:56 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 22 Mar 2005 07:04:55 -0800 Received: (qmail 24309 invoked by uid 1510); 22 Mar 2005 15:04:54 -0000 Date: 22 Mar 2005 15:04:54 -0000 Message-ID: <20050322150454.24308.qmail@minotaur.apache.org> From: arminw@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/test/org/apache/ojb/odmg AllTests.java InheritanceMultipleTableTest.java LockingMultithreadedTest.java RITest.java X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N arminw 2005/03/22 07:04:54 Modified: src/test/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE AllTests.java InheritanceMultipleTableTest.java LockingMultithreadedTest.java RITest.java Log: update tests Revision Changes Path No revision No revision 1.18.2.4 +1 -1 db-ojb/src/test/org/apache/ojb/odmg/AllTests.java Index: AllTests.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/AllTests.java,v retrieving revision 1.18.2.3 retrieving revision 1.18.2.4 diff -u -r1.18.2.3 -r1.18.2.4 --- AllTests.java 4 Dec 2004 14:46:31 -0000 1.18.2.3 +++ AllTests.java 22 Mar 2005 15:04:54 -0000 1.18.2.4 @@ -49,7 +49,7 @@ suite.addTestSuite(PersonWithArrayTest.class); suite.addTestSuite(M2NTest.class); suite.addTestSuite(ObjectImageTest.class); - // suite.addTestSuite(InheritanceMultipleTableTest.class); + suite.addTestSuite(InheritanceMultipleTableTest.class); return suite; } } 1.1.2.3 +100 -3 db-ojb/src/test/org/apache/ojb/odmg/InheritanceMultipleTableTest.java Index: InheritanceMultipleTableTest.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/InheritanceMultipleTableTest.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- InheritanceMultipleTableTest.java 4 Dec 2004 14:01:08 -0000 1.1.2.2 +++ InheritanceMultipleTableTest.java 22 Mar 2005 15:04:54 -0000 1.1.2.3 @@ -10,7 +10,7 @@ import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; -import org.apache.ojb.broker.Identity; +import org.apache.ojb.broker.*; import org.apache.ojb.junit.ODMGTestCase; import org.odmg.OQLQuery; import org.odmg.Transaction; @@ -28,7 +28,7 @@ junit.textui.TestRunner.main(new String[]{InheritanceMultipleTableTest.class.getName()}); } - public void testQuery() throws Exception + public void testQuery_2() throws Exception { long timestamp = System.currentTimeMillis(); Long id_2 = new Long(timestamp); @@ -43,6 +43,80 @@ Employee em = new Employee(id_2, name + "_employee"); + List executives = new ArrayList(); + executives.add(ex_1); + executives.add(ex_2); + m_3.setExecutives(executives); + + TransactionExt tx = (TransactionExt) odmg.newTransaction(); + tx.begin(); + database.makePersistent(m_1); + database.makePersistent(m_2); + database.makePersistent(m_3); + database.makePersistent(ex_1); + database.makePersistent(ex_2); + database.makePersistent(em); + tx.commit(); + + tx.begin(); + tx.getBroker().clearCache(); + tx.commit(); + + OQLQuery query = odmg.newOQLQuery(); + query.create("select objects from " + Employee.class.getName() + " where name like $1"); + query.bind(name + "%"); + List newEmployees = new ArrayList((Collection) query.execute()); + assertEquals(6, newEmployees.size()); + int countEmployee = 0; + int countExecutive = 0; + int countManager = 0; + for(int i = 0; i < newEmployees.size(); i++) + { + Object o = newEmployees.get(i); + if(o instanceof Employee) + { + ++countEmployee; + } + if(o instanceof Executive) + { + ++countExecutive; + } + if(o instanceof Manager) + { + ++countManager; + } + } + assertEquals(6, countEmployee); + /* + bug: + expect that the real classes will be populated + currently this does not happen, only objects of + type Employee will be returned. + */ + assertEquals(5, countExecutive); + assertEquals(3, countManager); + } + + public void testQuery_1() throws Exception + { + long timestamp = System.currentTimeMillis(); + Long id_2 = new Long(timestamp); + String name = "testInsert" + timestamp; + Manager m_1 = new Manager(id_2, name + "_manager_1"); + Manager m_2 = new Manager(id_2, name + "_manager_2"); + Manager m_3 = new Manager(id_2, name + "_manager_3"); + m_3.setDepartment("none"); + + Executive ex_1 = new Executive(id_2, name + "_executive", "department_1", null); + Executive ex_2 = new Executive(id_2, name + "_executive", "department_1", null); + + Employee em = new Employee(id_2, name + "_employee"); + + List executives = new ArrayList(); + executives.add(ex_1); + executives.add(ex_2); + m_3.setExecutives(executives); + TransactionExt tx = (TransactionExt) odmg.newTransaction(); tx.begin(); database.makePersistent(m_1); @@ -63,24 +137,47 @@ query.bind("none"); Collection result = (Collection) query.execute(); assertEquals(1, result.size()); + for(Iterator iterator = result.iterator(); iterator.hasNext();) + { + Object o = iterator.next(); + assertTrue(o instanceof Manager); + Manager temp = (Manager) o; + assertNotNull(temp.getExecutives()); + assertEquals(2, temp.getExecutives().size()); + } query = odmg.newOQLQuery(); query.create("select objects from " + Employee.class.getName() + " where name like $1"); query.bind(name + "%"); result = (Collection) query.execute(); assertEquals(6, result.size()); + for(Iterator iterator = result.iterator(); iterator.hasNext();) + { + Object o = iterator.next(); + assertTrue(o instanceof Employee); + } query = odmg.newOQLQuery(); query.create("select objects from " + Executive.class.getName() + " where name like $1"); query.bind(name + "%"); result = (Collection) query.execute(); assertEquals(5, result.size()); + for(Iterator iterator = result.iterator(); iterator.hasNext();) + { + Object o = iterator.next(); + assertTrue(o instanceof Executive); + } query = odmg.newOQLQuery(); query.create("select objects from " + Manager.class.getName() + " where name like $1"); query.bind(name + "%"); result = (Collection) query.execute(); assertEquals(3, result.size()); + for(Iterator iterator = result.iterator(); iterator.hasNext();) + { + Object o = iterator.next(); + assertTrue(o instanceof Manager); + } } public void testQueryWithSerializedObjects() throws Exception 1.3.2.1 +40 -35 db-ojb/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java Index: LockingMultithreadedTest.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/LockingMultithreadedTest.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- LockingMultithreadedTest.java 23 Jun 2004 12:26:58 -0000 1.3 +++ LockingMultithreadedTest.java 22 Mar 2005 15:04:54 -0000 1.3.2.1 @@ -1,7 +1,7 @@ package org.apache.ojb.odmg; +import org.apache.commons.lang.SystemUtils; import org.apache.ojb.broker.TestHelper; -import org.apache.ojb.broker.util.logging.LoggerFactory; import org.apache.ojb.junit.JUnitExtensions; import org.odmg.Database; import org.odmg.Implementation; @@ -21,6 +21,16 @@ private static int threadCount; private static Implementation odmg; private static Database db; + private final StringBuffer result = new StringBuffer(2000); + private static final String eol = SystemUtils.LINE_SEPARATOR; + // number of concurrent threads to run + private final int concurrentThreads = 10; + // number of updates each thread performs against the object + private final int objectUpdates = 30; + // max number of attemps to get a lock + private static final int maxAttempts = 50; + private static final int nearMax = (int) (maxAttempts * 0.75); + public static void main(String[] args) { @@ -56,38 +66,33 @@ LockObject targetObject = createLockObjectWithRef(); storeObject(targetObject); - // number of concurrent threads to run - int threads = 6; - // number of updates each thread performs against the object - int objectUpdates = 30; - - TestCaseRunnable tct [] = new TestCaseRunnable[threads]; - for (int i = 0; i < threads; i++) + TestCaseRunnable tct [] = new TestCaseRunnable[concurrentThreads]; + for (int i = 0; i < concurrentThreads; i++) { /* several threads try to lock the same object (shared object), the other threads lock deep copies of the shared object */ if (i % 2 == 0) - tct[i] = new LockHandle(targetObject, objectUpdates); + tct[i] = new LockHandle(targetObject); else - tct[i] = new LockHandle(targetObject.makeCopy(), objectUpdates); + tct[i] = new LockHandle(targetObject.makeCopy()); } // run test classes runTestCaseRunnables(tct); System.out.println("*** Result of multithreaded lock test ***"); - System.out.println(targetObject.getName()); - System.out.println(targetObject.getReference().getName()); + System.out.println(result.toString()); + //System.out.println(targetObject.getReference().getName()); } private LockObject createLockObjectWithRef() { int number = newThreadKey(); LockObject lo = new LockObject(); - lo.setName("mod by thread: " + number); + lo.setName("modified by thread: " + number); LockObjectRef lor = new LockObjectRef(); - lor.setName("mod by thread: " + number); + lor.setName("modified by thread: " + number); lo.setReference(lor); @@ -114,14 +119,13 @@ class LockHandle extends JUnitExtensions.MultiThreadedTestCase.TestCaseRunnable { - LockObject obj; + final LockObject obj; int threadNumber; - int objectUpdates = 30; + private int counter = 0; - public LockHandle(LockObject obj, int objectUpdates) + public LockHandle(LockObject obj) { super(); - this.objectUpdates = objectUpdates; this.obj = obj; } @@ -134,18 +138,16 @@ tx.begin(); updateObject(tx, obj); tx.commit(); + counter = 0; } } - private int counter = 0; - private static final int maxAttempts = 200; - private static final int nearMax = (int) (maxAttempts * 0.9); - - private void updateObject(Transaction tx, LockObject obj) throws Exception + private void updateObject(final Transaction tx, final LockObject obj) throws Exception { try { tx.lock(obj, Transaction.WRITE); + tx.lock(obj.getReference(), Transaction.WRITE); updateName(obj); updateName(obj.getReference()); } @@ -155,47 +157,50 @@ { counter++; if (counter > nearMax) - LoggerFactory.getDefaultLogger().warn("LockingMultithreadedTest: thread " + System.out.println("LockingMultithreadedTest: thread " + threadNumber + " waits " + counter + " times to update object. Maximal attempts before fail are " + maxAttempts + ". This can be a result of low hardware."); - Thread.sleep(10); + try + { + Thread.sleep(30); + } + catch(InterruptedException e1) + { + } updateObject(tx, obj); } else { - LoggerFactory.getDefaultLogger().error("* Can't lock given object, will throw exception" + + System.out.println("* Can't lock given object, will throw exception" + " for thread number " + threadNumber + " *"); throw e; } } - finally - { - counter = 0; - } } private void updateName(LockObject obj) { - if (obj.getName().length() < 230) + if (obj.getName().length() < 100) { obj.setName(obj.getName() + "-" + threadNumber); } else { - obj.setName("carryOver, mod by thread: " + threadNumber); + result.append(eol).append(obj.getName()); + obj.setName("modified by thread: " + threadNumber); } } private void updateName(LockObjectRef obj) { - if (obj.getName().length() < 230) + if (obj.getName().length() < 100) { obj.setName(obj.getName() + "-" + threadNumber); } else { - obj.setName("carryOver, mod by thread: " + threadNumber); + obj.setName("modified by thread: " + threadNumber); } } } 1.14.2.2 +136 -178 db-ojb/src/test/org/apache/ojb/odmg/RITest.java Index: RITest.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/RITest.java,v retrieving revision 1.14.2.1 retrieving revision 1.14.2.2 diff -u -r1.14.2.1 -r1.14.2.2 --- RITest.java 18 Mar 2005 19:22:30 -0000 1.14.2.1 +++ RITest.java 22 Mar 2005 15:04:54 -0000 1.14.2.2 @@ -38,34 +38,27 @@ public void testStoreFKnoPK() throws Exception { long timestamp = System.currentTimeMillis(); - try - { - Transaction tx = odmg.newTransaction(); - tx.begin(); - Master master_1 = populatedMasterFKnoPK(tx, 5, timestamp); - Master master_2 = populatedMasterFKnoPK(tx, 5, timestamp); - - database.makePersistent(master_1); - database.makePersistent(master_2); - tx.commit(); - - // Check stored objects - OQLQuery query = odmg.newOQLQuery(); - query.create("select masters from " + Master.class.getName() + " where masterText like $1"); - query.bind("%" + timestamp); - List allMasters = (List) query.execute(); - assertEquals("We should found master objects", 2, allMasters.size()); - Master lookup_1 = (Master) allMasters.get(0); - - Collection col_in = lookup_1.getCollDetailFKinPK(); - Collection col_no = lookup_1.getCollDetailFKnoPK(); - assertEquals("Should found none " + DetailFKinPK.class.getName() + " objects", 0, col_in.size()); - assertEquals("Should found " + DetailFKnoPK.class.getName() + " objects", 5, col_no.size()); - } - finally - { - database.close(); - } + Transaction tx = odmg.newTransaction(); + tx.begin(); + Master master_1 = populatedMasterFKnoPK(tx, 5, timestamp); + Master master_2 = populatedMasterFKnoPK(tx, 5, timestamp); + + database.makePersistent(master_1); + database.makePersistent(master_2); + tx.commit(); + + // Check stored objects + OQLQuery query = odmg.newOQLQuery(); + query.create("select masters from " + Master.class.getName() + " where masterText like $1"); + query.bind("%" + timestamp); + List allMasters = (List) query.execute(); + assertEquals("We should found master objects", 2, allMasters.size()); + Master lookup_1 = (Master) allMasters.get(0); + + Collection col_in = lookup_1.getCollDetailFKinPK(); + Collection col_no = lookup_1.getCollDetailFKnoPK(); + assertEquals("Should found none " + DetailFKinPK.class.getName() + " objects", 0, col_in.size()); + assertEquals("Should found " + DetailFKnoPK.class.getName() + " objects", 5, col_no.size()); } /** @@ -75,34 +68,27 @@ public void testStoreFKinPK() throws Exception { final long timestamp = System.currentTimeMillis(); - try - { - Transaction tx = odmg.newTransaction(); - tx.begin(); + Transaction tx = odmg.newTransaction(); + tx.begin(); - Master master_1 = populatedMasterFKinPK(tx, 5, timestamp); - Master master_2 = populatedMasterFKinPK(tx, 5, timestamp); + Master master_1 = populatedMasterFKinPK(tx, 5, timestamp); + Master master_2 = populatedMasterFKinPK(tx, 5, timestamp); - database.makePersistent(master_1); - database.makePersistent(master_2); - tx.commit(); - - // Check stored objects - OQLQuery query = odmg.newOQLQuery(); - query.create("select masters from " + Master.class.getName() + " where masterText like $1"); - query.bind("%" + timestamp); - List allMasters = (List) query.execute(); - assertEquals("We should found master objects", 2, allMasters.size()); - Master lookup_1 = (Master) allMasters.get(0); - Collection col_in = lookup_1.getCollDetailFKinPK(); - Collection col_no = lookup_1.getCollDetailFKnoPK(); - assertEquals("Should found none " + DetailFKnoPK.class.getName() + " objects", 0, col_no.size()); - assertEquals("Should found " + DetailFKinPK.class.getName() + " objects", 5, col_in.size()); - } - finally - { - database.close(); - } + database.makePersistent(master_1); + database.makePersistent(master_2); + tx.commit(); + + // Check stored objects + OQLQuery query = odmg.newOQLQuery(); + query.create("select masters from " + Master.class.getName() + " where masterText like $1"); + query.bind("%" + timestamp); + List allMasters = (List) query.execute(); + assertEquals("We should found master objects", 2, allMasters.size()); + Master lookup_1 = (Master) allMasters.get(0); + Collection col_in = lookup_1.getCollDetailFKinPK(); + Collection col_no = lookup_1.getCollDetailFKnoPK(); + assertEquals("Should found none " + DetailFKnoPK.class.getName() + " objects", 0, col_no.size()); + assertEquals("Should found " + DetailFKinPK.class.getName() + " objects", 5, col_in.size()); } private Master populatedMasterFKnoPK(Transaction tx, int countDetailObjects, long timestamp) @@ -142,60 +128,51 @@ public void testDelete() throws Exception { long timestamp = System.currentTimeMillis(); - try - { - // 2. Get a list of all Masters - Transaction tx = odmg.newTransaction(); - tx.begin(); - // 1. Insert some objects into the database, some of them with - // details in DetailFKinPK, some of them in DetailFKnoPK - Master master_1 = populatedMasterFKinPK(tx, 7, timestamp); - Master master_2 = populatedMasterFKinPK(tx, 6, timestamp); - Master master_3 = populatedMasterFKnoPK(tx, 7, timestamp); - Master master_4 = populatedMasterFKnoPK(tx, 6, timestamp); - - tx.lock(master_1, Transaction.WRITE); - tx.lock(master_2, Transaction.WRITE); - tx.lock(master_3, Transaction.WRITE); - tx.lock(master_4, Transaction.WRITE); - tx.commit(); - - tx.begin(); - OQLQuery query = odmg.newOQLQuery(); - query.create("select masters from " + Master.class.getName() + " where masterText like $1"); - query.bind("%" + timestamp); - List allMasters = (List) query.execute(); - - // Iterator over all Master objects - Iterator it = allMasters.iterator(); - int counter = 0; - while (it.hasNext()) - { - ++counter; - Master aMaster = (Master) it.next(); - Iterator it2 = aMaster.collDetailFKinPK.iterator(); - while (it2.hasNext()) - database.deletePersistent(it2.next()); - it2 = aMaster.collDetailFKnoPK.iterator(); - while (it2.hasNext()) - database.deletePersistent(it2.next()); - database.deletePersistent(aMaster); - } - tx.commit(); - assertEquals("Wrong count of Master objects found", 4, counter); - - query = odmg.newOQLQuery(); - query.create("select masters from " + Master.class.getName() + " where masterText like $1"); - query.bind("%" + timestamp); - allMasters = (List) query.execute(); - assertEquals("Delete of Master objects failed", 0, allMasters.size()); - - database.close(); - } - finally - { + // 2. Get a list of all Masters + Transaction tx = odmg.newTransaction(); + tx.begin(); + // 1. Insert some objects into the database, some of them with + // details in DetailFKinPK, some of them in DetailFKnoPK + Master master_1 = populatedMasterFKinPK(tx, 7, timestamp); + Master master_2 = populatedMasterFKinPK(tx, 6, timestamp); + Master master_3 = populatedMasterFKnoPK(tx, 7, timestamp); + Master master_4 = populatedMasterFKnoPK(tx, 6, timestamp); + + tx.lock(master_1, Transaction.WRITE); + tx.lock(master_2, Transaction.WRITE); + tx.lock(master_3, Transaction.WRITE); + tx.lock(master_4, Transaction.WRITE); + tx.commit(); - } + tx.begin(); + OQLQuery query = odmg.newOQLQuery(); + query.create("select masters from " + Master.class.getName() + " where masterText like $1"); + query.bind("%" + timestamp); + List allMasters = (List) query.execute(); + + // Iterator over all Master objects + Iterator it = allMasters.iterator(); + int counter = 0; + while (it.hasNext()) + { + ++counter; + Master aMaster = (Master) it.next(); + Iterator it2 = aMaster.collDetailFKinPK.iterator(); + while (it2.hasNext()) + database.deletePersistent(it2.next()); + it2 = aMaster.collDetailFKnoPK.iterator(); + while (it2.hasNext()) + database.deletePersistent(it2.next()); + database.deletePersistent(aMaster); + } + tx.commit(); + assertEquals("Wrong count of Master objects found", 4, counter); + + query = odmg.newOQLQuery(); + query.create("select masters from " + Master.class.getName() + " where masterText like $1"); + query.bind("%" + timestamp); + allMasters = (List) query.execute(); + assertEquals("Delete of Master objects failed", 0, allMasters.size()); } public void testInsertAfterDelete() throws Exception @@ -209,77 +186,58 @@ obj2.setPk(contractPk); obj2.setContractValue2(2); - try - { - // 1. Insert object - Transaction tx = odmg.newTransaction(); - tx.begin(); - /* - arminw: - seems to have problems when within a tx a object - was stored/deleted. - Without obj1 test pass - TODO: fix this - */ - //database.makePersistent(obj1); - database.makePersistent(obj2); - //database.deletePersistent(obj1); - /* - thma: I checked this, and don't see a problem here. - obj1 and obj2 have the same Identity. Thus the - calls database.makePersistent(obj1); and database.makePersistent(obj2); - will only register one instance to the transaction. - The second call does not add a second instance, but just marks the - existing instance as dirty a second time. - So it's no wonder why after deletePersistent(obj1); no contract is found. - Works as designed. - The Lesson to learn: never let business objects have the same primary key values! - * */ - tx.commit(); - Collection result = getContract(contractPk, odmg); - assertEquals("We should found exact one contract", 1, result.size()); - obj2 = (Contract) result.iterator().next(); - if (obj2 == null) - { - fail("Contract not found"); - } - else if (obj2.getContractValue2() != 2) - { - fail("Wrong contract found"); - } - - // 2. Delete, then insert object with the same identity - tx.begin(); - database.deletePersistent(obj2); - database.makePersistent(obj1); - tx.commit(); - result = getContract(contractPk, odmg); - assertEquals("We should found exact one contract", 1, result.size()); - obj1 = (Contract) result.iterator().next(); - if (obj1 == null) - { - fail("Contract not found"); - } - else if (obj1.getContractValue2() != 1) - { - fail("Wrong contract found"); - } - - // 3. Delete - tx.begin(); - database.deletePersistent(obj1); - tx.commit(); - - result = getContract(contractPk, odmg); - if (result.size() > 0) - { - fail("Contract was not deleted"); - } - } - finally - { - database.close(); - } + + // 1. Insert object + Transaction tx = odmg.newTransaction(); + tx.begin(); + /* + arminw: + seems to have problems when within a tx a object + was stored/deleted. + Without obj1 test pass + TODO: fix this + */ + database.makePersistent(obj1); + database.deletePersistent(obj2); + database.makePersistent(obj1); + /* + thma: I checked this, and don't see a problem here. + obj1 and obj2 have the same Identity. Thus the + calls database.makePersistent(obj1); and database.makePersistent(obj2); + will only register one instance to the transaction. + The second call does not add a second instance, but just marks the + existing instance as dirty a second time. + So it's no wonder why after deletePersistent(obj1); no contract is found. + Works as designed. + The Lesson to learn: never let business objects have the same primary key values! + * */ + tx.commit(); + Collection result = getContract(contractPk, odmg); + assertEquals("We should found exact one contract", 1, result.size()); + Contract newObj = (Contract) result.iterator().next(); + assertNotNull("Object not found", newObj); + assertEquals(1, newObj.getContractValue2()); + + // 2. Delete, then insert object with the same identity + tx.begin(); + database.deletePersistent(newObj); + database.makePersistent(obj2); + tx.commit(); + assertEquals(2, obj2.getContractValue2()); + + result = getContract(contractPk, odmg); + assertEquals("We should found exact one contract", 1, result.size()); + newObj = (Contract) result.iterator().next(); + assertNotNull("Object not found", newObj); + assertEquals(2, newObj.getContractValue2()); + + // 3. Delete + tx.begin(); + database.deletePersistent(obj1); + tx.commit(); + + result = getContract(contractPk, odmg); + assertEquals(0, result.size()); } private Collection getContract(String pk, Implementation odmg) --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org