db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r422240 [1/2] - in /db/ojb/trunk/src/test/org/apache/ojb: broker/ broker/sequence/ broker/sqlcount/ compare/ junit/ odmg/
Date Sat, 15 Jul 2006 14:49:28 GMT
Author: arminw
Date: Sat Jul 15 07:49:27 2006
New Revision: 422240

URL: http://svn.apache.org/viewvc?rev=422240&view=rev
Log:
merge trunk with 1.0.x

Modified:
    db/ojb/trunk/src/test/org/apache/ojb/broker/PBRollbackTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/PathTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/ProductGroupWithRemovalAwareCollection.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/ReferenceTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/RsIteratorTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/StockDetailNested.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/AutoIncrementTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java
    db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
    db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java
    db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceBaseTest.java
    db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java
    db/ojb/trunk/src/test/org/apache/ojb/compare/PerformancePBTest.java
    db/ojb/trunk/src/test/org/apache/ojb/junit/ODMGTestCase.java
    db/ojb/trunk/src/test/org/apache/ojb/junit/OJBTestCase.java
    db/ojb/trunk/src/test/org/apache/ojb/odmg/BatchModeTest.java
    db/ojb/trunk/src/test/org/apache/ojb/odmg/BidirectionalAssociationTest.java
    db/ojb/trunk/src/test/org/apache/ojb/odmg/CircularTest.java
    db/ojb/trunk/src/test/org/apache/ojb/odmg/CollectionsTest.java

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/PBRollbackTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/PBRollbackTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/PBRollbackTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/PBRollbackTest.java Sat Jul 15 07:49:27 2006
@@ -55,14 +55,15 @@
 
     public void testUserCommitClearCache() throws Exception
     {
+        // make sure to disable use of batch statements
+        broker.serviceBatchManager().setBatchMode(false);
+
         Collection projects = getNewProjects(10);
         storeObjects(broker, projects);
         Criteria c = new Criteria();
         Query q = QueryFactory.newQuery(Project.class, c);
         int beforeCommit = broker.getCount(q);
 
-        // Don't use batch statements
-        broker.serviceBatchManager().setBatchMode(false);
         broker.beginTransaction();
         broker.clearCache();
         storeObjects(broker, getNewProjects(10));
@@ -91,14 +92,15 @@
 
     public void testUserCommit() throws Exception
     {
+        // make sure to disable use of batch statements
+        broker.serviceBatchManager().setBatchMode(false);
+
         Collection projects = getNewProjects(10);
         storeObjects(broker, projects);
         Criteria c = new Criteria();
         Query q = QueryFactory.newQuery(Project.class, c);
         int beforeCommit = broker.getCount(q);
 
-        // Don't use batch statements
-        broker.serviceBatchManager().setBatchMode(false);
         broker.beginTransaction();
         storeObjects(broker, getNewProjects(10));
         int whileTransaction = broker.getCount(q);
@@ -126,6 +128,9 @@
 
     public void testUserRollbackClearCache() throws Exception
     {
+        // make sure to disable use of batch statements
+        broker.serviceBatchManager().setBatchMode(false);
+
         Collection projects = getNewProjects(10);
         storeObjects(broker, projects);
         Criteria c = new Criteria();
@@ -163,6 +168,9 @@
 
     public void testUserRollback() throws Exception
     {
+        // make sure to disable use of batch statements
+        broker.serviceBatchManager().setBatchMode(false);
+
         Collection projects = getNewProjects(10);
         storeObjects(broker, projects);
         Criteria c = new Criteria();
@@ -252,14 +260,16 @@
         Query q;
         int beforeRollback;
 
-            broker.beginTransaction();
-            storeObjects(broker, projects);
-            broker.commitTransaction();
+        broker.beginTransaction();
+        storeObjects(broker, projects);
+        broker.commitTransaction();
 
-            Criteria c = new Criteria();
-            q = QueryFactory.newQuery(Project.class, c);
-            beforeRollback = broker.getCount(q);
+        Criteria c = new Criteria();
+        q = QueryFactory.newQuery(Project.class, c);
+        beforeRollback = broker.getCount(q);
 
+        // close current used instance
+        broker.close();
         broker = ojb.getDefaultConfiguration().createPersistenceBroker();
         try
         {

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/PathTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/PathTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/PathTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/PathTest.java Sat Jul 15 07:49:27 2006
@@ -108,13 +108,13 @@
         {
             A a = new A(A_OFFSET + A_OFFSET * ia);
             broker.store(a);
-            output.append(eol +"A - " + a.getAAttrib());
+            output.append(eol +"A - " + a.getaAttrib());
             for (int ib = 0; ib < NUM_B_PER_A; ib++)
             {
                 B b = new B(A_OFFSET + B_OFFSET * ib);
                 b.setA(a);
                 broker.store(b);
-                output.append(eol +"\tB - " + b.getBAttrib());
+                output.append(eol +"\tB - " + b.getbAttrib());
                 for (int ic = 0; ic < NUM_C_PER_B; ic++)
                 {
                     C c = new C(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic);
@@ -125,8 +125,8 @@
                         c.setD(d);
                         broker.store(d);
                         broker.store(c);
-                        output.append(eol +"\t\tC - " + c.getCAttrib());
-                        output.append(eol +"\t\t\tD - " + d.getDAttrib());
+                        output.append(eol +"\t\tC - " + c.getcAttrib());
+                        output.append(eol +"\t\t\tD - " + d.getdAttrib());
                     }
                 }
                 for (int ic = 0; ic < NUM_C1_PER_B; ic++)
@@ -137,11 +137,11 @@
                     {
                         D d = new D(A_OFFSET + B_OFFSET * ib + C_OFFSET * ic + D_OFFSET * id);
                         c1.setD(d);
-                        c1.setC1Attrib(c1.getCAttrib() + 1);
+                        c1.setC1Attrib(c1.getcAttrib() + 1);
                         broker.store(d);
                         broker.store(c1);
                         output.append(eol +"\t\tC1 - " + c1.getC1Attrib());
-                        output.append(eol +"\t\t\tD - " + d.getDAttrib());
+                        output.append(eol +"\t\t\tD - " + d.getdAttrib());
                     }
                 }
             }
@@ -246,7 +246,7 @@
 			while (itr.hasNext())
 			{
 				B b = (B) itr.next();
-				output.append(eol +"Found B:  " + b.getId() + " " + b.getBAttrib());
+				output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -280,7 +280,7 @@
 			while (itr.hasNext())
 			{
 				A a = (A) itr.next();
-				output.append(eol +"Found A:  " + a.getId() + " " + a.getAAttrib());
+				output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -315,7 +315,7 @@
 			while (itr.hasNext())
 			{
 				B b = (B) itr.next();
-				output.append(eol +"Found B:  " + b.getId() + " " + b.getBAttrib());
+				output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -356,7 +356,7 @@
 			while (itr.hasNext())
 			{
 				B b = (B) itr.next();
-				output.append(eol +"Found B:  " + b.getId() + " " + b.getBAttrib());
+				output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -397,7 +397,7 @@
 			while (itr.hasNext())
 			{
 				A a = (A) itr.next();
-				output.append(eol +"Found A:  " + a.getId() + " " + a.getAAttrib());
+				output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -439,7 +439,7 @@
             while (itr.hasNext())
             {
                 B b = (B) itr.next();
-                output.append(eol +"Found B:  " + b.getId() + " " + b.getBAttrib());
+                output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
             }
         }
         catch (Throwable t)
@@ -483,7 +483,7 @@
 			while (itr.hasNext())
 			{
 				B b = (B) itr.next();
-				output.append(eol +"Found B:  " + b.getId() + " " + b.getBAttrib());
+				output.append(eol +"Found B:  " + b.getId() + " " + b.getbAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -525,7 +525,7 @@
 			while (itr.hasNext())
 			{
 				A a = (A) itr.next();
-				output.append(eol +"Found A:  " + a.getId() + " " + a.getAAttrib());
+				output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -574,7 +574,7 @@
 			while (itr.hasNext())
 			{
 				A a = (A) itr.next();
-				output.append(eol +"Found A:  " + a.getId() + " " + a.getAAttrib());
+				output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 			}
 		}
 		catch (Throwable t)
@@ -606,7 +606,7 @@
 		while (itr.hasNext())
 		{
 			A a = (A) itr.next();
-			output.append(eol +"Found A:  " + a.getId() + " " + a.getAAttrib());
+			output.append(eol +"Found A:  " + a.getId() + " " + a.getaAttrib());
 		}
     }
 	
@@ -628,75 +628,35 @@
             this.bSet = new ArrayList();
         }
 
-        // make javabeans conform
-        public int getaAttrib()
-        {
-            return aAttrib;
-        }
-        // make javabeans conform
-        public Collection getbSet()
-        {
-            return bSet;
-        }
-        // make javabeans conform
-        public void setbSet(Collection bSet)
-        {
-            this.bSet = bSet;
-        }
-        // make javabeans conform
-        public void setaAttrib(int aAttrib)
-        {
-            this.aAttrib = aAttrib;
-        }
-
-        /**
-         * @return
-         */
-        public int getAAttrib()
+        public long getId()
         {
-            return aAttrib;
+            return id;
         }
 
-        /**
-         * @return
-         */
-        public Collection getBSet()
+        public void setId(long id)
         {
-            return bSet;
+            this.id = id;
         }
 
-        /**
-         * @return
-         */
-        public long getId()
+        public int getaAttrib()
         {
-            return id;
+            return aAttrib;
         }
 
-        /**
-         * @param i
-         */
-        public void setAAttrib(int i)
+        public void setaAttrib(int aAttrib)
         {
-            aAttrib = i;
+            this.aAttrib = aAttrib;
         }
 
-        /**
-         * @param collection
-         */
-        public void setBSet(Collection collection)
+        public Collection getbSet()
         {
-            bSet = collection;
+            return bSet;
         }
 
-        /**
-         * @param l
-         */
-        public void setId(long l)
+        public void setbSet(Collection bSet)
         {
-            id = l;
+            this.bSet = bSet;
         }
-
     }
 
     public static class B
@@ -717,6 +677,16 @@
             this.cSet = new ArrayList();
         }
 
+        public long getId()
+        {
+            return id;
+        }
+
+        public void setId(long id)
+        {
+            this.id = id;
+        }
+
         public long getaId()
         {
             return aId;
@@ -737,81 +707,25 @@
             this.bAttrib = bAttrib;
         }
 
-        public Collection getcSet()
+       public A getA()
         {
-            return cSet;
-        }
-
-        public void setcSet(Collection cSet)
-        {
-            this.cSet = cSet;
+            return a;
         }
 
-        /**
-         * @return
-         */
-        public int getBAttrib()
+        public void setA(A a)
         {
-            return bAttrib;
+            this.a = a;
         }
 
-        /**
-         * @return
-         */
-        public Collection getCSet()
+        public Collection getcSet()
         {
             return cSet;
         }
 
-        /**
-         * @return
-         */
-        public long getId()
-        {
-            return id;
-        }
-
-        /**
-         * @param i
-         */
-        public void setBAttrib(int i)
-        {
-            bAttrib = i;
-        }
-
-        /**
-         * @param collection
-         */
-        public void setCSet(Collection collection)
-        {
-            cSet = collection;
-        }
-
-        /**
-         * @param l
-         */
-        public void setId(long l)
-        {
-            id = l;
-        }
-
-        /**
-         * @return
-         */
-        public A getA()
-        {
-            return a;
-        }
-
-        /**
-         * @param a
-         */
-        public void setA(A a)
+        public void setcSet(Collection cSet)
         {
-            this.a = a;
-            a.getBSet().add(this);
+            this.cSet = cSet;
         }
-
     }
 
     public static class C
@@ -832,112 +746,71 @@
             this.cAttrib = cAttrib;
         }
 
-        public long getbId()
-        {
-            return bId;
-        }
-
-        public void setbId(long bId)
+        public long getId()
         {
-            this.bId = bId;
+            return id;
         }
 
-        public long getdId()
+        public void setId(long id)
         {
-            return dId;
+            this.id = id;
         }
 
-        public void setdId(long dId)
+        public long getbId()
         {
-            this.dId = dId;
+            return bId;
         }
 
-        public int getcAttrib()
+        public void setbId(long bId)
         {
-            return cAttrib;
+            this.bId = bId;
         }
 
-        public void setcAttrib(int cAttrib)
+        public B getB()
         {
-            this.cAttrib = cAttrib;
+            return b;
         }
 
-        /**
-         * @return
-         */
-        public int getCAttrib()
+        public void setB(B b)
         {
-            return cAttrib;
+            this.b = b;
         }
 
-        /**
-         * @return
-         */
-        public D getD()
+        public long getdId()
         {
-            return d;
+            return dId;
         }
 
-        /**
-         * @return
-         */
-        public long getId()
+        public void setdId(long dId)
         {
-            return id;
+            this.dId = dId;
         }
 
-        /**
-         * @param i
-         */
-        public void setCAttrib(int i)
+        public D getD()
         {
-            cAttrib = i;
+            return d;
         }
 
-        /**
-         *
-         */
         public void setD(D d)
         {
             this.d = d;
         }
 
-        /**
-         * @param l
-         */
-        public void setId(long l)
-        {
-            id = l;
-        }
-
-        /**
-         * @return
-         */
-        public B getB()
+        public int getcAttrib()
         {
-            return b;
+            return cAttrib;
         }
 
-        /**
-         * @param b
-         */
-        public void setB(B b)
+        public void setcAttrib(int cAttrib)
         {
-            this.b = b;
-            b.getCSet().add(this);
+            this.cAttrib = cAttrib;
         }
-
     }
 
     public static class C1 extends C
     {
-
         private int c1Attrib;
 
-        /**
-         *
-         */
-
         public C1()
         {
         }
@@ -947,22 +820,15 @@
             super(cAttrib);
         }
 
-        /**
-         * @return
-         */
         public int getC1Attrib()
         {
             return c1Attrib;
         }
 
-        /**
-         * @param i
-         */
-        public void setC1Attrib(int i)
+        public void setC1Attrib(int c1Attrib)
         {
-            c1Attrib = i;
+            this.c1Attrib = c1Attrib;
         }
-
     }
 
     public static class D
@@ -979,38 +845,25 @@
             this.dAttrib = dAttrib;
         }
 
-        /**
-         * @return
-         */
-        public int getDAttrib()
-        {
-            return dAttrib;
-        }
-
-        /**
-         * @return
-         */
         public long getId()
         {
             return id;
         }
 
-        /**
-         * @param i
-         */
-        public void setDAttrib(int i)
+        public void setId(long id)
         {
-            dAttrib = i;
+            this.id = id;
         }
 
-        /**
-         * @param l
-         */
-        public void setId(long l)
+        public int getdAttrib()
         {
-            id = l;
+            return dAttrib;
         }
 
+        public void setdAttrib(int dAttrib)
+        {
+            this.dAttrib = dAttrib;
+        }
     }
 
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java Sat Jul 15 07:49:27 2006
@@ -19,6 +19,7 @@
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.query.ReportQueryByCriteria;
+import org.apache.ojb.broker.util.ObjectModification;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -140,14 +141,16 @@
      public void testReadUncommitedDataWithinSamePB() throws Exception
     {
         String name = "testReadUncommitedDataWithinSamePB" + System.currentTimeMillis();
-        ObjectRepository.Component comp = new ObjectRepository.Component();
-        comp.setName(name);
 
         // make sure not to use batch mode
         broker.serviceBatchManager().setBatchMode(false);
+
+        ObjectRepository.Component comp = new ObjectRepository.Component();
+        comp.setName(name);
+
         broker.beginTransaction();
         // store data
-        broker.store(comp, OJB.INSERT);
+        broker.store(comp, ObjectModification.INSERT);
         Query query = QueryFactory.newQuery(ObjectRepository.Component.class, (Criteria) null);
         // now we try to read the uncommitted data
         Collection all = broker.getCollectionByQuery(query);
@@ -427,9 +430,9 @@
     /**
      * test the the PB deleteByQuery() method.
      */
-    public void testDeleteByQuery1() throws Exception
+    public void testDeleteByQuery() throws Exception
     {
-        String name = "Funny_testDelete1_" + System.currentTimeMillis();
+        String name = "Funny_testDelete_" + System.currentTimeMillis();
         ProductGroup pg;
         pg = new ProductGroup();
         pg.setGroupName(name);
@@ -438,6 +441,9 @@
         broker.store(pg);
         broker.commitTransaction();
 
+        // make sure not to use batch mode
+        broker.serviceBatchManager().setBatchMode(false);
+
         Article a = createArticle(pg, name);
         Article b = createArticle(pg, name);
         CdArticle c = createCdArticle(pg, name);
@@ -613,19 +619,19 @@
 
         // test retrieval by Identity
         Criteria crit = new Criteria();
-        crit.addEqualTo("id", new Integer(a1.id));
+        crit.addEqualTo("id", new Integer(a1.getId()));
         q = QueryFactory.newQuery(ObjectRepository.AB.class, crit);
         ab = (ObjectRepository.AB) broker.getObjectByQuery(q);
 
-        assertEquals(ObjectRepository.A.class.getName(), ab.getConcreteClass());
+        assertEquals(ObjectRepository.A.class.getName(), ab.getOjbConcreteClass());
         assertEquals(ObjectRepository.A.class, ab.getClass());
 
         crit = new Criteria();
-        crit.addEqualTo("id", new Integer(b1.id));
+        crit.addEqualTo("id", new Integer(b1.getId()));
         q = QueryFactory.newQuery(ObjectRepository.AB.class, crit);
         ab = (ObjectRepository.AB) broker.getObjectByQuery(q);
 
-        assertEquals(ObjectRepository.B.class.getName(), ab.getConcreteClass());
+        assertEquals(ObjectRepository.B.class.getName(), ab.getOjbConcreteClass());
         assertEquals(ObjectRepository.B.class, ab.getClass());
 
         // test retrieval of collections
@@ -869,12 +875,8 @@
         broker.commitTransaction();
 
         ObjectRepository.C c1 = new ObjectRepository.C();
-        // Identity iC1 = new Identity(c1, broker);
         ObjectRepository.C c2 = new ObjectRepository.C();
-        // Identity iC2 = new Identity(c2, broker);
-
         ObjectRepository.D d1 = new ObjectRepository.D();
-        // Identity iD1 = new Identity(d1, broker);
 
         broker.beginTransaction();
         broker.store(c1);
@@ -886,25 +888,25 @@
 
         // test retrieval by Identity
         crit = new Criteria();
-        crit.addEqualTo("id", new Integer(c1.id));
+        crit.addEqualTo("id", new Integer(c1.getId()));
         q = QueryFactory.newQuery(ObjectRepository.C.class, crit);
         candidate = (ObjectRepository.C) broker.getObjectByQuery(q);
 
-        assertEquals(ObjectRepository.C.class.getName(), candidate.getConcreteClass());
+        assertEquals(ObjectRepository.C.class.getName(), candidate.getOjbConcreteClass());
         assertEquals(ObjectRepository.C.class, candidate.getClass());
 
         crit = new Criteria();
-        crit.addEqualTo("id", new Integer(d1.id));
+        crit.addEqualTo("id", new Integer(d1.getId()));
         q = QueryFactory.newQuery(ObjectRepository.C.class, crit);
         candidate = (ObjectRepository.C) broker.getObjectByQuery(q);
-        assertEquals(ObjectRepository.D.class.getName(), candidate.getConcreteClass());
+        assertEquals(ObjectRepository.D.class.getName(), candidate.getOjbConcreteClass());
         assertEquals(ObjectRepository.D.class, candidate.getClass());
 
         crit = new Criteria();
-        crit.addEqualTo("id", new Integer(d1.id));
+        crit.addEqualTo("id", new Integer(d1.getId()));
         q = QueryFactory.newQuery(ObjectRepository.D.class, crit);
         candidate = (ObjectRepository.D) broker.getObjectByQuery(q);
-        assertEquals(ObjectRepository.D.class.getName(), candidate.getConcreteClass());
+        assertEquals(ObjectRepository.D.class.getName(), candidate.getOjbConcreteClass());
         assertEquals(ObjectRepository.D.class, candidate.getClass());
 
         // test retrieval of collections
@@ -1200,7 +1202,6 @@
 
     public void testSorting() throws Exception
     {
-        // 1. ensure there are 0 items matching the query
         String name = "testSorting_" + System.currentTimeMillis();
         Criteria criteria = new Criteria();
         criteria.addEqualTo("articleName", name);
@@ -1236,7 +1237,7 @@
         String name = "testSortedCollectionAttribute_" + System.currentTimeMillis();
         ProductGroup samplePG = new ProductGroup();
         Article a1_ = createArticle(samplePG, name);
-        createArticle(samplePG, name);
+        Article a2_ = createArticle(samplePG, name);
         Article a3_ = createArticle(samplePG, name);
         // auto insert of referenced Article is enabled
         // and aX_ was added to PG
@@ -1561,12 +1562,12 @@
     public void testUpdateWithModification() throws Exception
     {
         String name = "testUpdateWithModification_" + System.currentTimeMillis();
-        assertFalse("should not be marked for update yet", OJB.INSERT.needsUpdate());
-        assertFalse("should not be marked for insert", OJB.UPDATE.needsInsert());
+        assertFalse("should not be marked for update yet", ObjectModification.INSERT.needsUpdate());
+        assertFalse("should not be marked for insert", ObjectModification.UPDATE.needsInsert());
         Article a = createArticle(null, name);
 
         broker.beginTransaction();
-        broker.store(a, OJB.INSERT);
+        broker.store(a, ObjectModification.INSERT);
         broker.commitTransaction();
 
         Article b = readArticleByIdentity(a.getArticleId());
@@ -1577,7 +1578,7 @@
         String newname = "TESTUPDATE_" + name;
         b.setArticleName(newname);
         broker.beginTransaction();
-        broker.store(b, OJB.UPDATE);
+        broker.store(b, ObjectModification.UPDATE);
         broker.commitTransaction();
 
         b = null;
@@ -1609,6 +1610,9 @@
 
     public void testChangeFieldsWhileStoringObject()
     {
+        // guarantee that batch statements are disabled
+        broker.serviceBatchManager().setBatchMode(false);
+
         long timestamp = System.currentTimeMillis();
 
         broker.beginTransaction();

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/ProductGroupWithRemovalAwareCollection.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/ProductGroupWithRemovalAwareCollection.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/ProductGroupWithRemovalAwareCollection.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/ProductGroupWithRemovalAwareCollection.java Sat Jul 15 07:49:27 2006
@@ -11,6 +11,7 @@
  */
 public class ProductGroupWithRemovalAwareCollection implements Serializable
 {
+
     /** collection containing all articles of a given product group*/
     private RemovalAwareList allArticlesInGroup;
 
@@ -20,6 +21,9 @@
     /** the name of a group*/
     private String groupName;
 
+    public ProductGroupWithRemovalAwareCollection()
+    {
+    }
 
     /** return group id*/
     public int getId()
@@ -33,12 +37,8 @@
         return groupName;
     }
 
-    public ProductGroupWithRemovalAwareCollection()
-    {
-    }
-
     /** return List of all Articles in productgroup*/
-    public RemovalAwareList getAllArticles()
+    public RemovalAwareList getAllArticlesInGroup()
     {
         return allArticlesInGroup;
     }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/ReferenceTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/ReferenceTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/ReferenceTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/ReferenceTest.java Sat Jul 15 07:49:27 2006
@@ -17,7 +17,6 @@
 /**
  * Test case for checking the management of references.
  *
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  * @version $Id$
  */
 public class ReferenceTest extends PBTestCase
@@ -709,6 +708,7 @@
 
         broker.beginTransaction();
         broker.store(a);
+        broker.store(b);
         broker.commitTransaction();
 
         broker.clearCache();

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/RsIteratorTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/RsIteratorTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/RsIteratorTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/RsIteratorTest.java Sat Jul 15 07:49:27 2006
@@ -2,12 +2,12 @@
 
 import java.util.Iterator;
 
-import org.apache.ojb.broker.accesslayer.RsIterator;
 import org.apache.ojb.broker.accesslayer.OJBIterator;
+import org.apache.ojb.broker.accesslayer.RsIterator;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
-import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.util.ObjectModification;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -29,6 +29,82 @@
         super(name);
     }
 
+    public void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    /**
+     * This test provoke resource cleanup by GC, which remove
+     * listener objects.
+     */
+    public void testMassReadWithIterator()
+    {
+        long time = System.currentTimeMillis();
+        String name = "testMassReadWithIterator_" + time + "_";
+
+        for(int k = 0; k < 10 ; k++)
+        {
+            broker.beginTransaction();
+            for(int i = 0; i < 500; i++)
+            {
+                ObjectRepository.Component r = new ObjectRepository.Component();
+                r.setName(name + i);
+                broker.store(r);
+            }
+            broker.commitTransaction();
+
+            //long timer = System.currentTimeMillis();
+            broker.beginTransaction();
+            for(int i = 0; i < 400; i++)
+            {
+                Query q = QueryFactory.newQuery(ObjectRepository.Component.class, new Criteria().addLike("name", name));
+                Iterator result = broker.getIteratorByQuery(q);
+                if(result.hasNext())
+                {
+                    ObjectRepository.Component o = (ObjectRepository.Component) result.next();
+                    o.setName(o.getName() + "_update");
+                    broker.store(o, ObjectModification.UPDATE);
+                }
+            }
+            broker.commitTransaction();
+
+            broker.beginTransaction();
+            for(int i = 0; i < 400; i++)
+            {
+                PersistenceBroker tmp = PersistenceBrokerFactory.defaultPersistenceBroker();
+                Iterator result;
+                try
+                {
+                    Query q = QueryFactory.newQuery(ObjectRepository.Component.class, new Criteria().addLike("name", name));
+                    result = tmp.getIteratorByQuery(q);
+                    if(result.hasNext())
+                    {
+                        ObjectRepository.Component o = (ObjectRepository.Component) result.next();
+                        o.setName(o.getName() + "_update");
+                        broker.store(o, ObjectModification.UPDATE);
+                    }
+                }
+                finally
+                {
+                    if(tmp != null && !tmp.isClosed()) tmp.close();
+                }
+            }
+            broker.commitTransaction();
+            //System.out.println("time: " + (System.currentTimeMillis() - timer));
+
+            broker.beginTransaction();
+            Query q = QueryFactory.newQuery(ObjectRepository.Component.class, new Criteria().addLike("name", name + "%"));
+            broker.deleteByQuery(q);
+            broker.commitTransaction();
+        }
+    }
+
     public void testRsIterator() throws Exception
     {
         String name = "testRsIterator_" + System.currentTimeMillis();
@@ -261,7 +337,7 @@
 
         try
         {
-            ((RsIterator) it).relative(1);
+            it.relative(1);
         }
         catch(RsIterator.ResourceClosedException e)
         {
@@ -302,12 +378,7 @@
         Query query = QueryFactory.newQuery(Person.class, criteria);
         // Run the query.
         Person person = (Person) broker.getObjectByQuery(query);
-        // The previous call may or may not return a 'real' Person
-        // object.  What it returns is not important.  The test here
-        // is whether or not this call raises an error or not.  When
-        // this code runs using hsqldb, it works fine.  However, when
-        // this code runs against Oracle, it fails with a null pointer
-        // exception.
+        assertNotNull("Person with id 1 was not found", person);
     }
-}
 
+}

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/StockDetailNested.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/StockDetailNested.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/StockDetailNested.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/StockDetailNested.java Sat Jul 15 07:49:27 2006
@@ -8,7 +8,7 @@
  */
 public class StockDetailNested implements java.io.Serializable
 {
-    private boolean isSelloutArticle;
+    private boolean selloutArticle;
     private int minimumStock;
     private int orderedUnits;
     private int stock;
@@ -20,12 +20,12 @@
 
     public boolean isSelloutArticle()
     {
-        return isSelloutArticle;
+        return selloutArticle;
     }
 
     public void setSelloutArticle(boolean selloutArticle)
     {
-        isSelloutArticle = selloutArticle;
+        this.selloutArticle = selloutArticle;
     }
 
     public int getMinimumStock()

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/AutoIncrementTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/AutoIncrementTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/AutoIncrementTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/AutoIncrementTest.java Sat Jul 15 07:49:27 2006
@@ -34,7 +34,7 @@
         assertTrue(obj_2.getIntegerId().intValue() > 0);
         assertTrue((new Integer(obj_2.getStr())).intValue() > 0);
 
-        Identity oid = new Identity(obj_2, broker);
+        Identity oid = broker.serviceIdentity().buildIdentity(obj_2);
         IncrementObject newObj_2 = (IncrementObject) broker.getObjectByIdentity(oid);
         broker.beginTransaction();
         broker.store(obj_1);

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java Sat Jul 15 07:49:27 2006
@@ -23,7 +23,6 @@
 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;
@@ -214,11 +213,7 @@
 
     public void tearDown() throws Exception
     {
-        if (skipTest())
-        {
-            super.tearDown();
-            return;
-        }
+        if (skipTest()) return;
 
         Connection con;
         Statement stmt;
@@ -256,17 +251,24 @@
         }
         finally
         {
-            if (pb != null) pb.close();
+            if (pb != null)
+            {
+                pb.clearCache();
+                pb.close();
+            }
         }
 
-
+        // close the broker instance, because we want to release all used instance
+        if(broker != null) broker.close();
+        
+        persistenceConf.releaseAllInstances();
+        broker = persistenceConf.createPersistenceBroker();
         SequenceDescriptor sd = ojb.getMetadataManager().connectionRepository().
                 getDescriptor(broker.getPBKey()).getSequenceDescriptor();
         assertEquals(oldSequenceManager, sd.getSequenceManagerClass());
-
         // close the broker instance, because we want to release all used instance
         if(broker != null) broker.close();
-        persistenceConf.releaseAllInstances();
+
         super.tearDown();
     }
 
@@ -452,8 +454,8 @@
         assertTrue(ref_3.getRefIdentifier().longValue() > 0);
 
         // get Identity objects
-        Identity oid_1 = new Identity(obj_1, broker);
-        Identity oid_2 = new Identity(obj_2, broker);
+        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();
@@ -690,6 +692,7 @@
         obj_2.setName(name+"_update");
         tx.commit();
 
+        broker.close();
         broker = ojb.getDefaultConfiguration().createPersistenceBroker();
         obj_2 = (MainObject) broker.getObjectByIdentity(oid_2);
         broker.close();
@@ -806,8 +809,8 @@
         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 = new Identity(obj_1, broker);
-        Identity oid_2 = new Identity(obj_2, broker);
+        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();
@@ -986,7 +989,7 @@
         broker.beginTransaction();
         broker.store(obj_1);
         broker.commitTransaction();
-        Identity oid_1 = new Identity(obj_1, broker);
+        Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
 
         MainObject result = (MainObject) broker.getObjectByIdentity(oid_1);
         assertNotNull(result);
@@ -1062,7 +1065,8 @@
         broker.store(obj_1);
         // System.out.println("8. "+obj_1);
         broker.commitTransaction();
-        Identity oid_1 = new Identity(obj_1, broker);
+        Identity oid_1 = broker.serviceIdentity().buildIdentity(obj_1);
+        //Identity oid_1 = new Identity(obj_1, broker);
 
         MainObject result = (MainObject) broker.getObjectByIdentity(oid_1);
         assertNotNull(result);
@@ -1200,8 +1204,9 @@
         public String toString()
         {
             return new ToStringBuilder(this).append("identifier", identifier).append("name", name)
-                    .append("allReferences", allReferences != null ? allReferences.toString() : "null")
-                    .append("singleReference", singleReference.getClass().toString()).toString();
+                    .append("allReferences", (allReferences != null ? allReferences.toString() : "null"))
+                    .append("singleReference", (singleReference != null ? singleReference.getClass().toString(): "null"))
+                    .toString();
         }
     }
 
@@ -1234,6 +1239,16 @@
             // id = new Long((long)(Math.random() * Integer.MAX_VALUE));
         }
 
+        public String getOjbConcreteClass()
+        {
+            return ojbConcreteClass;
+        }
+
+        public void setOjbConcreteClass(String ojbConcreteClass)
+        {
+            this.ojbConcreteClass = ojbConcreteClass;
+        }
+
         public MainObjectIF getMainObject()
         {
             return mainObject;
@@ -1301,6 +1316,16 @@
             this();
             this.refIdentifier = refIdentifier;
             this.refName = refName;
+        }
+
+        public String getOjbConcreteClass()
+        {
+            return ojbConcreteClass;
+        }
+
+        public void setOjbConcreteClass(String ojbConcreteClass)
+        {
+            this.ojbConcreteClass = ojbConcreteClass;
         }
 
         public Long getRefIdentifier()

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sequence/SequenceManagerTest.java Sat Jul 15 07:49:27 2006
@@ -93,7 +93,7 @@
     protected void setUp() throws Exception
     {
         super.setUp();
-                }
+    }
 
     protected void tearDown() throws Exception
     {
@@ -507,6 +507,7 @@
         assertTrue(id2 > id1);
         assertTrue("If the sequence manger implementation does not support continuous key generation" +
                 " per PB instance, you could ignore this failure", (id2 - id1) == 1);
+        pb.close();
     }
 
     /**
@@ -731,6 +732,7 @@
     protected static synchronized void addResultList(List resultList)
     {
         System.out.println(" add " + resultList.size() + "generated Keys");
+        if (resultList == null) return;
         generatedKeys.addAll(resultList);
     }
 

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java Sat Jul 15 07:49:27 2006
@@ -24,7 +24,7 @@
 import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
-import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
+import org.apache.ojb.broker.util.ObjectModification;
 
 /**
  * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
@@ -85,7 +85,7 @@
     myPB.clearCache();
     myPB.beginTransaction();
     ProductGroup pg =
-            (ProductGroup)myPB.getObjectByIdentity(new Identity(null, ProductGroup.class, new Object[] {new Integer(5)}));
+            (ProductGroup)myPB.getObjectByIdentity(myPB.serviceIdentity().buildIdentity(null, ProductGroup.class, new Object[] {new Integer(5)}));
     assertStmtCount("getObjectByIdentity", 4);
     resetStmtCount();
     List articles = pg.getAllArticles();
@@ -131,7 +131,7 @@
     logStmtCount("Storing first person");  // 6. oma: why so many? double lookup in OJB_HL_SEQ !
     resetStmtCount();
     pers = new Person();
-    myPB.store(pers, ObjectModificationDefaultImpl.INSERT);
+    myPB.store(pers, ObjectModification.INSERT);
     myPB.commitTransaction();
     // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('172','','')
     // commit
@@ -162,7 +162,7 @@
     proj2.setTitle("proj2");
     Collection projects = Arrays.asList(new Project[] {proj2});
     pers.setProjects(projects);
-    myPB.store(pers, ObjectModificationDefaultImpl.INSERT);
+    myPB.store(pers, ObjectModification.INSERT);
     myPB.commitTransaction();
     // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('292','','')
     // SELECT TITLE,DESCRIPTION,ID FROM PROJECT WHERE ID = '88'

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java Sat Jul 15 07:49:27 2006
@@ -33,7 +33,7 @@
     super.setUp();
     myPB = ojb.lookupBroker();
     //old_CacheFilter = getConfig().getCacheFilters();
-    // old_ObjectCache = ObjectCacheFactory.getInstance().getClassToServe();
+    //old_ObjectCache = ObjectCacheFactory.getInstance().getClassToServe();
   }
 
   /**
@@ -43,7 +43,7 @@
   protected void tearDown() throws Exception
   {
     //getConfig().setCacheFilters(old_CacheFilter);
-    // ObjectCacheFactory.getInstance().setClassToServe(old_ObjectCache);
+    //ObjectCacheFactory.getInstance().setClassToServe(old_ObjectCache);
     super.tearDown();
   }
 
@@ -55,7 +55,7 @@
     resetStmtCount();
     myPB.clearCache();
     myPB.beginTransaction();
-    Identity id = new Identity(null, InterfaceArticle.class, new Object[] {new Integer(200)});
+    Identity id = myPB.serviceIdentity().buildIdentity(null, InterfaceArticle.class, new Object[] {new Integer(200)});
     logger.info(id.toString());
     assertNull(id.getObjectsRealClass());
     myPB.getObjectByIdentity(id);

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/SimpleCountTest.java Sat Jul 15 07:49:27 2006
@@ -26,7 +26,7 @@
     Person a = new Person();
     a.setFirstname("A");
     myPB.store(a);
-    aId = new Identity(a, myPB);
+    aId = myPB.serviceIdentity().buildIdentity(a);
     myPB.commitTransaction();
     logStmtCount("Wrote test data");
   }

Modified: db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java Sat Jul 15 07:49:27 2006
@@ -41,7 +41,7 @@
     protected void tearDown() throws Exception
     {
         //getConfig().setCacheFilters(old_CacheFilter);
-        // ObjectCacheFactory.getInstance().setClassToServe(old_ObjectCache);
+        //ObjectCacheFactory.getInstance().setClassToServe(old_ObjectCache);
         super.tearDown();
     }
 
@@ -58,7 +58,7 @@
         resetStmtCount();
         pb0.clearCache();
         pb0.beginTransaction();
-        Identity id = new Identity(null, CloneableGroup.class, new Object[]{new Integer(1)});
+        Identity id = pb0.serviceIdentity().buildIdentity(null, CloneableGroup.class, new Object[] {new Integer(1)});
         logger.info(id.toString());
         assertNull(id.getObjectsRealClass());
         Object group0 = pb0.getObjectByIdentity(id);

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/OJBPerfTest.java Sat Jul 15 07:49:27 2006
@@ -6,15 +6,18 @@
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.TestHelper;
-import org.apache.ojb.broker.accesslayer.ConnectionFactory;
 import org.apache.ojb.broker.accesslayer.LookupException;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.util.ObjectModification;
+import org.apache.ojb.odmg.OJB;
 import org.apache.ojb.odmg.TransactionExt;
 import org.apache.ojb.otm.OTMConnection;
 import org.apache.ojb.otm.OTMKit;
@@ -22,7 +25,6 @@
 import org.apache.ojb.otm.lock.LockType;
 import org.apache.ojb.performance.PerfArticle;
 import org.apache.ojb.performance.PerfArticleImpl;
-import org.apache.ojb.performance.PerfHandle;
 import org.apache.ojb.performance.PerfTest;
 import org.odmg.Database;
 import org.odmg.Implementation;
@@ -33,9 +35,8 @@
 /**
  * Multi-threaded performance test implementation classes for testing
  * the PB-api, ODMG-api of OJB against native JDBC using
- * the performance-package test classes from <code>org.apache.ojb.performance</code>.
+ * the performance-package test classes.
  *
- * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  * @version $Id$
  */
 public class OJBPerfTest
@@ -43,25 +44,40 @@
     static org.apache.ojb.broker.OJB ojbInstance = new org.apache.ojb.broker.OJB();
 
     // =====================================================================================
-    // Inner class, test base class using native JDBC
+    // Inner class, test handle using native JDBC
     // =====================================================================================
     public static class JdbcPerfTest extends PerfTest
     {
         private static final String TABLE_NAME = "PERF_ARTICLE";
-        private static ConnectionFactory conFac = ojbInstance.getDefaultConfiguration().getConnectionFactory();
+        // cast to int to avoid problems with DB field length
+        public static volatile int counter = (int) System.currentTimeMillis();
+        private PersistenceBroker broker;
 
-        public JdbcPerfTest()
+        public synchronized static Long nextKey()
         {
+            return new Long(++counter);
         }
 
-        public String testName()
+        public void init() throws Exception
         {
-            return "JDBC";
+            if(broker == null)
+            {
+                broker = ojbInstance.lookupBroker();
+            }
+        }
+
+        public void tearDown() throws Exception
+        {
+            if(broker != null)
+            {
+                broker.close();
+                broker = null;
+            }
         }
 
-        public PerfHandle newPerfHandle(PerfTest test)
+        public String testName()
         {
-            return new JdbcPerfHandle(test);
+            return "JDBC";
         }
 
         public int articleCount()
@@ -77,71 +93,32 @@
                 result = rs.getInt(1);
                 rs.close();
                 stmt.close();
-                releaseConnection(con);
+                releaseConnection();
             }
-            catch (Exception e)
+            catch(Exception e)
             {
                 e.printStackTrace();
             }
             return result;
         }
 
-        private Connection getConnection() throws LookupException
-        {
-            return conFac.lookupConnection();
-        }
-
-        private void releaseConnection(Connection con)
-        {
-            conFac.releaseConnection(con);
-        }
-    }
-
-    // =====================================================================================
-    // Inner class, test handle using native JDBC
-    // =====================================================================================
-    public static class JdbcPerfHandle extends PerfHandle
-    {
-        private static final String TABLE_NAME = "PERF_ARTICLE";
-        private PersistenceBroker broker;
-
-
-        public JdbcPerfHandle(PerfTest test)
-        {
-            super(test);
-        }
-
-        public void init() throws Exception
-        {
-            if (broker == null)
-            {
-                broker = ojbInstance.lookupBroker();
-            }
-        }
-
-        public void tearDown() throws Exception
-        {
-            if (broker != null)
-            {
-                broker.close();
-            }
-        }
-
         public void insertNewArticles(PerfArticle[] arr) throws Exception
         {
             StringBuffer buf = new StringBuffer();
             buf.append("INSERT INTO ").append(TABLE_NAME);
             buf.append(" (ARTICLE_ID, ARTICLE_NAME, MINIMUM_STOCK, PRICE, UNIT, STOCK, SUPPLIER_ID)");
             buf.append(" VALUES (?,?,?,?,?,?,?)");
+            // lookup the connection (using OJB's con pooling support to make the test more fair)
             Connection con = getConnection();
             con.setAutoCommit(false);
-            PreparedStatement stmt = con.prepareStatement(buf.toString());
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
+                // OJB doesn't use a PS-pool (normally the JDBC driver supports statement pooling)
+                // thus to make this test more fair lookup a new PS for each object
+                PreparedStatement stmt = con.prepareStatement(buf.toString());
                 PerfArticle article = arr[i];
-                // use Identity to set pk field value
-                broker.serviceIdentity().buildIdentity(article);
-
+                // generate PK value
+                article.setArticleId(nextKey());
                 stmt.setLong(1, article.getArticleId().longValue());
                 stmt.setString(2, article.getArticleName());
                 stmt.setInt(3, article.getMinimumStock());
@@ -150,10 +127,10 @@
                 stmt.setInt(6, article.getStock());
                 stmt.setInt(7, article.getSupplierId());
                 stmt.executeUpdate();
+                stmt.close();
             }
             con.commit();
             con.setAutoCommit(true);
-            stmt.close();
             releaseConnection();
         }
 
@@ -169,7 +146,7 @@
             Statement stmt = con.createStatement();
             ResultSet rs = stmt.executeQuery(sql);
             ArrayList list = new ArrayList();
-            while (rs.next())
+            while(rs.next())
             {
                 PerfArticle article = new PerfArticleImpl();
                 article.setArticleId(new Long(rs.getLong("ARTICLE_ID")));
@@ -187,6 +164,30 @@
             return list;
         }
 
+        public PerfArticle getArticleByIdentity(Long articleId) throws Exception
+        {
+            String sql = "SELECT * FROM " + TABLE_NAME + " WHERE ARTICLE_ID=" + articleId.longValue() + "";
+            Connection con = getConnection();
+            Statement stmt = con.createStatement();
+            ResultSet rs = stmt.executeQuery(sql);
+            PerfArticle result = null;
+            while(rs.next())
+            {
+                result = new PerfArticleImpl();
+                result.setArticleId(new Long(rs.getLong("ARTICLE_ID")));
+                result.setArticleName(rs.getString("ARTICLE_NAME"));
+                result.setMinimumStock(rs.getInt("MINIMUM_STOCK"));
+                result.setPrice(rs.getDouble("PRICE"));
+                result.setUnit(rs.getString("UNIT"));
+                result.setStock(rs.getInt("STOCK"));
+                result.setSupplierId(rs.getInt("SUPPLIER_ID"));
+            }
+            rs.close();
+            stmt.close();
+            releaseConnection();
+            return result;
+        }
+
         public void updateArticles(PerfArticle[] arr) throws Exception
         {
             // we don't know which field is to update, thus do do all
@@ -196,9 +197,11 @@
             buf.append(" WHERE ARTICLE_ID = ?");
             Connection con = getConnection();
             con.setAutoCommit(false);
-            PreparedStatement stmt = con.prepareStatement(buf.toString());
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
+                // OJB doesn't use a PS-pool (normally the JDBC driver supports statement pooling)
+                // thus to make this test more fair lookup a new PS for each object
+                PreparedStatement stmt = con.prepareStatement(buf.toString());
                 PerfArticle article = arr[i];
                 stmt.setString(1, article.getArticleName());
                 stmt.setInt(2, article.getMinimumStock());
@@ -208,10 +211,10 @@
                 stmt.setInt(6, article.getSupplierId());
                 stmt.setLong(7, article.getArticleId().longValue());
                 stmt.executeUpdate();
+                stmt.close();
             }
             con.commit();
             con.setAutoCommit(true);
-            stmt.close();
             releaseConnection();
         }
 
@@ -225,16 +228,18 @@
             String sql = "DELETE FROM " + TABLE_NAME + " WHERE ARTICLE_ID = ?";
             Connection con = getConnection();
             con.setAutoCommit(false);
-            PreparedStatement stmt = con.prepareStatement(sql);
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
+                // OJB doesn't use a PS-pool (normally the JDBC driver supports statement pooling)
+                // thus to make this test more fair lookup a new PS for each object
+                PreparedStatement stmt = con.prepareStatement(sql);
                 PerfArticle article = arr[i];
                 stmt.setLong(1, article.getArticleId().longValue());
                 stmt.execute();
+                stmt.close();
             }
             con.commit();
             con.setAutoCommit(true);
-            stmt.close();
             releaseConnection();
         }
 
@@ -245,8 +250,6 @@
 
         private Connection getConnection() throws LookupException
         {
-            // don't let OJB handle batching
-            broker.serviceBatchManager().setBatchMode(false);
             return broker.serviceConnectionManager().getConnection();
         }
 
@@ -256,28 +259,29 @@
         }
     }
 
+
     // =====================================================================================
-    // Inner class, test base class using PB-api
+    // Inner class, test handle using PB-api
     // =====================================================================================
     public static class PBPerfTest extends PerfTest
     {
-        public PBPerfTest()
+        public void init() throws Exception
         {
         }
 
-        public String testName()
+        public void tearDown() throws Exception
         {
-            return "PB";
         }
 
-        public PerfHandle newPerfHandle(PerfTest test)
+        public String testName()
         {
-            return new PBPerfHandle(test);
+            return "PB";
         }
 
         public int articleCount()
         {
-            Query q = ojbInstance.getQueryFactory().newQuery(PerfArticleImpl.class, new Criteria());
+            Criteria c = new Criteria();
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
             int count = 0;
             try
             {
@@ -285,34 +289,12 @@
                 count = broker.getCount(q);
                 broker.close();
             }
-            catch (Exception e)
+            catch(Exception e)
             {
                 e.printStackTrace();
             }
             return count;
         }
-    }
-
-    // =====================================================================================
-    // Inner class, test handle using PB-api
-    // =====================================================================================
-    public static class PBPerfHandle extends PerfHandle
-    {
-        public PBPerfHandle(PerfTest test)
-        {
-            super(test);
-        }
-
-        public void init() throws Exception
-        {
-            PersistenceBroker broker = ojbInstance.lookupBroker();
-            broker.clearCache();
-            broker.close();
-        }
-
-        public void tearDown() throws Exception
-        {
-        }
 
         /**
          * A resource cumbering insert-method implementation,
@@ -320,7 +302,7 @@
          */
         public void insertNewArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 PersistenceBroker broker = null;
                 try
@@ -330,13 +312,9 @@
                     broker.store(arr[i]);
                     broker.commitTransaction();
                 }
-                catch(Exception e)
-                {
-                    if (broker != null) broker.abortTransaction();
-                }
                 finally
                 {
-                    if (broker != null) broker.close();
+                    if(broker != null) broker.close();
                 }
             }
         }
@@ -353,19 +331,15 @@
                 broker = ojbInstance.lookupBroker();
                 broker.serviceBatchManager().setBatchMode(true);
                 broker.beginTransaction();
-                for (int i = 0; i < arr.length; i++)
+                for(int i = 0; i < arr.length; i++)
                 {
-                    broker.store(arr[i], org.apache.ojb.broker.OJB.INSERT);
+                    broker.store(arr[i], ObjectModification.INSERT);
                 }
                 broker.commitTransaction();
             }
-            catch(Exception e)
-            {
-                if (broker != null) broker.abortTransaction();
-            }
             finally
             {
-                if (broker != null) broker.close();
+                if(broker != null) broker.close();
             }
         }
 
@@ -373,7 +347,7 @@
         {
             Criteria c = new Criteria();
             c.addLike("articleName", articleName);
-            Query q = ojbInstance.getQueryFactory().newQuery(PerfArticleImpl.class, c);
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
 
             Collection col = null;
             PersistenceBroker broker = null;
@@ -384,11 +358,25 @@
             }
             finally
             {
-                if (broker != null) broker.close();
+                if(broker != null) broker.close();
             }
             return col;
         }
 
+        public PerfArticle getArticleByIdentity(Long articleId) throws Exception
+        {
+            PersistenceBroker broker = null;
+            try
+            {
+                broker = ojbInstance.lookupBroker();
+                return (PerfArticle) broker.getObjectByIdentity(broker.serviceIdentity().buildIdentity(PerfArticleImpl.class, articleId));
+            }
+            finally
+            {
+                if(broker != null) broker.close();
+            }
+        }
+
         public void updateArticles(PerfArticle[] arr) throws Exception
         {
             PersistenceBroker broker = null;
@@ -397,26 +385,22 @@
                 broker = ojbInstance.lookupBroker();
                 broker.serviceBatchManager().setBatchMode(true);
                 broker.beginTransaction();
-                for (int i = 0; i < arr.length; i++)
+                for(int i = 0; i < arr.length; i++)
                 {
-                    broker.store(arr[i], org.apache.ojb.broker.OJB.UPDATE);
+                    broker.store(arr[i], ObjectModification.UPDATE);
                     // broker.store(arr[i]);
                 }
                 broker.commitTransaction();
             }
-            catch(Exception e)
-            {
-                if (broker != null) broker.abortTransaction();
-            }
             finally
             {
-                if (broker != null) broker.close();
+                if(broker != null) broker.close();
             }
         }
 
         public void updateArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 PersistenceBroker broker = null;
                 try
@@ -426,13 +410,9 @@
                     broker.store(arr[i]);
                     broker.commitTransaction();
                 }
-                catch(Exception e)
-                {
-                    if (broker != null) broker.abortTransaction();
-                }
                 finally
                 {
-                    if (broker != null) broker.close();
+                    if(broker != null) broker.close();
                 }
             }
         }
@@ -443,7 +423,7 @@
          */
         public void deleteArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 PersistenceBroker broker = null;
                 try
@@ -453,13 +433,9 @@
                     broker.delete(arr[i]);
                     broker.commitTransaction();
                 }
-                catch(Exception e)
-                {
-                    if (broker != null) broker.abortTransaction();
-                }
                 finally
                 {
-                    if (broker != null) broker.close();
+                    if(broker != null) broker.close();
                 }
             }
         }
@@ -475,46 +451,61 @@
             {
                 broker.serviceBatchManager().setBatchMode(true);
                 broker.beginTransaction();
-                for (int i = 0; i < arr.length; i++)
+                for(int i = 0; i < arr.length; i++)
                 {
                     broker.delete(arr[i]);
                 }
                 broker.commitTransaction();
             }
-            catch(Exception e)
-            {
-                if (broker != null) broker.abortTransaction();
-            }
             finally
             {
-                if (broker != null) broker.close();
+                if(broker != null) broker.close();
             }
         }
     }
 
+
     // =====================================================================================
-    // Inner class, test base class using ODMG-api
+    // Inner class, test handle using ODMG-api
     // =====================================================================================
     public static class ODMGPerfTest extends PerfTest
     {
-        public ODMGPerfTest()
+        private static Implementation odmg;
+        private static Database db;
+        static
+        {
+            try
+            {
+                odmg = OJB.getInstance();
+                db = odmg.newDatabase();
+                db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
+            }
+            catch(ODMGException e)
+            {
+                e.printStackTrace();
+            }
+        }
+        private TransactionExt m_tx;
+
+        public void init()
         {
+            m_tx = (TransactionExt) odmg.newTransaction();
         }
 
-        public String testName()
+        public void tearDown() throws Exception
         {
-            return "ODMG";
+            if(m_tx.isOpen()) m_tx.abort();
         }
 
-        public PerfHandle newPerfHandle(PerfTest test)
+        public String testName()
         {
-            return new ODMGPerfHandle(test);
+            return "ODMG";
         }
 
         public int articleCount()
         {
             Criteria c = new Criteria();
-            Query q = ojbInstance.getQueryFactory().newQuery(PerfArticleImpl.class, c);
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
             int count = 0;
             try
             {
@@ -522,48 +513,12 @@
                 count = broker.getCount(q);
                 broker.close();
             }
-            catch (Exception e)
+            catch(Exception e)
             {
                 e.printStackTrace();
             }
             return count;
         }
-    }
-
-    // =====================================================================================
-    // Inner class, test handle using ODMG-api
-    // =====================================================================================
-    public static class ODMGPerfHandle extends PerfHandle
-    {
-        private Implementation odmg;
-        private Database db;
-        private TransactionExt m_tx;
-
-        public ODMGPerfHandle(PerfTest test)
-        {
-            super(test);
-        }
-
-        public void init()
-        {
-            try
-            {
-                odmg = ojbInstance.instanceODMG();
-                db = odmg.newDatabase();
-                db.open(TestHelper.DEF_DATABASE_NAME, Database.OPEN_READ_WRITE);
-                m_tx = (TransactionExt) odmg.newTransaction();
-            }
-            catch (ODMGException e)
-            {
-                e.printStackTrace();
-            }
-        }
-
-        public void tearDown() throws Exception
-        {
-            if (m_tx.isOpen()) m_tx.abort();
-            db.close();
-        }
 
         /**
          * A performance optimized insert-method implementation,
@@ -572,7 +527,7 @@
         public void insertNewArticles(PerfArticle[] arr) throws Exception
         {
             m_tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 db.makePersistent(arr[i]);
             }
@@ -585,7 +540,7 @@
          */
         public void insertNewArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 Transaction tx = odmg.newTransaction();
                 tx.begin();
@@ -608,10 +563,32 @@
             return allProducts;
         }
 
+        public PerfArticle getArticleByIdentity(Long articleId) throws Exception
+        {
+//            m_tx.setImplicitLocking(false);
+//            m_tx.begin();
+//            OQLQuery query = odmg.newOQLQuery();
+//            String sql = "select allArticles from " + PerfArticleImpl.class.getName() +
+//                    " where articleId=$";
+//            query.create(sql);
+//            query.bind(articleId);
+//            List result = (List) query.execute();
+//            m_tx.commit();
+//            return (PerfArticle) result.get(0);
+// use OJB's extension for faster Identity lookup
+            PerfArticle result;
+            m_tx.setImplicitLocking(false);
+            m_tx.begin();
+            PersistenceBroker pb = m_tx.getBroker();
+            result = (PerfArticle) pb.getObjectByIdentity(pb.serviceIdentity().buildIdentity(PerfArticleImpl.class, articleId));
+            m_tx.commit();
+            return result;
+        }
+
         public void updateArticles(PerfArticle[] arr) throws Exception
         {
             m_tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 m_tx.lock(arr[i], Transaction.WRITE);
                 m_tx.markDirty(arr[i]);
@@ -621,7 +598,7 @@
 
         public void updateArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 Transaction tx = odmg.newTransaction();
                 tx.begin();
@@ -638,7 +615,7 @@
         public void deleteArticles(PerfArticle[] arr) throws Exception
         {
             m_tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 db.deletePersistent(arr[i]);
             }
@@ -651,7 +628,7 @@
          */
         public void deleteArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 Transaction tx = odmg.newTransaction();
                 tx.begin();
@@ -662,29 +639,40 @@
     }
 
     // =====================================================================================
-    // Inner class, test base class using OTM-api
+    // Inner class, test handle using OTM-api
     // =====================================================================================
     public static class OTMPerfTest extends PerfTest
     {
+        private OTMKit _kit;
+
+        private OTMConnection _conn;
+
+        private org.apache.ojb.otm.core.Transaction _tx;
 
-        public OTMPerfTest()
+        public void init()
         {
+            _kit = SimpleKit.getInstance();
+            _conn = _kit.acquireConnection(ojbInstance.getDefaultConfiguration());
         }
 
-        public String testName()
+        public void tearDown() throws Exception
         {
-            return "OTM";
+            if((_tx != null) && _tx.isInProgress())
+            {
+                _tx.rollback();
+            }
+            _conn.close();
         }
 
-        public PerfHandle newPerfHandle(PerfTest test)
+        public String testName()
         {
-            return new OTMPerfHandle(test);
+            return "OTM";
         }
 
         public int articleCount()
         {
             Criteria c = new Criteria();
-            Query q = ojbInstance.getQueryFactory().newQuery(PerfArticleImpl.class, c);
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
             int count = 0;
             try
             {
@@ -692,45 +680,12 @@
                 count = broker.getCount(q);
                 broker.close();
             }
-            catch (Exception e)
+            catch(Exception e)
             {
                 e.printStackTrace();
             }
             return count;
         }
-    }
-
-    // =====================================================================================
-    // Inner class, test handle using OTM-api
-    // =====================================================================================
-    public static class OTMPerfHandle extends PerfHandle
-    {
-        private OTMKit _kit;
-
-        private OTMConnection _conn;
-
-        private org.apache.ojb.otm.core.Transaction _tx;
-
-        public OTMPerfHandle(PerfTest test)
-        {
-            super(test);
-        }
-
-        public void init()
-        {
-            _kit = SimpleKit.getInstance();
-            _conn = _kit.acquireConnection(ojbInstance.getDefaultConfiguration());
-        }
-
-        public void tearDown() throws Exception
-        {
-            if ((_tx != null) && _tx.isInProgress())
-            {
-                _tx.rollback();
-            }
-            _conn.close();
-        }
-
 
         /**
          * A resource cumbering insert-method implementation,
@@ -738,7 +693,7 @@
          */
         public void insertNewArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 _tx = _kit.getTransaction(_conn);
                 _tx.begin();
@@ -755,7 +710,7 @@
         {
             _tx = _kit.getTransaction(_conn);
             _tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 _conn.makePersistent(arr[i]);
             }
@@ -766,7 +721,7 @@
         {
             Criteria c = new Criteria();
             c.addLike("articleName", articleName);
-            Query q = ojbInstance.getQueryFactory().newQuery(PerfArticleImpl.class, c);
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
 
             _tx = _kit.getTransaction(_conn);
             _tx.begin();
@@ -775,11 +730,26 @@
             return col;
         }
 
+        public PerfArticle getArticleByIdentity(Long articleId) throws Exception
+        {
+            Criteria c = new Criteria();
+            c.addEqualTo("articleId", articleId);
+            Query q = QueryFactory.newQuery(PerfArticleImpl.class, c);
+
+            _tx = _kit.getTransaction(_conn);
+            _tx.begin();
+            // the getByIdeneityMethod() needs Identity and this is currently not supported
+            Collection col = _conn.getCollectionByQuery(q, LockType.NO_LOCK);
+            _tx.commit();
+            Iterator it = col.iterator();
+            return it.hasNext() ? (PerfArticle) it.next() : null;
+        }
+
         public void updateArticles(PerfArticle[] arr) throws Exception
         {
             _tx = _kit.getTransaction(_conn);
             _tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 Identity oid = _conn.getIdentity(arr[i]);
                 PerfArticle a = (PerfArticle) _conn.getObjectByIdentity(oid, LockType.WRITE_LOCK);
@@ -790,7 +760,7 @@
 
         public void updateArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 _tx = _kit.getTransaction(_conn);
                 _tx.begin();
@@ -807,7 +777,7 @@
          */
         public void deleteArticlesStress(PerfArticle[] arr) throws Exception
         {
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 _tx = _kit.getTransaction(_conn);
                 _tx.begin();
@@ -824,7 +794,7 @@
         {
             _tx = _kit.getTransaction(_conn);
             _tx.begin();
-            for (int i = 0; i < arr.length; i++)
+            for(int i = 0; i < arr.length; i++)
             {
                 _conn.deletePersistent(arr[i]);
             }

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceBaseTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceBaseTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceBaseTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceBaseTest.java Sat Jul 15 07:49:27 2006
@@ -2,10 +2,14 @@
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
 
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.util.logging.Logger;
 import org.apache.ojb.broker.util.logging.LoggerFactory;
+import org.apache.ojb.broker.platforms.Platform;
+import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -78,6 +82,7 @@
         try
         {
             clearTable();
+            shutdown();
             super.tearDown();
         }
         catch(Exception e)
@@ -222,5 +227,41 @@
             logger.error(e);
             throw e;
         }
+    }
+
+    public void shutdown()
+    {
+        Platform platform = broker.serviceConnectionManager().getSupportedPlatform();
+
+        if(platform instanceof PlatformHsqldbImpl)
+        {
+            Connection con = null;
+            Statement stmt = null;
+
+            try
+            {
+                con = broker.serviceConnectionManager().getConnection();
+                stmt = con.createStatement();
+                stmt.execute("shutdown");
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+            finally
+            {
+                try
+                {
+                    if(con != null) con.close();
+                    if(stmt != null) stmt.close();
+
+                }
+                catch (SQLException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        }
+
     }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/PerformanceODMGTest.java Sat Jul 15 07:49:27 2006
@@ -114,6 +114,9 @@
         TransactionExt tx = (TransactionExt) odmg.newTransaction();
         // we don't want implicite locks when compare performance
         tx.setImplicitLocking(false);
+        // the odmg-api hasn't specific methods to lookup objects
+        // by primary key. It's recommended to use use PB-api instead for
+        // best performance. But here we use an oql-query for each object.
         String sql = "select allArticles from " + PerformanceArticle.class.getName() + " where articleId=$1";
         long start = System.currentTimeMillis();
         tx.begin();

Modified: db/ojb/trunk/src/test/org/apache/ojb/compare/PerformancePBTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/compare/PerformancePBTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/compare/PerformancePBTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/compare/PerformancePBTest.java Sat Jul 15 07:49:27 2006
@@ -4,9 +4,9 @@
 
 import org.apache.ojb.broker.Identity;
 import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.ojb.broker.OJB;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
+import org.apache.ojb.broker.util.ObjectModification;
 
 /**
  * This TestCase contains the OJB single-threaded performance benchmarks for the
@@ -76,7 +76,7 @@
         broker.beginTransaction();
         for(int i = 0; i < articleCount; i++)
         {
-            broker.store(arr[i], OJB.INSERT);
+            broker.store(arr[i], ObjectModification.INSERT);
         }
         broker.commitTransaction();
         long stop = System.currentTimeMillis();
@@ -149,7 +149,7 @@
         broker.beginTransaction();
         for(int i = 0; i < articleCount; i++)
         {
-            broker.store(arr[i], OJB.UPDATE);
+            broker.store(arr[i], ObjectModification.UPDATE);
         }
         broker.commitTransaction();
         long stop = System.currentTimeMillis();

Modified: db/ojb/trunk/src/test/org/apache/ojb/junit/ODMGTestCase.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/junit/ODMGTestCase.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/junit/ODMGTestCase.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/junit/ODMGTestCase.java Sat Jul 15 07:49:27 2006
@@ -1,7 +1,10 @@
 package org.apache.ojb.junit;
 
 import org.apache.ojb.broker.PBKey;
+import org.apache.ojb.broker.PersistenceBrokerInternal;
+import org.apache.ojb.broker.core.proxy.ProxyFactory;
 import org.apache.ojb.odmg.ImplementationExt;
+import org.apache.ojb.odmg.TransactionExt;
 import org.odmg.Database;
 import org.odmg.Transaction;
 
@@ -64,5 +67,10 @@
             buf.append("#").append(key.getPassword());
         }
         return buf.toString();
+    }
+
+    public ProxyFactory getProxyFactory(TransactionExt tx)
+    {
+        return ((PersistenceBrokerInternal) tx.getBroker()).getProxyFactory();
     }
 }

Modified: db/ojb/trunk/src/test/org/apache/ojb/junit/OJBTestCase.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/junit/OJBTestCase.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/junit/OJBTestCase.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/junit/OJBTestCase.java Sat Jul 15 07:49:27 2006
@@ -81,6 +81,7 @@
         }
         // ojb.releaseAllConfigurations();
         super.tearDown();
+        // if not really needed don't comment in, because it double the test case runtime
         // System.gc();
     }
 

Modified: db/ojb/trunk/src/test/org/apache/ojb/odmg/BatchModeTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/odmg/BatchModeTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/odmg/BatchModeTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/odmg/BatchModeTest.java Sat Jul 15 07:49:27 2006
@@ -32,7 +32,7 @@
         tx.begin();
 
         ProductGroup pg1 = new ProductGroup();
-        pg1.setName("BatchModeTest ProductGroup #1");
+        pg1.setGroupName("BatchModeTest ProductGroup #1");
         database.makePersistent(pg1);
 
         tx.checkpoint();
@@ -44,7 +44,7 @@
         database.makePersistent(a1);
 
         ProductGroup pg2 = new ProductGroup();
-        pg2.setName("BatchModeTest ProductGroup #2");
+        pg2.setGroupName("BatchModeTest ProductGroup #2");
         database.makePersistent(pg2);
 
         Article a2 = Article.createInstance();

Modified: db/ojb/trunk/src/test/org/apache/ojb/odmg/BidirectionalAssociationTest.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/test/org/apache/ojb/odmg/BidirectionalAssociationTest.java?rev=422240&r1=422239&r2=422240&view=diff
==============================================================================
--- db/ojb/trunk/src/test/org/apache/ojb/odmg/BidirectionalAssociationTest.java (original)
+++ db/ojb/trunk/src/test/org/apache/ojb/odmg/BidirectionalAssociationTest.java Sat Jul 15 07:49:27 2006
@@ -128,8 +128,11 @@
         tx.begin();
         b.setRelatedA(a);
         a.setRelatedB(b);
-        database.makePersistent(a);
+        // we use a FK from ObjectB to ObjectA, thus we
+        // make persistent B
         database.makePersistent(b);
+        // not needed
+        //database.makePersistent(a);
         tx.commit();
 
         /**



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message