db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker AbstractExtentClassTest.java BatchModeTest.java BidirectionalAssociationTest.java BlobTest.java ComplexReferenceTest.java ConnectionFactoryTest.java ExtentAwarePathExpressionsTest.java FieldConversionTest.java FieldConversionTest_3.java IdentityPerformanceTest.java InheritanceMultipleTableTest.java KeyConstraintViolationTest.java LockedByVersion.java LogServiceTest.java M2NTest.java MtoNMapping.java OJBPerfTest.java OptimisticLockingTest.java PBRollbackTest.java PerformanceJdbcReferenceTest.java PerformanceTest.java PerformanceTest2.java PerformanceTest3.java PersistenceBrokerTest.java Person.java PolymorphicExtents.java Project.java ProxyExamples.java QueryTest.java TypedCollectionsTest.java Zoo.java
Date Tue, 14 Sep 2004 16:46:09 GMT
arminw      2004/09/14 09:46:09

  Modified:    src/test/org/apache/ojb/broker/sqlcount
                        AbstractCountTest.java
               src/test/org/apache/ojb/broker/util/graph GraphTest.java
               src/test/org/apache/ojb/broker AbstractExtentClassTest.java
                        BatchModeTest.java
                        BidirectionalAssociationTest.java BlobTest.java
                        ComplexReferenceTest.java
                        ConnectionFactoryTest.java
                        ExtentAwarePathExpressionsTest.java
                        FieldConversionTest.java FieldConversionTest_3.java
                        IdentityPerformanceTest.java
                        InheritanceMultipleTableTest.java
                        KeyConstraintViolationTest.java
                        LockedByVersion.java LogServiceTest.java
                        M2NTest.java MtoNMapping.java OJBPerfTest.java
                        OptimisticLockingTest.java PBRollbackTest.java
                        PerformanceJdbcReferenceTest.java
                        PerformanceTest.java PerformanceTest2.java
                        PerformanceTest3.java PersistenceBrokerTest.java
                        Person.java PolymorphicExtents.java Project.java
                        ProxyExamples.java QueryTest.java
                        TypedCollectionsTest.java Zoo.java
  Log:
  - add new batch handling
  - update/refactoring Statement classes
  - add new PB.update(Object obj, String[] fields)
  - change insert order of m:n relations
  - change repository.dtd, add element 'batch', rename element
  'connection-pool' to 'connection-factory', remove implementation
  dependent attributes and add custom-attributes instead
  - remove unused classes
  
  Revision  Changes    Path
  1.5       +1 -2      db-ojb/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java
  
  Index: AbstractCountTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sqlcount/AbstractCountTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractCountTest.java	11 Aug 2004 00:39:44 -0000	1.4
  +++ AbstractCountTest.java	14 Sep 2004 16:46:08 -0000	1.5
  @@ -7,7 +7,6 @@
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  -import org.apache.ojb.broker.metadata.MetadataManager;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.junit.OJBTestCase;
  
  
  
  1.3       +0 -1      db-ojb/src/test/org/apache/ojb/broker/util/graph/GraphTest.java
  
  Index: GraphTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/util/graph/GraphTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GraphTest.java	11 Aug 2004 00:39:45 -0000	1.2
  +++ GraphTest.java	14 Sep 2004 16:46:08 -0000	1.3
  @@ -1,6 +1,5 @@
   package org.apache.ojb.broker.util.graph;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.Person;
   import org.apache.ojb.broker.Project;
   import org.apache.ojb.junit.OJBTestCase;
  
  
  
  1.9       +1 -3      db-ojb/src/test/org/apache/ojb/broker/AbstractExtentClassTest.java
  
  Index: AbstractExtentClassTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AbstractExtentClassTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbstractExtentClassTest.java	11 Aug 2004 00:39:45 -0000	1.8
  +++ AbstractExtentClassTest.java	14 Sep 2004 16:46:08 -0000	1.9
  @@ -4,12 +4,10 @@
   import java.util.Collection;
   import java.util.Iterator;
   
  -import junit.framework.TestCase;
   import org.apache.commons.lang.builder.ToStringBuilder;
   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.junit.OJBTestCase;
   import org.apache.ojb.junit.PBTestCase;
   
   /**
  
  
  
  1.10      +7 -1      db-ojb/src/test/org/apache/ojb/broker/BatchModeTest.java
  
  Index: BatchModeTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/BatchModeTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BatchModeTest.java	11 Aug 2004 00:39:45 -0000	1.9
  +++ BatchModeTest.java	14 Sep 2004 16:46:08 -0000	1.10
  @@ -40,6 +40,12 @@
           junit.textui.TestRunner.main(arr);
       }
   
  +    public void setUp() throws Exception
  +    {
  +        super.setUp();
  +        broker.serviceConnectionManager().setBatchMode(true);
  +    }
  +
   
       /**
        * A common (no specific batch) test
  @@ -303,7 +309,7 @@
           for(int i = 200 - 1; i >= 0; i--)
           {
               Person p = new Person();
  -            p.setFirstname("a mass test");
  +            p.setFirstname("a mass test_" + i);
               p.setLastname(name);
               broker.store(p);
           }
  
  
  
  1.6       +0 -1      db-ojb/src/test/org/apache/ojb/broker/BidirectionalAssociationTest.java
  
  Index: BidirectionalAssociationTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/BidirectionalAssociationTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BidirectionalAssociationTest.java	22 Jun 2004 18:16:22 -0000	1.5
  +++ BidirectionalAssociationTest.java	14 Sep 2004 16:46:08 -0000	1.6
  @@ -4,7 +4,6 @@
    */
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.query.*;
   import org.apache.ojb.junit.PBTestCase;
   
  
  
  
  1.10      +0 -1      db-ojb/src/test/org/apache/ojb/broker/BlobTest.java
  
  Index: BlobTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/BlobTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BlobTest.java	23 Jun 2004 10:20:08 -0000	1.9
  +++ BlobTest.java	14 Sep 2004 16:46:08 -0000	1.10
  @@ -2,7 +2,6 @@
   
   import java.io.Serializable;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.platforms.Platform;
   import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
   import org.apache.ojb.junit.PBTestCase;
  
  
  
  1.3       +1 -3      db-ojb/src/test/org/apache/ojb/broker/ComplexReferenceTest.java
  
  Index: ComplexReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ComplexReferenceTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ComplexReferenceTest.java	11 Aug 2004 00:39:45 -0000	1.2
  +++ ComplexReferenceTest.java	14 Sep 2004 16:46:08 -0000	1.3
  @@ -1,7 +1,5 @@
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
  -
   import java.util.Collection;
   import java.util.ArrayList;
   
  
  
  
  1.6       +5 -4      db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java
  
  Index: ConnectionFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConnectionFactoryTest.java	11 Aug 2004 00:39:45 -0000	1.5
  +++ ConnectionFactoryTest.java	14 Sep 2004 16:46:08 -0000	1.6
  @@ -8,6 +8,7 @@
   import org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl;
   import org.apache.ojb.broker.accesslayer.LookupException;
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  +import org.apache.ojb.broker.util.pooling.PoolConfiguration;
   import org.apache.ojb.junit.PBTestCase;
   
   /**
  @@ -101,7 +102,7 @@
           JdbcConnectionDescriptor jcd = broker.getConfiguration().getJdbcConnectionDescriptor();
           Class oldCF = jcd.getConnectionPoolDescriptor().getConnectionFactory();
           int oldAutoCommit = jcd.getUseAutoCommit();
  -        int oldMaxActive = jcd.getConnectionPoolDescriptor().getMaxActive();
  +        String oldMaxActive = jcd.getConnectionPoolDescriptor().getAttribute(PoolConfiguration.MAX_ACTIVE);
           try
           {
               // release connection factory of current broker
  @@ -110,7 +111,7 @@
               jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
   
               jcd.setUseAutoCommit(1);
  -            jcd.getConnectionPoolDescriptor().setMaxActive(2);
  +            jcd.getConnectionPoolDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE, "2");
               jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
   
               Connection con = null;
  @@ -160,7 +161,7 @@
               // restore settings
               jcd.setUseAutoCommit(oldAutoCommit);
               jcd.getConnectionPoolDescriptor().setConnectionFactory(oldCF);
  -            jcd.getConnectionPoolDescriptor().setMaxActive(oldMaxActive);
  +            jcd.getConnectionPoolDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE, oldMaxActive);
           }
       }
   }
  
  
  
  1.9       +1 -2      db-ojb/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
  
  Index: ExtentAwarePathExpressionsTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ExtentAwarePathExpressionsTest.java	11 Aug 2004 00:39:45 -0000	1.8
  +++ ExtentAwarePathExpressionsTest.java	14 Sep 2004 16:46:08 -0000	1.9
  @@ -5,7 +5,6 @@
   import java.util.List;
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
   import org.apache.ojb.broker.query.Criteria;
  
  
  
  1.4       +1 -2      db-ojb/src/test/org/apache/ojb/broker/FieldConversionTest.java
  
  Index: FieldConversionTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/FieldConversionTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FieldConversionTest.java	11 Aug 2004 00:39:45 -0000	1.3
  +++ FieldConversionTest.java	14 Sep 2004 16:46:08 -0000	1.4
  @@ -1,6 +1,5 @@
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.ojb.broker.accesslayer.conversions.ConversionException;
  
  
  
  1.6       +1 -2      db-ojb/src/test/org/apache/ojb/broker/FieldConversionTest_3.java
  
  Index: FieldConversionTest_3.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/FieldConversionTest_3.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FieldConversionTest_3.java	11 Aug 2004 00:39:45 -0000	1.5
  +++ FieldConversionTest_3.java	14 Sep 2004 16:46:08 -0000	1.6
  @@ -3,7 +3,6 @@
   import java.io.Serializable;
   import java.math.BigDecimal;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.accesslayer.conversions.ConversionException;
   import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
   import org.apache.ojb.broker.query.Criteria;
  
  
  
  1.6       +0 -3      db-ojb/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java
  
  Index: IdentityPerformanceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/IdentityPerformanceTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IdentityPerformanceTest.java	11 Aug 2004 00:39:45 -0000	1.5
  +++ IdentityPerformanceTest.java	14 Sep 2004 16:46:08 -0000	1.6
  @@ -1,12 +1,9 @@
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
  -
   import java.util.Map;
   import java.util.HashMap;
   
   import org.apache.ojb.broker.metadata.DescriptorRepository;
  -import org.apache.ojb.broker.metadata.MetadataManager;
   import org.apache.ojb.junit.PBTestCase;
   
   /**
  
  
  
  1.9       +189 -62   db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java
  
  Index: InheritanceMultipleTableTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/InheritanceMultipleTableTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- InheritanceMultipleTableTest.java	3 Jul 2004 23:32:16 -0000	1.8
  +++ InheritanceMultipleTableTest.java	14 Sep 2004 16:46:08 -0000	1.9
  @@ -31,6 +31,187 @@
           junit.textui.TestRunner.main(new String[]{InheritanceMultipleTableTest.class.getName()});
       }
   
  +    public void setUp() throws Exception
  +    {
  +        super.setUp();
  +        // allow to batch statements
  +        broker.serviceConnectionManager().setBatchMode(true);
  +    }
  +
  +    public void testUpdate()
  +    {
  +        long timestamp = System.currentTimeMillis();
  +        Long id_2 = new Long(timestamp);
  +        String name = "testUpdate" + timestamp;
  +        Employee em1 = new Employee(id_2, "employee_" + name);
  +        Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
  +        Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
  +        ArrayList list = new ArrayList();
  +        list.add(ex1);
  +        list.add(ex2);
  +        Manager m1 = new Manager(id_2, "manager_" + name);
  +        m1.setExecutives(list);
  +
  +        broker.beginTransaction();
  +        broker.store(em1);
  +        broker.store(m1);
  +        broker.commitTransaction();
  +
  +        Identity m1_oid = new Identity(m1, broker);
  +        Identity ex1_oid = new Identity(ex1, broker);
  +        Identity em1_oid = new Identity(em1, broker);
  +
  +        broker.clearCache();
  +
  +        Employee newEm1 = (Employee) broker.getObjectByIdentity(em1_oid);
  +        Executive newEx1 = (Executive) broker.getObjectByIdentity(ex1_oid);
  +        Manager newM1 = (Manager) broker.getObjectByIdentity(m1_oid);
  +
  +        assertEquals(2, newM1.getExecutives().size());
  +
  +        newEm1.setName("**updated_" + name);
  +        newM1.setName("**updated_" + name);
  +        ((Executive) newM1.getExecutives().get(0)).setName("**updated_" + name);
  +
  +        broker.beginTransaction();
  +        broker.store(newEm1);
  +        broker.store(newM1);
  +        broker.store(newEx1);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +
  +        em1 = (Employee) broker.getObjectByIdentity(em1_oid);
  +        ex1 = (Executive) broker.getObjectByIdentity(ex1_oid);
  +        m1 = (Manager) broker.getObjectByIdentity(m1_oid);
  +
  +        assertEquals(newEm1, em1);
  +        assertEquals(newEx1, ex1);
  +        assertEquals(newM1, m1);
  +
  +        assertEquals(2, m1.getExecutives().size());
  +    }
  +
  +    public void testStoreUpdateQuerySerialized_2()
  +    {
  +        long timestamp = System.currentTimeMillis();
  +        Long id_2 = new Long(timestamp);
  +        String name = "testStoreUpdateQuerySerialized_" + 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");
  +
  +        broker.beginTransaction();
  +        broker.store(em);
  +        broker.store(m_1);
  +        broker.store(m_3);
  +        broker.store(ex_1);
  +        broker.store(m_2);
  +        broker.store(ex_2);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        Criteria crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        crit.addLike("department", "none");
  +        Query query = QueryFactory.newQuery(Manager.class, crit);
  +        Collection result = broker.getCollectionByQuery(query);
  +        assertEquals(1, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Employee.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals(6, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Executive.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals(5, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Manager.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals(3, result.size());
  +
  +        em = (Employee) SerializationUtils.clone(em);
  +        m_1 = (Manager) SerializationUtils.clone(m_1);
  +        m_2 = (Manager) SerializationUtils.clone(m_2);
  +        m_3 = (Manager) SerializationUtils.clone(m_3);
  +        ex_1 = (Executive) SerializationUtils.clone(ex_1);
  +        ex_2 = (Executive) SerializationUtils.clone(ex_2);
  +
  +        em.setName(em.getName() + "_updated");
  +        m_1.setName(m_1.getName() + "_updated");
  +        m_1.setDepartment("_updated_Dep");
  +        m_2.setName(m_2.getName() + "_updated");
  +        m_3.setName(m_3.getName() + "_updated");
  +        ex_1.setName(ex_1.getName() + "_updated");
  +        ex_2.setName(ex_2.getName() + "_updated");
  +
  +        broker.clearCache();
  +        broker.beginTransaction();
  +        //========================================
  +        // update only modified fields
  +        broker.update(em, new String[]{"name"});
  +        broker.update(m_1, new String[]{"name", "department"});
  +        broker.update(m_3, new String[]{"name"});
  +        broker.update(ex_1, new String[]{"name"});
  +        broker.update(m_2, new String[]{"name"});
  +        broker.update(ex_2, new String[]{"name"});
  +        //========================================
  +        broker.commitTransaction();
  +
  +        /*
  +        after de/serialization and update we expect the same row count in
  +        each table
  +        */
  +        broker.clearCache();
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        crit.addLike("department", "_updated_Dep");
  +        query = QueryFactory.newQuery(Manager.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals("Expect the same number of objects as before update", 1, result.size());
  +        Manager newMan = (Manager) result.iterator().next();
  +        assertEquals(m_1.getName(), newMan.getName());
  +        assertEquals(m_1.getDepartment(), newMan.getDepartment());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        crit.addLike("department", "none");
  +        query = QueryFactory.newQuery(Manager.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals("Expect the same number of objects as before update", 1, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Employee.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals("Expect the same number of objects as before update", 6, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Executive.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals("Expect the same number of objects as before update", 5, result.size());
  +
  +        crit = new Criteria();
  +        crit.addLike("name", name + "%");
  +        query = QueryFactory.newQuery(Manager.class, crit);
  +        result = broker.getCollectionByQuery(query);
  +        assertEquals("Expect the same number of objects as before update", 3, result.size());
  +    }
  +
       public void testObjectExistence()
       {
           Manager target_1 = new Manager(new Long(1), "testObjectExistence");
  @@ -51,7 +232,7 @@
       {
           long timestamp = System.currentTimeMillis();
           Long id_2 = new Long(timestamp);
  -        String name = "testInsert" + timestamp;
  +        String name = "testStoreUpdateQuerySerialized_" + 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");
  @@ -97,12 +278,12 @@
           result = broker.getCollectionByQuery(query);
           assertEquals(3, result.size());
   
  -        em = (Employee) SerializationUtils.deserialize(SerializationUtils.serialize(em));
  -        m_1 = (Manager) SerializationUtils.deserialize(SerializationUtils.serialize(m_1));
  -        m_2 = (Manager) SerializationUtils.deserialize(SerializationUtils.serialize(m_2));
  -        m_3 = (Manager) SerializationUtils.deserialize(SerializationUtils.serialize(m_3));
  -        ex_1 = (Executive) SerializationUtils.deserialize(SerializationUtils.serialize(ex_1));
  -        ex_2 = (Executive) SerializationUtils.deserialize(SerializationUtils.serialize(ex_2));
  +        em = (Employee) SerializationUtils.clone(em);
  +        m_1 = (Manager) SerializationUtils.clone(m_1);
  +        m_2 = (Manager) SerializationUtils.clone(m_2);
  +        m_3 = (Manager) SerializationUtils.clone(m_3);
  +        ex_1 = (Executive) SerializationUtils.clone(ex_1);
  +        ex_2 = (Executive) SerializationUtils.clone(ex_2);
   
           em.setName(em.getName() + "_updated");
           m_1.setName(m_1.getName() + "_updated");
  @@ -366,60 +547,6 @@
   
           result = broker.getCollectionByQuery(queryManager);
           assertEquals(1, result.size());
  -    }
  -
  -    public void testUpdate()
  -    {
  -        long timestamp = System.currentTimeMillis();
  -        Long id_2 = new Long(timestamp);
  -        String name = "testUpdate" + timestamp;
  -        Employee em1 = new Employee(id_2, "employee_" + name);
  -        Executive ex1 = new Executive(id_2, "executive_" + name, "department_1", null);
  -        Executive ex2 = new Executive(id_2, "executive_" + name, "department_2", null);
  -        ArrayList list = new ArrayList();
  -        list.add(ex1);
  -        list.add(ex2);
  -        Manager m1 = new Manager(id_2, "manager_" + name);
  -        m1.setExecutives(list);
  -
  -        broker.beginTransaction();
  -        broker.store(em1);
  -        broker.store(m1);
  -        broker.commitTransaction();
  -
  -        Identity m1_oid = new Identity(m1, broker);
  -        Identity ex1_oid = new Identity(ex1, broker);
  -        Identity em1_oid = new Identity(em1, broker);
  -
  -        broker.clearCache();
  -
  -        Employee newEm1 = (Employee) broker.getObjectByIdentity(em1_oid);
  -        Executive newEx1 = (Executive) broker.getObjectByIdentity(ex1_oid);
  -        Manager newM1 = (Manager) broker.getObjectByIdentity(m1_oid);
  -
  -        assertEquals(2, newM1.getExecutives().size());
  -
  -        newEm1.setName("**updated_" + name);
  -        newM1.setName("**updated_" + name);
  -        ((Executive) newM1.getExecutives().get(0)).setName("**updated_" + name);
  -
  -        broker.beginTransaction();
  -        broker.store(newEm1);
  -        broker.store(newM1);
  -        broker.store(newEx1);
  -        broker.commitTransaction();
  -
  -        broker.clearCache();
  -
  -        em1 = (Employee) broker.getObjectByIdentity(em1_oid);
  -        ex1 = (Executive) broker.getObjectByIdentity(ex1_oid);
  -        m1 = (Manager) broker.getObjectByIdentity(m1_oid);
  -
  -        assertEquals(newEm1, em1);
  -        assertEquals(newEx1, ex1);
  -        assertEquals(newM1, m1);
  -
  -        assertEquals(2, m1.getExecutives().size());
       }
   
       public void testDelete()
  
  
  
  1.7       +6 -5      db-ojb/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java
  
  Index: KeyConstraintViolationTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/KeyConstraintViolationTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- KeyConstraintViolationTest.java	31 May 2004 22:57:21 -0000	1.6
  +++ KeyConstraintViolationTest.java	14 Sep 2004 16:46:08 -0000	1.7
  @@ -26,15 +26,16 @@
   	 **/
   	public void testKeyViolation() throws Exception
   	{
  -        ObjectModificationDefaultImpl objMod = new ObjectModificationDefaultImpl();
  -        objMod.setNeedsInsert(true);
  -
  +        // make sure not to batch mode, because key constraint exception will be wrapped by
  +        // a batch exception
  +        broker.serviceConnectionManager().setBatchMode(false);
  +        
           broker.beginTransaction();
           Article obj = new Article();
           obj.setProductGroupId(1);
           obj.articleName = "repeated Article";
           // storing once should be ok.
  -        broker.store(obj,objMod);
  +        broker.store(obj, OJB.INSERT);
           broker.commitTransaction();
   
           broker.clearCache();
  @@ -47,7 +48,7 @@
   			obj2.articleName = "repeated Article";
   
   			// store it again!
  -			broker.store(obj2,objMod);
  +			broker.store(obj2, OJB.INSERT);
   			broker.commitTransaction();
   
   			fail("Should have thrown a KeyConstraintViolatedException");
  
  
  
  1.3       +7 -0      db-ojb/src/test/org/apache/ojb/broker/LockedByVersion.java
  
  Index: LockedByVersion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/LockedByVersion.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LockedByVersion.java	21 Aug 2002 14:01:17 -0000	1.2
  +++ LockedByVersion.java	14 Sep 2004 16:46:08 -0000	1.3
  @@ -2,6 +2,8 @@
   
   import java.io.Serializable;
   
  +import org.apache.commons.lang.builder.ToStringBuilder;
  +
   /**
    *
    */
  @@ -77,4 +79,9 @@
           this.version = version;
       }
   
  +    public String toString()
  +    {
  +        ToStringBuilder buf = new ToStringBuilder(this);
  +        return buf.append("id" , id).append("value", value).append("version", version).toString();
  +    }
   }
  
  
  
  1.8       +0 -1      db-ojb/src/test/org/apache/ojb/broker/LogServiceTest.java
  
  Index: LogServiceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/LogServiceTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LogServiceTest.java	11 Aug 2004 00:39:45 -0000	1.7
  +++ LogServiceTest.java	14 Sep 2004 16:46:08 -0000	1.8
  @@ -3,7 +3,6 @@
   //JUNIT
   
   import junit.framework.Test;
  -import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import org.apache.ojb.broker.accesslayer.RsIterator;
   import org.apache.ojb.broker.core.PersistenceBrokerImpl;
  
  
  
  1.9       +327 -5    db-ojb/src/test/org/apache/ojb/broker/M2NTest.java
  
  Index: M2NTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/M2NTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- M2NTest.java	7 Jul 2004 16:46:24 -0000	1.8
  +++ M2NTest.java	14 Sep 2004 16:46:08 -0000	1.9
  @@ -1,6 +1,8 @@
   package org.apache.ojb.broker;
   
   import org.apache.commons.lang.builder.ToStringBuilder;
  +import org.apache.commons.lang.time.StopWatch;
  +import org.apache.commons.lang.ClassUtils;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
  @@ -12,6 +14,7 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
  +import java.util.List;
   
   /**
    * Test (non-decomposed) M:N relations.
  @@ -29,6 +32,9 @@
       static final int LINK = ObjectReferenceDescriptor.CASCADE_LINK;
       static final int OBJECT = ObjectReferenceDescriptor.CASCADE_OBJECT;
   
  +    int actorCount = 2000;
  +    int movieCount = 1000;
  +
       public static void main(String[] args)
       {
           junit.textui.TestRunner.main(new String[]{M2NTest.class.getName()});
  @@ -45,6 +51,266 @@
           super.tearDown();
       }
   
  +    public void testMassStoreUpdateAutomatic()
  +    {
  +
  +        long testPeriod = 0;
  +
  +        String postfix = "testMassStoreUpdateAutomatic_" + System.currentTimeMillis();
  +        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +
  +        Movie movie = buildMovieWithActors(postfix, actorCount);
  +        Actor actor = buildActorWithMovies(postfix, movieCount);
  +
  +        List actors = new ArrayList(movie.getActors());
  +        actors.add(actor);
  +        movie.setActors(actors);
  +
  +        MovieManageableCollection movies = actor.getMovies();
  +        movies.add(movie);
  +
  +        StopWatch watch = new StopWatch();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.store(movie);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Time to store "+(actorCount + movieCount)+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        watch.reset();
  +        watch.start();
  +        Query queryMovie = movieQuery(postfix);
  +        Collection resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(movieCount + 1, resultMovie.size());
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Time to query "+movieCount+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        watch.reset();
  +        watch.start();
  +        Query queryActor = actorQuery(postfix);
  +        Collection resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount + 1, resultActor.size());
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Time to query "+actorCount+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        Query queryRole = roleQueryActorOrMovieMatch(actor, movie);
  +        Collection resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(actorCount + movieCount + 1, resultRole.size());
  +
  +        //*****************************
  +        // update movie
  +        movie.setActors(new ArrayList());
  +        watch.reset();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.store(movie);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Time to update object with "+actorCount + " m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +        //*****************************
  +
  +        broker.clearCache();
  +        Identity oid = new Identity(movie, broker);
  +        movie = (Movie) broker.getObjectByIdentity(oid);
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(movieCount + 1, resultMovie.size());
  +
  +        resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount + 1, resultActor.size());
  +
  +        resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(movieCount, resultRole.size());
  +
  +        assertNotNull(movie);
  +        assertEquals(0, movie.getActors().size());
  +
  +        //*****************************
  +        // remove actor
  +        movie.setActors(new ArrayList());
  +        watch.reset();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.delete(actor);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Time to remove object with "+ movieCount + " m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +        //*****************************
  +
  +        broker.clearCache();
  +        oid = new Identity(actor, broker);
  +        actor = (Actor) broker.getObjectByIdentity(oid);
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(0, resultMovie.size());
  +
  +        // we never delete these actor objects
  +        resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount, resultActor.size());
  +
  +        resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(0, resultRole.size());
  +
  +        assertNull(actor);
  +
  +        broker.beginTransaction();
  +        broker.delete(movie);
  +        broker.commitTransaction();
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(0, resultMovie.size());
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateAutomatic] Total test time is "+ testPeriod+" ms");
  +        System.out.println("");
  +    }
  +
  +
  +    public void testMassStoreUpdateLinking()
  +    {
  +        long testPeriod = 0;
  +
  +        String postfix = "testMassStoreUpdateLinking" + System.currentTimeMillis();
  +        changeMovieCollectionDescriptorTo(true, NONE, OBJECT, false);
  +        changeActorCollectionDescriptorTo(true, NONE, OBJECT, false);
  +
  +        Movie movie = buildMovieWithActors(postfix, actorCount);
  +        Actor actor = buildActorWithMovies(postfix, movieCount);
  +
  +        List actors = new ArrayList(movie.getActors());
  +        actors.add(actor);
  +        movie.setActors(actors);
  +
  +        MovieManageableCollection movies = actor.getMovies();
  +        movies.add(movie);
  +
  +        StopWatch watch = new StopWatch();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.store(movie);
  +        for(int i = 0; i < actors.size(); i++)
  +        {
  +            broker.store(actors.get(i));
  +        }
  +        MovieManageableCollection actorMovies = actor.getMovies();
  +        for(int i = 0; i < actorMovies.size(); i++)
  +        {
  +             broker.store(actorMovies.get(i));
  +        }
  +        broker.serviceBrokerHelper().link(movie, true);
  +        broker.serviceBrokerHelper().link(actor, true);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Time to store "+(actorCount + movieCount)+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        watch.reset();
  +        watch.start();
  +        Query queryMovie = movieQuery(postfix);
  +        Collection resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(movieCount + 1, resultMovie.size());
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Time to query "+movieCount+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        watch.reset();
  +        watch.start();
  +        Query queryActor = actorQuery(postfix);
  +        Collection resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount + 1, resultActor.size());
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Time to query "+actorCount+" m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +
  +        Query queryRole = roleQueryActorOrMovieMatch(actor, movie);
  +        Collection resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(actorCount + movieCount + 1, resultRole.size());
  +
  +        //*****************************
  +        // update movie
  +        movie.setActors(new ArrayList());
  +        watch.reset();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.serviceBrokerHelper().unlink(movie);
  +        broker.store(movie);
  +        broker.serviceBrokerHelper().link(movie, false);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Time to update object with "+actorCount + " m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +        //*****************************
  +
  +        broker.clearCache();
  +        Identity oid = new Identity(movie, broker);
  +        movie = (Movie) broker.getObjectByIdentity(oid);
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(movieCount + 1, resultMovie.size());
  +
  +        resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount + 1, resultActor.size());
  +
  +        resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(movieCount, resultRole.size());
  +
  +        assertNotNull(movie);
  +        assertEquals(0, movie.getActors().size());
  +
  +        //*****************************
  +        // remove actor
  +        movie.setActors(new ArrayList());
  +        watch.reset();
  +        watch.start();
  +        broker.beginTransaction();
  +        broker.delete(actor);
  +        broker.commitTransaction();
  +        watch.stop();
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Time to remove object with "+ movieCount + " m:n objects=" + watch.getTime());
  +        testPeriod += watch.getTime();
  +        //*****************************
  +
  +        broker.clearCache();
  +        oid = new Identity(actor, broker);
  +        actor = (Actor) broker.getObjectByIdentity(oid);
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(0, resultMovie.size());
  +
  +        // we never delete these actor objects
  +        resultActor = broker.getCollectionByQuery(queryActor);
  +        assertEquals(actorCount, resultActor.size());
  +
  +        resultRole = broker.getCollectionByQuery(queryRole);
  +        assertEquals(0, resultRole.size());
  +
  +        assertNull(actor);
  +
  +        broker.beginTransaction();
  +        broker.delete(movie);
  +        broker.commitTransaction();
  +
  +        resultMovie = broker.getCollectionByQuery(queryMovie);
  +        assertEquals(0, resultMovie.size());
  +        System.out.println("[" + ClassUtils.getShortClassName(this.getClass())
  +                + "#testMassStoreUpdateLinking] Total test time is "+ testPeriod+" ms");
  +        System.out.println("");
  +    }
   
       public void testAutoUpdateDeleteSettings()
       {
  @@ -518,16 +784,16 @@
   
       public void testAddNewEntriesTTTF()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
           doTestStoreUpdateTTXX();
       }
   
       public void testAddNewEntriesTTTT()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, true);
  +        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, true);
           // default proxy does not work for user defined collection 
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
           doTestStoreUpdateTTXX();
       }
   
  @@ -657,6 +923,28 @@
           return q;
       }
   
  +    Query roleQueryActorOrMovieMatch(Actor actor, Movie movie)
  +    {
  +        Criteria c_1 = new Criteria();
  +        Criteria c_2 = new Criteria();
  +        if(actor != null) c_1.addEqualTo("actorId", actor.getId());
  +        if(movie != null)
  +        {
  +            c_2.addEqualTo("movieIntId", movie.getIdInt());
  +            c_2.addEqualTo("movieStrId", movie.getIdStr());
  +        }
  +        if(actor != null)
  +        {
  +            c_2.addOrCriteria(c_1);
  +        }
  +        else
  +        {
  +            c_2 = c_1;
  +        }
  +        Query q = QueryFactory.newQuery(Role.class, c_2);
  +        return q;
  +    }
  +
       /**
        * Returns 1 movie object with 3 actor objects
        */
  @@ -675,6 +963,40 @@
           list.add(a3);
           m.setActors(list);
           return m;
  +    }
  +
  +    /**
  +     * Returns 1 movie object with 3 actor objects
  +     */
  +    Movie buildMovieWithActors(String postfixId, int actorCount)
  +    {
  +        Movie m = new MovieImpl(postfixId, "Movie with "+ actorCount+" actors_" + postfixId, "none");
  +
  +        ArrayList list = new ArrayList();
  +        for(int i = 0; i < actorCount; i++)
  +        {
  +            Actor a = new Actor("A bad actor_" + postfixId);
  +            list.add(a);
  +        }
  +        m.setActors(list);
  +        return m;
  +    }
  +
  +    /**
  +     * Returns 1 movie object with 3 actor objects
  +     */
  +    Actor buildActorWithMovies(String postfixId, int movieCount)
  +    {
  +        Actor a = new Actor(postfixId+"_Actor play in "+ movieCount+" movies");
  +
  +        MovieManageableCollection list = new MovieManageableCollection();
  +        for(int i = 0; i < movieCount; i++)
  +        {
  +            Movie m  = new MovieImpl(postfixId, "A bad movie_" + postfixId, "none");
  +            list.add(m);
  +        }
  +        a.setMovies(list);
  +        return a;
       }
   
       /**
  
  
  
  1.26      +47 -17    db-ojb/src/test/org/apache/ojb/broker/MtoNMapping.java
  
  Index: MtoNMapping.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MtoNMapping.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- MtoNMapping.java	3 Jul 2004 18:22:14 -0000	1.25
  +++ MtoNMapping.java	14 Sep 2004 16:46:08 -0000	1.26
  @@ -245,7 +245,7 @@
   
               assertEquals("Same Title", p1.getTitle(), p2.getTitle());
               assertEquals("Same Number of Persons", p1.getPersons().size(), p2.getPersons().size());
  -            assertEquals("Same toString", p1.toString(), p2.toString());
  +            assertEquals("Same toString", p1.getId(), p2.getId());
           }
       }
   
  @@ -326,37 +326,67 @@
       /** Add a new Project, delete an existing Project */
       public void testInsertAndDelete() throws Exception
       {
  +        int projectsCount = 2;
  +        String name = "testInsertAndDelete_" + System.currentTimeMillis();
           Person pers = new Person();
  -        pers.setId(7);
  -        Query query = QueryFactory.newQuery(pers);
  -        pers = (Person) broker.getObjectByQuery(query);
  -        Collection projects = pers.getProjects();
  -        Project[] projectArray = (Project[]) projects.toArray(new Project[0]);
  -        Project oldProj, newProj;
  -        int count = projects.size();
  +        pers.setFirstname(name);
   
  -        oldProj = projectArray[0];
  -        projects.remove(oldProj);
  +        List projects = new ArrayList();
  +        for(int i = 0;i<projectsCount;i++)
  +        {
  +            Project p = new Project();
  +            p.setTitle(name);
  +            projects.add(p);
  +        }
   
  -        newProj = new Project();
  -        newProj.setTitle("Test Project1 for Person 7");
  -        newProj.setDescription("This is a Test Project1 for Person 7");
  +        pers.setProjects(projects);
  +
  +        broker.beginTransaction();
  +        broker.store(pers);
  +        broker.commitTransaction();
  +
  +        Identity oid = broker.serviceIdentity().buildIdentity(pers);
  +        broker.clearCache();
  +
  +        pers = (Person) broker.getObjectByIdentity(oid);
  +        projects = new ArrayList(pers.getProjects());
  +        assertEquals(projectsCount, projects.size());
  +        // remove one project
  +        projects.remove(0);
  +
  +        // add two new projects
  +        Project newProj = new Project();
  +        newProj.setTitle(name);
  +        newProj.setDescription("New test Project for Person_" + pers.getId());
           projects.add(newProj);
   
           newProj = new Project();
  -        newProj.setTitle("Test Project2 for Person 7");
  -        newProj.setDescription("This is a Test Project2 for Person 7");
  +        newProj.setTitle(name);
  +        newProj.setDescription("New test Project for Person_" + pers.getId());
           projects.add(newProj);
   
  +        pers.setProjects(projects);
  +
           broker.beginTransaction();
           broker.store(pers);
           broker.commitTransaction();
   
           broker.clearCache();
  +        pers = (Person) broker.getObjectByIdentity(oid);
  +        assertEquals(projectsCount + 1 , pers.getProjects().size());
   
  -        pers = (Person) broker.getObjectByQuery(query);
  -        assertEquals(count + 1 , pers.getProjects().size());
  +        projects = new ArrayList(pers.getProjects());
   
  +        int match  = 0;
  +        for(int i = 0; i < projects.size(); i++)
  +        {
  +            Project project = (Project) projects.get(i);
  +            if(project.getDescription() != null && project.getDescription().indexOf("_"+pers.getId()) > -1)
  +            {
  +                ++match;
  +            }
  +        }
  +        assertEquals("Expect two matches", 2, match);
       }
   
       /**
  
  
  
  1.13      +4 -4      db-ojb/src/test/org/apache/ojb/broker/OJBPerfTest.java
  
  Index: OJBPerfTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/OJBPerfTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- OJBPerfTest.java	11 Aug 2004 00:39:45 -0000	1.12
  +++ OJBPerfTest.java	14 Sep 2004 16:46:08 -0000	1.13
  @@ -413,17 +413,17 @@
   
           public void updateArticles(PerfArticle[] arr) throws Exception
           {
  -            ObjectModificationDefaultImpl needsInsert = new ObjectModificationDefaultImpl(false, true);
               PersistenceBroker broker = null;
               try
               {
                   broker = PersistenceBrokerFactory.defaultPersistenceBroker();
                   broker.serviceConnectionManager().setBatchMode(true);
                   broker.beginTransaction();
  +                String[] modifiedFieldName = new String[]{"articleName"};
                   for (int i = 0; i < arr.length; i++)
                   {
  -                    broker.store(arr[i], needsInsert);
  -                    // broker.store(arr[i]);
  +                    broker.store(arr[i], org.apache.ojb.broker.OJB.UPDATE);
  +                    // broker.update(arr[i], modifiedFieldName);
                   }
                   broker.commitTransaction();
               }
  
  
  
  1.13      +97 -41    db-ojb/src/test/org/apache/ojb/broker/OptimisticLockingTest.java
  
  Index: OptimisticLockingTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/OptimisticLockingTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- OptimisticLockingTest.java	30 Jul 2004 23:20:25 -0000	1.12
  +++ OptimisticLockingTest.java	14 Sep 2004 16:46:08 -0000	1.13
  @@ -7,20 +7,74 @@
    */
   public class OptimisticLockingTest extends PBTestCase
   {
  -	public static void main(String[] args)
  -	{
  -		String[] arr = {OptimisticLockingTest.class.getName()};
  -		junit.textui.TestRunner.main(arr);
  -	}
  -
  -	public OptimisticLockingTest(String name)
  -	{
  -		super(name);
  -	}
  -
  -	/** Test optimistic Lock by version.*/
  -	public void testVersionLock() throws Exception
  -	{
  +    public static void main(String[] args)
  +    {
  +        String[] arr = {OptimisticLockingTest.class.getName()};
  +        junit.textui.TestRunner.main(arr);
  +    }
  +
  +    public OptimisticLockingTest(String name)
  +    {
  +        super(name);
  +    }
  +
  +//    /** internal developer test. optimistic Lock by version.*/
  +//	public void testVersionLockDirectConnection() throws Exception
  +//	{
  +//        LockedByVersion obj = new LockedByVersion();
  +//        obj.setValue("original");
  +//        Identity oid = new Identity(obj, broker);
  +//        broker.beginTransaction();
  +//        broker.store(obj);
  +//        broker.commitTransaction();
  +//
  +//        broker.clearCache();
  +//        LockedByVersion copy1 = (LockedByVersion) broker.getObjectByIdentity(oid);
  +//        broker.clearCache();
  +//        LockedByVersion copy2 = (LockedByVersion) broker.getObjectByIdentity(oid);
  +//
  +//        copy1.setValue("copy 1");
  +//        copy2.setValue("copy 2");
  +//        assertEquals("Expect same version number", copy1.getVersion(), copy2.getVersion());
  +//
  +//        broker.beginTransaction();
  +//        Connection con = broker.serviceConnectionManager().getConnection();
  +//        PreparedStatement stmt = con.prepareStatement(
  +//                "UPDATE LOCKED_BY_VERSION SET VALUE_= ?, VERSION_= ?  WHERE ID = ?  AND VERSION_ = ? ");
  +//        stmt.setString(1, "copy_direct");
  +//        stmt.setInt(2, 1);
  +//        stmt.setInt(3, copy1.getId());
  +//        stmt.setInt(4, 1);
  +//        stmt.addBatch();
  +//
  +//        int[] result = stmt.executeBatch();
  +//        assertEquals(1, result.length);
  +//        assertEquals(1, result[0]);
  +//        broker.commitTransaction();
  +//        assertTrue("Expect different version number", copy1.getVersion() != copy2.getVersion());
  +//        try
  +//        {
  +//            // as copy1 has already been stored the version info of copy2
  +//            // is out of sync with the database !
  +//            broker.beginTransaction();
  +//            broker.store(copy2);
  +//            broker.commitTransaction();
  +//        }
  +//        catch (OptimisticLockException ex)
  +//        {
  +//            assertTrue(true);
  +//            //LoggerFactory.getDefaultLogger().debug(ex);
  +//            broker.abortTransaction();
  +//            return;
  +//        }
  +//        fail("Should throw an Optimistic Lock exception");
  +//	}
  +
  +    /**
  +     * Test optimistic Lock by version.
  +     */
  +    public void testVersionLock() throws Exception
  +    {
           LockedByVersion obj = new LockedByVersion();
           obj.setValue("original");
           Identity oid = new Identity(obj, broker);
  @@ -43,8 +97,8 @@
           assertTrue("Expect different version number", copy1.getVersion() != copy2.getVersion());
           try
           {
  -            // as copy1 has already been stored the version info of copy2
  -            // is out of sync with the database !
  +// as copy1 has already been stored the version info of copy2
  +// is out of sync with the database !
               broker.beginTransaction();
               broker.store(copy2);
               broker.commitTransaction();
  @@ -52,19 +106,19 @@
           catch (OptimisticLockException ex)
           {
               assertTrue(true);
  -            //LoggerFactory.getDefaultLogger().debug(ex);
  +//LoggerFactory.getDefaultLogger().debug(ex);
               broker.abortTransaction();
               return;
           }
           fail("Should throw an Optimistic Lock exception");
  -	}
  +    }
   
  -	/**
  -	 * demonstrates how OptimisticLockExceptions can be used
  -	 * to handle resynchronization of conflicting instances.
  -	 */
  -	public void testLockHandling() throws Exception
  -	{
  +    /**
  +     * demonstrates how OptimisticLockExceptions can be used
  +     * to handle resynchronization of conflicting instances.
  +     */
  +    public void testLockHandling() throws Exception
  +    {
           LockedByVersion obj = new LockedByVersion();
           obj.setValue("original");
           Identity oid = new Identity(obj, broker);
  @@ -87,36 +141,38 @@
           assertTrue("Expect different version number", copy1.getVersion() != copy2.getVersion());
           try
           {
  -            // as copy1 has already been stored the version info of copy2
  -            // is out of sync with the database !
  +// as copy1 has already been stored the version info of copy2
  +// is out of sync with the database !
               broker.beginTransaction();
               broker.store(copy2);
               broker.commitTransaction();
           }
           catch (OptimisticLockException ex)
           {
  -            // obtain conflicting object from exception
  +// obtain conflicting object from exception
               Object conflictingObject = ex.getSourceObject();
   
  -            // get a synchronized instance
  +// get a synchronized instance
               broker.removeFromCache(conflictingObject);
               Object syncronizedObject = broker.getObjectByIdentity(new Identity(conflictingObject, broker));
   
  -            // modify synchronized copy and call store again without trouble
  +// modify synchronized copy and call store again without trouble
               ((LockedByVersion) syncronizedObject).setValue("copy 3");
  -            if(!broker.isInTransaction()) broker.beginTransaction();
  +            if (!broker.isInTransaction()) broker.beginTransaction();
               broker.store(syncronizedObject);
               broker.commitTransaction();
               return;
           }
           fail("Should throw an Optimistic Lock exception");
  -	}
  +    }
   
   
  -/** Test optimistic Lock by timestamp.*/
  -	public void testTimestampLock() throws Exception
  -	{
  -		LockedByTimestamp obj = new LockedByTimestamp();
  +    /**
  +     * Test optimistic Lock by timestamp.
  +     */
  +    public void testTimestampLock() throws Exception
  +    {
  +        LockedByTimestamp obj = new LockedByTimestamp();
           obj.setValue("original");
           Identity oid = new Identity(obj, broker);
           broker.beginTransaction();
  @@ -153,7 +209,7 @@
               broker.abortTransaction();
           }
   
  -        if(!broker.isInTransaction()) broker.beginTransaction();
  +        if (!broker.isInTransaction()) broker.beginTransaction();
           broker.delete(copy1);
           broker.commitTransaction();
   
  @@ -165,12 +221,12 @@
           }
           catch (OptimisticLockException e)
           {
  -           // BRJ: exception thrown if object has been modified or deleted 
  -           // 
  -           // fail("If an object which use optimistic locking was deleted two times, OJB" +
  -           //         " should not throw an optimistic locking exception: "+e.getMessage());
  +            // BRJ: exception thrown if object has been modified or deleted
  +            //
  +            // fail("If an object which use optimistic locking was deleted two times, OJB" +
  +            //         " should not throw an optimistic locking exception: "+e.getMessage());
               broker.abortTransaction();
  -           return;
  +            return;
           }
           fail("Should throw an Optimistic Lock exception");
       }
  
  
  
  1.9       +4 -0      db-ojb/src/test/org/apache/ojb/broker/PBRollbackTest.java
  
  Index: PBRollbackTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PBRollbackTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PBRollbackTest.java	31 May 2004 22:57:21 -0000	1.8
  +++ PBRollbackTest.java	14 Sep 2004 16:46:08 -0000	1.9
  @@ -60,6 +60,8 @@
           Query q = new QueryByCriteria(Project.class, c);
           int beforeCommit = broker.getCount(q);
   
  +        // Don't use batch statements
  +        broker.serviceConnectionManager().setBatchMode(false);
           broker.beginTransaction();
           broker.clearCache();
           storeObjects(broker, getNewProjects(10));
  @@ -94,6 +96,8 @@
           Query q = new QueryByCriteria(Project.class, c);
           int beforeCommit = broker.getCount(q);
   
  +        // Don't use batch statements
  +        broker.serviceConnectionManager().setBatchMode(false);
           broker.beginTransaction();
           storeObjects(broker, getNewProjects(10));
           int whileTransaction = broker.getCount(q);
  
  
  
  1.15      +0 -1      db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java
  
  Index: PerformanceJdbcReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PerformanceJdbcReferenceTest.java	11 Aug 2004 00:39:45 -0000	1.14
  +++ PerformanceJdbcReferenceTest.java	14 Sep 2004 16:46:08 -0000	1.15
  @@ -4,7 +4,6 @@
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.accesslayer.ConnectionFactory;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  
  
  
  1.13      +2 -13     db-ojb/src/test/org/apache/ojb/broker/PerformanceTest.java
  
  Index: PerformanceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PerformanceTest.java	11 Aug 2004 00:39:45 -0000	1.12
  +++ PerformanceTest.java	14 Sep 2004 16:46:08 -0000	1.13
  @@ -1,13 +1,9 @@
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
  -
  -import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl;
   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.util.ObjectModificationDefaultImpl;
  -import org.apache.ojb.broker.util.configuration.impl.OjbConfiguration;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.junit.PBTestCase;
  @@ -123,14 +119,11 @@
        */
       protected void insertNewArticles() throws PersistenceBrokerException
       {
  -        ObjectModificationDefaultImpl needsInsert = new ObjectModificationDefaultImpl();
  -        needsInsert.setNeedsInsert(true);
  -
           long start = System.currentTimeMillis();
           broker.beginTransaction();
           for (int i = 0; i < articleCount; i++)
           {
  -            broker.store(arr[i], needsInsert);
  +            broker.store(arr[i], OJB.INSERT);
           }
           broker.commitTransaction();
           long stop = System.currentTimeMillis();
  @@ -201,15 +194,11 @@
               arr[i].setPrice(arr[i].getPrice() * 1.95583);
           }
   
  -        // build mod object that tell OJB to use UPDATE
  -        ObjectModificationDefaultImpl needsUpdate = new ObjectModificationDefaultImpl();
  -        needsUpdate.setNeedsUpdate(true);
  -
           long start = System.currentTimeMillis();
           broker.beginTransaction();
           for (int i = 0; i < articleCount; i++)
           {
  -            broker.store(arr[i], needsUpdate);
  +            broker.store(arr[i], OJB.UPDATE);
           }
           broker.commitTransaction();
           long stop = System.currentTimeMillis();
  
  
  
  1.23      +2 -6      db-ojb/src/test/org/apache/ojb/broker/PerformanceTest2.java
  
  Index: PerformanceTest2.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceTest2.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- PerformanceTest2.java	11 Aug 2004 00:39:45 -0000	1.22
  +++ PerformanceTest2.java	14 Sep 2004 16:46:08 -0000	1.23
  @@ -693,10 +693,6 @@
   
           protected void insertNewArticles() throws Exception
           {
  -
  -            ObjectModificationDefaultImpl needsInsert = new ObjectModificationDefaultImpl();
  -            needsInsert.setNeedsInsert(true);
  -
               long start = System.currentTimeMillis();
   
               for (int i = 0; i < arr.length; i++)
  @@ -706,7 +702,7 @@
                   {
                       broker = PersistenceBrokerFactory.defaultPersistenceBroker();
                       broker.beginTransaction();
  -                    broker.store(arr[i], needsInsert);
  +                    broker.store(arr[i], org.apache.ojb.broker.OJB.INSERT);
                       broker.commitTransaction();
                   }
                   finally
  
  
  
  1.11      +2 -12     db-ojb/src/test/org/apache/ojb/broker/PerformanceTest3.java
  
  Index: PerformanceTest3.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceTest3.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PerformanceTest3.java	30 Jul 2003 21:17:34 -0000	1.10
  +++ PerformanceTest3.java	14 Sep 2004 16:46:08 -0000	1.11
  @@ -602,10 +602,6 @@
   
           protected void insertNewArticles() throws Exception
           {
  -
  -            ObjectModificationDefaultImpl needsInsert = new ObjectModificationDefaultImpl();
  -            needsInsert.setNeedsInsert(true);
  -
               long start = System.currentTimeMillis();
   
               for (int i = 0; i < arr.length; i++)
  @@ -615,7 +611,7 @@
                   {
                       broker = PersistenceBrokerFactory.defaultPersistenceBroker();
                       broker.beginTransaction();
  -                    broker.store(arr[i], needsInsert);
  +                    broker.store(arr[i], org.apache.ojb.broker.OJB.INSERT);
                       broker.commitTransaction();
                   }
                   finally
  @@ -631,12 +627,7 @@
   
           protected void insertNewFarAways() throws Exception
           {
  -
  -            ObjectModificationDefaultImpl needsInsert = new ObjectModificationDefaultImpl();
  -            needsInsert.setNeedsInsert(true);
  -
               long start = System.currentTimeMillis();
  -
               for (int i = 0; i < arr.length; i++)
               {
                   PersistenceBroker broker = null;
  @@ -644,14 +635,13 @@
                   {
                       broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey_FarAway);
                       broker.beginTransaction();
  -                    broker.store(arrFarAway[i], needsInsert);
  +                    broker.store(arrFarAway[i], org.apache.ojb.broker.OJB.INSERT);
                       broker.commitTransaction();
                   }
                   finally
                   {
                       if (broker != null) broker.close();
                   }
  -
               }
   
               long stop = System.currentTimeMillis();
  
  
  
  1.45      +12 -5     db-ojb/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java
  
  Index: PersistenceBrokerTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PersistenceBrokerTest.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- PersistenceBrokerTest.java	15 Aug 2004 12:42:29 -0000	1.44
  +++ PersistenceBrokerTest.java	14 Sep 2004 16:46:08 -0000	1.45
  @@ -163,6 +163,8 @@
           ObjectRepository.Component comp = new ObjectRepository.Component();
           comp.setName(name);
   
  +        // make sure not to use batch mode
  +        broker.serviceConnectionManager().setBatchMode(false);
           broker.beginTransaction();
           // store data
           broker.store(comp, ObjectModificationDefaultImpl.INSERT);
  @@ -204,14 +206,14 @@
           {
               broker.beginTransaction();
               // cleanup
  -            stmt = broker.serviceStatementManager().getGenericStatement(cld, false);
  +            stmt = broker.serviceStatementManager().getGenericStatement(false);
               stmt.executeUpdate(delete);
               broker.serviceStatementManager().closeResources(stmt, null);
               broker.commitTransaction();
   
               broker.beginTransaction();
               // prepare test
  -            stmt = broker.serviceStatementManager().getGenericStatement(cld, false);
  +            stmt = broker.serviceStatementManager().getGenericStatement(false);
               // insert object with 0 as PK
               stmt.executeUpdate(insert);
               broker.serviceStatementManager().closeResources(stmt, null);
  @@ -243,7 +245,7 @@
           {
               broker.beginTransaction();
               // cleanup
  -            stmt = broker.serviceStatementManager().getGenericStatement(cld, false);
  +            stmt = broker.serviceStatementManager().getGenericStatement(false);
               stmt.executeUpdate(delete);
               broker.serviceStatementManager().closeResources(stmt, null);
               broker.commitTransaction();
  @@ -265,7 +267,7 @@
           try
           {
               broker.beginTransaction();
  -            stmt = broker.serviceStatementManager().getGenericStatement(cld, false);
  +            stmt = broker.serviceStatementManager().getGenericStatement(false);
               stmt.executeUpdate(delete);
               broker.serviceStatementManager().closeResources(stmt, null);
               broker.commitTransaction();
  @@ -300,7 +302,7 @@
           {
               broker.beginTransaction();
               // cleanup
  -            stmt = broker.serviceStatementManager().getGenericStatement(cld, false);
  +            stmt = broker.serviceStatementManager().getGenericStatement(false);
               stmt.executeUpdate(delete);
               broker.serviceStatementManager().closeResources(stmt, null);
               broker.commitTransaction();
  @@ -1641,6 +1643,11 @@
   
       public void testChangeFieldsWhileStoringObject()
       {
  +        // batch manager isn't smart enough to detect multiple insert
  +        // of same object with different values in same tx, so disable
  +        // batch mode
  +        broker.serviceConnectionManager().setBatchMode(false);
  +
           long timestamp = System.currentTimeMillis();
   
           broker.beginTransaction();
  
  
  
  1.2       +9 -2      db-ojb/src/test/org/apache/ojb/broker/Person.java
  
  Index: Person.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Person.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Person.java	20 Jun 2002 17:07:50 -0000	1.1
  +++ Person.java	14 Sep 2004 16:46:08 -0000	1.2
  @@ -28,6 +28,8 @@
   import java.util.Collection;
   import java.io.Serializable;
   
  +import org.apache.commons.lang.builder.ToStringBuilder;
  +
   public class Person implements Serializable
   {
   
  @@ -100,8 +102,13 @@
   
       public String toString()
       {
  -        String result = firstname;
  -        return result;
  +        return new ToStringBuilder(this)
  +                .append("id", id)
  +                .append("firstname", firstname)
  +                .append("lastname", lastname)
  +                .append("projects size", projects != null ? projects.size() : 0)
  +                .append("role size", roles != null ? roles.size() : 0)
  +                .toString();
       }
   
   }
  
  
  
  1.16      +0 -4      db-ojb/src/test/org/apache/ojb/broker/PolymorphicExtents.java
  
  Index: PolymorphicExtents.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PolymorphicExtents.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- PolymorphicExtents.java	11 Aug 2004 00:39:45 -0000	1.15
  +++ PolymorphicExtents.java	14 Sep 2004 16:46:08 -0000	1.16
  @@ -2,12 +2,8 @@
   
   import java.util.Collection;
   
  -import junit.framework.TestCase;
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
  -import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.Query;
  -import org.apache.ojb.broker.query.QueryByIdentity;
   import org.apache.ojb.broker.query.QueryFactory;
   import org.apache.ojb.junit.PBTestCase;
   
  
  
  
  1.2       +9 -5      db-ojb/src/test/org/apache/ojb/broker/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Project.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Project.java	20 Jun 2002 17:07:50 -0000	1.1
  +++ Project.java	14 Sep 2004 16:46:08 -0000	1.2
  @@ -28,6 +28,8 @@
   import java.util.Collection;
   import java.io.Serializable;
   
  +import org.apache.commons.lang.builder.ToStringBuilder;
  +
   public class Project implements Serializable
   {
       private int id;
  @@ -101,10 +103,12 @@
   
       public String toString()
       {
  -        String result = title;
  -        result += " ";
  -        result += persons;
  -
  -        return result;
  +        return new ToStringBuilder(this)
  +                .append("id", id)
  +                .append("title", title)
  +                .append("description", description)
  +                .append("person size", persons != null ? persons.size() : 0)
  +                .append("role size", roles != null ? roles.size() : 0)
  +                .toString();
       }
   }
  
  
  
  1.18      +2 -0      db-ojb/src/test/org/apache/ojb/broker/ProxyExamples.java
  
  Index: ProxyExamples.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ProxyExamples.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ProxyExamples.java	11 Aug 2004 00:39:45 -0000	1.17
  +++ ProxyExamples.java	14 Sep 2004 16:46:08 -0000	1.18
  @@ -328,6 +328,8 @@
           boolean commit = false;
           try
           {
  +            // Don't use batch statements
  +            broker.serviceConnectionManager().setBatchMode(false);
               // Start transaction
               broker.beginTransaction();
   
  
  
  
  1.73      +59 -1     db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- QueryTest.java	27 Aug 2004 19:57:07 -0000	1.72
  +++ QueryTest.java	14 Sep 2004 16:46:08 -0000	1.73
  @@ -8,6 +8,7 @@
   import java.util.Iterator;
   import java.util.Set;
   import java.util.Vector;
  +import java.util.List;
   
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.query.Criteria;
  @@ -19,6 +20,7 @@
   import org.apache.ojb.broker.query.ReportQueryByCriteria;
   import org.apache.ojb.broker.platforms.PlatformHsqldbImpl;
   import org.apache.ojb.junit.PBTestCase;
  +import org.apache.commons.lang.time.StopWatch;
   
   /**
    * Testing the query API
  @@ -1603,7 +1605,63 @@
           // ProductGroup 4 with it's Articles
           assertEquals("check size", list.size(), 1);
       }
  -    
  +
  +    /**
  +     * Run a query range test.
  +     */
  +    public void testQueryRangeMassTest()
  +    {
  +        String name = "testQueryRangeMassTest_" + System.currentTimeMillis();
  +        int objCount = 2000;
  +
  +        broker.beginTransaction();
  +        for(int i = 0; i < objCount; i++)
  +        {
  +            Gourmet a = new Gourmet();
  +            a.setName(name);
  +            broker.store(a);
  +        }
  +        broker.commitTransaction();
  +
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name", name);
  +        QueryByCriteria q = QueryFactory.newQuery(Gourmet.class, crit);
  +        q.setStartAtIndex(10);
  +        q.setEndAtIndex(19);
  +
  +        StopWatch watch = new StopWatch();
  +        watch.start();
  +        Collection c = broker.getCollectionByQuery(q);
  +        watch.stop();
  +        System.out.println("# Query 10 of " + objCount + " objects take " + watch.getTime() + " ms");
  +        assertNotNull(c);
  +        List result = new ArrayList(c);
  +        assertEquals(10, result.size());
  +
  +        crit = new Criteria();
  +        crit.addEqualTo("name", name);
  +        q = QueryFactory.newQuery(Gourmet.class, crit);
  +        watch.start();
  +        c = broker.getCollectionByQuery(q);
  +        watch.stop();
  +        System.out.println("# Query all " + objCount + " objects take " + watch.getTime() + " ms");
  +        assertNotNull(c);
  +        result = new ArrayList(c);
  +        assertEquals(objCount, result.size());
  +
  +        broker.beginTransaction();
  +        for(int i = 0; i < result.size(); i++)
  +        {
  +            broker.delete(result.get(i));
  +        }
  +        broker.commitTransaction();
  +
  +        c = broker.getCollectionByQuery(q);
  +        assertNotNull(c);
  +        result = new ArrayList(c);
  +        assertEquals(0, result.size());
  +    }
  +
       /**
   	 * Run a query range test that includes one record less than the total
   	 * number of records that exist.
  
  
  
  1.10      +0 -1      db-ojb/src/test/org/apache/ojb/broker/TypedCollectionsTest.java
  
  Index: TypedCollectionsTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/TypedCollectionsTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TypedCollectionsTest.java	11 Aug 2004 00:39:45 -0000	1.9
  +++ TypedCollectionsTest.java	14 Sep 2004 16:46:08 -0000	1.10
  @@ -1,6 +1,5 @@
   package org.apache.ojb.broker;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.query.QueryByIdentity;
   import org.apache.ojb.junit.PBTestCase;
   
  
  
  
  1.5       +0 -1      db-ojb/src/test/org/apache/ojb/broker/Zoo.java
  
  Index: Zoo.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Zoo.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Zoo.java	22 Jun 2004 18:16:22 -0000	1.4
  +++ Zoo.java	14 Sep 2004 16:46:08 -0000	1.5
  @@ -1,7 +1,6 @@
   package org.apache.ojb.broker;
   
   import java.io.Serializable;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Vector;
   
  
  
  

---------------------------------------------------------------------
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