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/java/org/apache/ojb/odmg DatabaseImpl.java ImplementationExt.java ImplementationImpl.java NamedRootsMap.java NarrowTransaction.java ObjectEnvelope.java ObjectEnvelopeTable.java TransactionExt.java TransactionImpl.java
Date Sat, 04 Jun 2005 14:38:14 GMT
arminw      2005/06/04 07:38:14

  Modified:    src/java/org/apache/ojb/odmg/collections Tag:
                        OJB_1_0_RELEASE DListEntry.java DListImpl.java
                        DListIterator.java DMapImpl.java DSetImpl.java
               src/java/org/apache/ojb/odmg/states Tag: OJB_1_0_RELEASE
                        StateNewDelete.java StateOldDelete.java
               src/java/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        DatabaseImpl.java ImplementationExt.java
                        ImplementationImpl.java NamedRootsMap.java
                        NarrowTransaction.java ObjectEnvelope.java
                        ObjectEnvelopeTable.java TransactionExt.java
                        TransactionImpl.java
  Added:       src/java/org/apache/ojb/odmg/states Tag: OJB_1_0_RELEASE
                        StateTransient.java
  Removed:     src/java/org/apache/ojb/odmg/collections Tag:
                        OJB_1_0_RELEASE DCollectionFactory.java
  Log:
  - new feature, allow to use auto-delete="object" to enable cascading delete for odmg-api add new odmg-extensions/properties: ordering
  - 'ordering' Allow to dis-/enable OJB's object ordering on transaction commit
  - 'noteUserOrder' If true the order of persisting/locking method calls determine the order of objects before commit.
  - 'implicitLocking' Dis-/enable OJB's implicit locking
  - introduce new object state 'StateTransient' for deleted, not persistent objects
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.25.2.3  +2 -2      db-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java
  
  Index: DListEntry.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java,v
  retrieving revision 1.25.2.2
  retrieving revision 1.25.2.3
  diff -u -r1.25.2.2 -r1.25.2.3
  --- DListEntry.java	3 May 2005 17:09:04 -0000	1.25.2.2
  +++ DListEntry.java	4 Jun 2005 14:38:13 -0000	1.25.2.3
  @@ -149,7 +149,7 @@
                   if(realSubject != null)
                   {
                       RuntimeObject rt = new RuntimeObject(realSubject, tx, false);
  -                    tx.lockAndRegister(rt, Transaction.READ, true, tx.getRegistrationList());
  +                    tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList());
                   }
               }
               else
  
  
  
  1.27.2.4  +3 -3      db-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java
  
  Index: DListImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java,v
  retrieving revision 1.27.2.3
  retrieving revision 1.27.2.4
  diff -u -r1.27.2.3 -r1.27.2.4
  --- DListImpl.java	3 May 2005 17:09:04 -0000	1.27.2.3
  +++ DListImpl.java	4 Jun 2005 14:38:13 -0000	1.27.2.4
  @@ -171,7 +171,7 @@
               tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
               rt = new RuntimeObject(element, tx);
  -            tx.lockAndRegister(rt, Transaction.READ, true, regList);
  +            tx.lockAndRegister(rt, Transaction.READ, regList);
   
               rt = new RuntimeObject(entry, tx, true);
               tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
  @@ -217,7 +217,7 @@
           TransactionImpl tx = getTransaction();
           if (checkForOpenTransaction(tx))
           {
  -            tx.getAssociatedDatabase().deletePersistent(entry);
  +            tx.deletePersistent(new RuntimeObject(entry, tx));
           }
           elements.remove(index);
           // changing the position markers of entries:
  
  
  
  1.8.2.3   +2 -2      db-ojb/src/java/org/apache/ojb/odmg/collections/DListIterator.java
  
  Index: DListIterator.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DListIterator.java,v
  retrieving revision 1.8.2.2
  retrieving revision 1.8.2.3
  diff -u -r1.8.2.2 -r1.8.2.3
  --- DListIterator.java	3 May 2005 17:09:04 -0000	1.8.2.2
  +++ DListIterator.java	4 Jun 2005 14:38:13 -0000	1.8.2.3
  @@ -63,7 +63,7 @@
           if (tx != null)
           {
               RuntimeObject rt = new RuntimeObject(entry, tx, true);
  -            tx.lockAndRegister(rt, Transaction.WRITE, true, tx.getRegistrationList());
  +            tx.lockAndRegister(rt, Transaction.WRITE, false, tx.getRegistrationList());
           }
       }
   
  
  
  
  1.21.2.3  +4 -4      db-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java
  
  Index: DMapImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java,v
  retrieving revision 1.21.2.2
  retrieving revision 1.21.2.3
  diff -u -r1.21.2.2 -r1.21.2.3
  --- DMapImpl.java	3 May 2005 17:09:04 -0000	1.21.2.2
  +++ DMapImpl.java	4 Jun 2005 14:38:13 -0000	1.21.2.3
  @@ -153,10 +153,10 @@
                   tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
                   rt = new RuntimeObject(key, tx);
  -                tx.lockAndRegister(rt, Transaction.READ, true, regList);
  +                tx.lockAndRegister(rt, Transaction.READ, regList);
   
                   rt = new RuntimeObject(value, tx);
  -                tx.lockAndRegister(rt, Transaction.READ, true, regList);
  +                tx.lockAndRegister(rt, Transaction.READ, regList);
   
                   rt = new RuntimeObject(entry, tx, true);
                   tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
  @@ -201,7 +201,7 @@
               TransactionImpl tx = getTransaction();
               if ((tx != null) && (tx.isOpen()))
               {
  -                tx.getAssociatedDatabase().deletePersistent(correctEntry);
  +                tx.deletePersistent(new RuntimeObject(correctEntry, tx));
               }
           }
           return oldValue;
  
  
  
  1.21.2.4  +1 -1      db-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java
  
  Index: DSetImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java,v
  retrieving revision 1.21.2.3
  retrieving revision 1.21.2.4
  diff -u -r1.21.2.3 -r1.21.2.4
  --- DSetImpl.java	3 May 2005 17:09:04 -0000	1.21.2.3
  +++ DSetImpl.java	4 Jun 2005 14:38:13 -0000	1.21.2.4
  @@ -160,7 +160,7 @@
                   tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
   
                   rt = new RuntimeObject(o, tx);
  -                tx.lockAndRegister(rt, Transaction.READ, true, regList);
  +                tx.lockAndRegister(rt, Transaction.READ, regList);
   
                   rt = new RuntimeObject(entry, tx, true);
                   tx.lockAndRegister(rt, Transaction.WRITE, false, regList);
  
  
  
  No                   revision
  No                   revision
  1.5.2.4   +2 -0      db-ojb/src/java/org/apache/ojb/odmg/states/StateNewDelete.java
  
  Index: StateNewDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateNewDelete.java,v
  retrieving revision 1.5.2.3
  retrieving revision 1.5.2.4
  diff -u -r1.5.2.3 -r1.5.2.4
  --- StateNewDelete.java	3 Apr 2005 01:50:14 -0000	1.5.2.3
  +++ StateNewDelete.java	4 Jun 2005 14:38:13 -0000	1.5.2.4
  @@ -101,6 +101,7 @@
       public void commit(ObjectEnvelope mod)
       {
           mod.doEvictFromCache();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  @@ -109,5 +110,6 @@
       public void rollback(ObjectEnvelope mod)
       {
           mod.doEvictFromCache();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   }
  
  
  
  1.5.2.3   +2 -0      db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java
  
  Index: StateOldDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- StateOldDelete.java	18 Mar 2005 19:25:06 -0000	1.5.2.2
  +++ StateOldDelete.java	4 Jun 2005 14:38:13 -0000	1.5.2.3
  @@ -96,6 +96,7 @@
               throws org.apache.ojb.broker.PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  @@ -104,6 +105,7 @@
       public void commit(ObjectEnvelope mod) throws PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  
  
  
  No                   revision
  
  Index: StateOldDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- StateOldDelete.java	18 Mar 2005 19:25:06 -0000	1.5.2.2
  +++ StateOldDelete.java	4 Jun 2005 14:38:13 -0000	1.5.2.3
  @@ -96,6 +96,7 @@
               throws org.apache.ojb.broker.PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  @@ -104,6 +105,7 @@
       public void commit(ObjectEnvelope mod) throws PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  
  
  
  No                   revision
  
  Index: StateOldDelete.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/states/StateOldDelete.java,v
  retrieving revision 1.5.2.2
  retrieving revision 1.5.2.3
  diff -u -r1.5.2.2 -r1.5.2.3
  --- StateOldDelete.java	18 Mar 2005 19:25:06 -0000	1.5.2.2
  +++ StateOldDelete.java	4 Jun 2005 14:38:13 -0000	1.5.2.3
  @@ -96,6 +96,7 @@
               throws org.apache.ojb.broker.PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  @@ -104,6 +105,7 @@
       public void commit(ObjectEnvelope mod) throws PersistenceBrokerException
       {
           mod.doDelete();
  +        mod.setModificationState(StateTransient.getInstance());
       }
   
       /**
  
  
  
  1.1.2.1   +112 -0    db-ojb/src/java/org/apache/ojb/odmg/states/Attic/StateTransient.java
  
  
  
  
  No                   revision
  No                   revision
  1.26.2.6  +6 -20     db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java
  
  Index: DatabaseImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/DatabaseImpl.java,v
  retrieving revision 1.26.2.5
  retrieving revision 1.26.2.6
  diff -u -r1.26.2.5 -r1.26.2.6
  --- DatabaseImpl.java	3 May 2005 17:09:04 -0000	1.26.2.5
  +++ DatabaseImpl.java	4 Jun 2005 14:38:13 -0000	1.26.2.6
  @@ -293,24 +293,9 @@
           {
               throw new TransactionNotInProgressException("No transaction in progress, cannot persist");
           }
  -
           RuntimeObject rt = new RuntimeObject(object, getTransaction());
  -        makePersistent(rt);
  -    }
  -
  -    void makePersistent(RuntimeObject rt)
  -    {
  -        TransactionImpl tx = getTransaction();
  -        try
  -        {
  -            tx.lockAndRegister(rt, Transaction.WRITE, false, tx.getRegistrationList());
  -            tx.markPersistent(rt);
  -        }
  -        catch (org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException ex)
  -        {
  -            log.error("Can't persist object: " + rt.getIdentity(), ex);
  -            throw new org.odmg.ClassNotPersistenceCapableException(ex.getMessage());
  -        }
  +        tx.makePersistent(rt);
  +        tx.moveToLastInOrderList(rt.getIdentity());
       }
   
       /**
  @@ -335,7 +320,8 @@
           {
               throw new TransactionNotInProgressException("No transaction in progress, cannot delete persistent");
           }
  -        tx.lockAndRegister(new RuntimeObject(object, tx), Transaction.WRITE, false, tx.getRegistrationList());
  -        tx.markDelete(object);
  +        RuntimeObject rt = new RuntimeObject(object, tx);
  +        tx.deletePersistent(rt);
  +        tx.moveToLastInOrderList(rt.getIdentity());
       }
   }
  
  
  
  1.1.2.3   +105 -2    db-ojb/src/java/org/apache/ojb/odmg/Attic/ImplementationExt.java
  
  Index: ImplementationExt.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/Attic/ImplementationExt.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- ImplementationExt.java	3 Apr 2005 02:38:45 -0000	1.1.2.2
  +++ ImplementationExt.java	4 Jun 2005 14:38:13 -0000	1.1.2.3
  @@ -66,8 +66,111 @@
        * Is <em>true</em> when implicite write locks are enabled.
        *
        * @return <em>true</em> when implicit write locks are enabled.
  +     * @see #setImpliciteWriteLocks(boolean)
        */
  -    boolean isImpliciteWriteLocks();
  +    public boolean isImpliciteWriteLocks();
  +
  +    /**
  +     * Set the global property <em>implicit locking</em>. This method can be used
  +     * to activate or deactivate the global implicit
  +     * locking mechanism.
  +     * <br/>
  +     * If set <em>true</em> OJB implicitly locks objects to ODMG transactions
  +     * after performing OQL queries. Also if implicit locking is used
  +     * locking objects is recursive, that is associated objects are also
  +     * locked. If ImplicitLocking is set to 'false', no locks are obtained
  +     * in OQL queries, lookup objects and there is also no recursive locking.
  +     * <p/>
  +     * However it's possible to set this value only for the current used {@link org.odmg.Transaction}
  +     * using {@link TransactionExt#setImplicitLocking(boolean)} and to detect the implicit locking
  +     * state of the used transaction instance call {@link TransactionExt#isImplicitLocking()}.
  +     * <br/>
  +     * Turning of implicit locking may improve performance but requires
  +     * additional care to make sure that all changed objects are properly
  +     * registered to the transaction.
  +     *
  +     * @param impliciteLocking If set <em>true</em> implicit locking is enabled,
  +     *        if <em>false</em>, implicit locking is disabled.
  +     */
  +    public void setImplicitLocking(boolean impliciteLocking);
  +
  +    /**
  +     * Returns <em>true</em> if the global implicit locking is enabled
  +     * for this {@link org.odmg.Implementation} instance, else <em>false</em>.
  +     * <br/>
  +     * <strong>Important:</strong> The returned value is the global used setting for all
  +     * {@link org.odmg.Transaction#lock(Object, int)} calls.
  +     * <br/>
  +     * However it's possible to set this value only for the current used {@link org.odmg.Transaction}
  +     * using {@link TransactionExt#setImplicitLocking(boolean)} and to detect the implicit locking
  +     * state of the used transaction instance call {@link TransactionExt#isImplicitLocking()}.
  +     *
  +     * @return <em>true</em> if the global property <em>implicit locking</em><em>true</em> is enabled.
  +     * @see #setImplicitLocking(boolean)
  +     */
  +    public boolean isImplicitLocking();
  +
  +    /**
  +     * Returns <em>true</em> if OJB's ordering algorithm is enabled.
  +     *
  +     * @see #setOrdering(boolean)
  +     */
  +    public boolean isOrdering();
  +
  +    /**
  +     * Disable/enable OJB's ordering algorithm when insert, update, delete a
  +     * bunch of objects within a transaction. The ordering algorithm try to
  +     * calculate the correct order of the modified/new persistent objects to
  +     * prevent problems on commit of the transaction.
  +     * <br/>
  +     * If the used databases support 'deferred checks' it's recommended to
  +     * use this feature and to disable OJB's object ordering.
  +     * <p/>
  +     * However it's possible to set this value only for the current
  +     * used {@link org.odmg.Transaction} using {@link TransactionExt#setOrdering(boolean)}
  +     *
  +     * @param ordering If <em>true</em> OJB's ordering algorithm is used.
  +     */
  +    public void setOrdering(boolean ordering);
  +
  +    /**
  +     * Returns whether or not the persistent method calls determine
  +     * the persistent object order on commit.
  +     *
  +     * @see #setNoteUserOrder(boolean)
  +     */
  +    public boolean isNoteUserOrder();
  +
  +    /**
  +     * If <em>true</em> the order of persisting method calls like
  +     * <br/> - {@link org.odmg.Transaction#lock(Object, int)}).
  +     * <br/> - {@link org.odmg.Database#deletePersistent(Object)}).
  +     * <br/> - {@link org.odmg.Database#makePersistent(Object)})
  +     * determine the order of objects before commit.
  +     * <br/>
  +     * If <em>false</em> the ordering was determined by OJB's internal
  +     * method calls and user calls.
  +     * <br/>
  +     * However it's possible to set this value only for the current
  +     * used {@link org.odmg.Transaction} using {@link TransactionExt#setNoteUserOrder(boolean)}
  +     * <p/>
  +     * <strong>NOTE:</strong> If OJB's ordering algorithm (see
  +     * {@link #setOrdering(boolean)}) is enabled, the
  +     * order of objects may change on commit.
  +     *
  +     * @param noteUserOrder If <em>true</em> the order of persisting
  +     * method calls determine the order of objects.
  +     */
  +    public void setNoteUserOrder(boolean noteUserOrder);
  +
  +
  +//    /**
  +//     * Get object by OJB's {@link org.apache.ojb.broker.Identity}.
  +//     *
  +//     * @param id The identity of the object to look for.
  +//     * @return The matching object or <em>null</em>.
  +//     */
  +//    public Object getObjectByIdentity(Identity id);
   
   //    /**
   //     * If set <em>true</em> the odmg implementation do it's best to find out the user intension, if set
  
  
  
  1.1.2.9   +166 -64   db-ojb/src/java/org/apache/ojb/odmg/ImplementationImpl.java
  
  Index: ImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ImplementationImpl.java,v
  retrieving revision 1.1.2.8
  retrieving revision 1.1.2.9
  diff -u -r1.1.2.8 -r1.1.2.9
  --- ImplementationImpl.java	3 May 2005 17:09:04 -0000	1.1.2.8
  +++ ImplementationImpl.java	4 Jun 2005 14:38:13 -0000	1.1.2.9
  @@ -15,22 +15,27 @@
    * limitations under the License.
    */
   
  +import java.util.ArrayList;
  +import java.util.List;
  +
  +import org.apache.commons.lang.SerializationUtils;
  +import org.apache.commons.lang.builder.ToStringBuilder;
  +import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
  +import org.apache.ojb.broker.util.collections.ManageableArrayList;
  +import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.broker.util.configuration.Configurator;
  -import org.apache.ojb.broker.util.configuration.Configuration;
  +import org.apache.ojb.broker.util.factory.ConfigurableFactory;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  -import org.apache.ojb.broker.util.collections.ManageableArrayList;
  -import org.apache.ojb.odmg.collections.DCollectionFactory;
  -import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
  -import org.apache.ojb.odmg.oql.OQLQueryImpl;
   import org.apache.ojb.odmg.locking.LockManager;
   import org.apache.ojb.odmg.locking.LockManagerFactory;
  -import org.apache.commons.lang.SerializationUtils;
  +import org.apache.ojb.odmg.oql.EnhancedOQLQuery;
  +import org.apache.ojb.odmg.oql.OQLQueryImpl;
   import org.odmg.DArray;
   import org.odmg.DBag;
   import org.odmg.DList;
  @@ -42,9 +47,6 @@
   import org.odmg.ODMGRuntimeException;
   import org.odmg.Transaction;
   
  -import java.util.ArrayList;
  -import java.util.List;
  -
   
   /**
    * Default implementation of the {@link Implementation} interface.
  @@ -64,12 +66,13 @@
       private Configurator configurator;
       private OJBTxManager ojbTxManager;
       private LockManager lockManager;
  +
       private Class oqlCollectionClass;
       private boolean impliciteWriteLocks;
       private boolean implicitLocking;
  -    protected boolean cascadingDeleteOnetoOne;
  -    protected boolean cascadingDeleteOnetoN;
  -    protected boolean cascadingDeleteMtoN;
  +    private boolean implicitLockingBackward;
  +    private boolean ordering;
  +    private boolean noteUserOrder;
   
       /**
        * private Constructor: use static factory method
  @@ -81,13 +84,16 @@
           lockManager = LockManagerFactory.getLockManager();
           setConfigurator(PersistenceBrokerFactory.getConfigurator());
           Configuration conf = getConfigurator().getConfigurationFor(null);
  -        // read settings for cascading delete behavior
  -        cascadingDeleteOnetoOne = conf.getBoolean("cascadingDeleteOneToOne", false);
  -        cascadingDeleteOnetoN = conf.getBoolean("cascadingDeleteOneToN", false);
  -        cascadingDeleteMtoN = conf.getBoolean("cascadingDeleteMToN", false);
           oqlCollectionClass = conf.getClass("OqlCollectionClass", ManageableArrayList.class);
  -        impliciteWriteLocks = ((OdmgConfiguration)conf).lockAssociationAsWrites();
  -        implicitLocking = ((OdmgConfiguration)conf).useImplicitLocking();
  +        impliciteWriteLocks = (conf.getString("LockAssociations", "WRITE").equalsIgnoreCase("WRITE") ? true : false);
  +        implicitLocking = conf.getBoolean("ImplicitLocking", true);
  +        ordering = conf.getBoolean("Ordering", true);
  +        noteUserOrder = conf.getBoolean("NoteUserOrder", true);
  +        implicitLockingBackward = conf.getBoolean("ImplicitLockingBackward", false);
  +        if(log.isEnabledFor(Logger.INFO))
  +        {
  +            log.info("Settings: " + this.toString());
  +        }
       }
   
       public OJBTxManager getTxManager()
  @@ -212,7 +218,7 @@
           {
               throw new DatabaseClosedException("Database is NULL, cannot create a DList with a null database.");
           }
  -        return DCollectionFactory.getInstance().createDList(getCurrentPBKey());
  +        return (DList) DListFactory.singleton.createCollectionOrMap(getCurrentPBKey());
       }
   
       /**
  @@ -226,7 +232,7 @@
           {
               throw new DatabaseClosedException("Database is NULL, cannot create a DBag with a null database.");
           }
  -        return DCollectionFactory.getInstance().createDBag(getCurrentPBKey());
  +        return (DBag) DBagFactory.singleton.createCollectionOrMap(getCurrentPBKey());
       }
   
       /**
  @@ -240,7 +246,7 @@
           {
               throw new DatabaseClosedException("Database is NULL, cannot create a DSet with a null database.");
           }
  -        return DCollectionFactory.getInstance().createDSet(getCurrentPBKey());
  +        return (DSet) DSetFactory.singleton.createCollectionOrMap(getCurrentPBKey());
       }
   
       /**
  @@ -254,7 +260,7 @@
           {
               throw new DatabaseClosedException("Database is NULL, cannot create a DArray with a null database.");
           }
  -        return DCollectionFactory.getInstance().createDArray(getCurrentPBKey());
  +        return (DArray) DArrayFactory.singleton.createCollectionOrMap(getCurrentPBKey());
       }
   
       /**
  @@ -268,7 +274,7 @@
           {
               throw new DatabaseClosedException("Database is NULL, cannot create a DMap with a null database.");
           }
  -        return DCollectionFactory.getInstance().createDMap(getCurrentPBKey());
  +        return (DMap) DMapFactory.singleton.createCollectionOrMap(getCurrentPBKey());
       }
   
       /**
  @@ -280,24 +286,35 @@
       public String getObjectId(Object obj)
       {
           Identity oid = null;
  -        PersistenceBroker broker;
  +        PersistenceBroker broker = null;
   
  -        if (getCurrentDatabase() != null)
  +        try
           {
  -            /**
  -             * is there an open database we are calling getObjectId against? if yes, use it
  -             */
  -            broker = PersistenceBrokerFactory.createPersistenceBroker(getCurrentDatabase().getPBKey());
  +            if (getCurrentDatabase() != null)
  +            {
  +                /**
  +                 * is there an open database we are calling getObjectId against? if yes, use it
  +                 */
  +                broker = PersistenceBrokerFactory.createPersistenceBroker(getCurrentDatabase().getPBKey());
  +            }
  +            else
  +            {
  +                log.warn("Can't find open database, try to use the default configuration");
  +                /**
  +                 * otherwise, use default.
  +                 */
  +                broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +            }
  +
  +            oid = broker.serviceIdentity().buildIdentity(obj);
           }
  -        else
  +        finally
           {
  -            /**
  -             * otherwise, use default.
  -             */
  -            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +            if(broker != null)
  +            {
  +                broker.close();
  +            }
           }
  -
  -        oid = new Identity(obj, broker);
           return new String(SerializationUtils.serialize(oid));
       }
   
  @@ -337,40 +354,29 @@
       }
   
       /**
  -     * This method can be used to activate or deactivate the implicit
  -     * locking mechanism for the current transaction.
  -     * turning of implicit locking may improve performance but requires
  -     * additional care to make sure all changed objects are properly
  -     * registered to the transaction.
  -     * <br/>
  -     * [In future versions this method will set the global used
  -     * implicite locking property. The deprecated flag is set to indicate
  -     * the upcoming change in method behavior. Currently it's not possible
  -     * to change the global property specified in OJB.properties file at
  -     * runtime, only per Transaction the property can be changed]
  +     * <strong>Note:</strong> Method behavior changed between version 1.0.3 and
  +     * 1.0.4. Now this method is used to set the global property <em>implicit locking</em>,
  +     * use method {@link TransactionExt#setImplicitLocking(boolean)} to set the property
  +     * for a running transaction.
        *
  -     * @deprecated use {@link TransactionExt#setImplicitLocking(boolean)} instead.
  -     * @param value if set to true implicit locking is enabled,
  -     *        if false, implicit locking is disabled.
  -     **/
  +     * @see ImplementationExt#setImplicitLocking(boolean)
  +     */
   	public void setImplicitLocking(boolean value)
   	{
  -		((TransactionExt)currentTransaction()).setImplicitLocking(value);
  -        // this.implicitLocking = value;
  +        if(implicitLockingBackward)
  +        {
  +            ((TransactionExt)currentTransaction()).setImplicitLocking(value);
  +        }
  +        else
  +        {
  +            this.implicitLocking = value;
  +        }
   	}
   
       /**
  -     * Returns <em>true</em> if implicit locking is enabled
  -     * for this {@link org.odmg.Implementation} instance, else <em>false</em>.
  -     * <br/>
  -     * Important: The returned value is the global used setting for all
  -     * {@link org.odmg.Transaction#lock(Object, int)} calls. Nevertheless it
  -     * is possible to set this value at runtime for the current used {@link org.odmg.Transaction}
  -     * using {@link TransactionExt#setImplicitLocking(boolean)}.
  -     *
  -     * @see TransactionExt#isImplicitLocking()
  +     * @see ImplementationExt#isImplicitLocking()
        */
  -    boolean isImplicitLocking()
  +    public boolean isImplicitLocking()
       {
           return implicitLocking;
       }
  @@ -406,4 +412,100 @@
       {
           return impliciteWriteLocks;
       }
  +
  +    public boolean isOrdering()
  +    {
  +        return ordering;
  +    }
  +
  +    public void setOrdering(boolean ordering)
  +    {
  +        this.ordering = ordering;
  +    }
  +
  +    public boolean isNoteUserOrder()
  +    {
  +        return noteUserOrder;
  +    }
  +
  +    public void setNoteUserOrder(boolean noteUserOrder)
  +    {
  +        this.noteUserOrder = noteUserOrder;
  +    }
  +
  +    public String toString()
  +    {
  +        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
  +                .append("implicitLocking", isImplicitLocking())
  +                .append("implicitWriteLocks", isImpliciteWriteLocks())
  +                .append("ordering", isOrdering())
  +                .append("noteUserOrder", isNoteUserOrder())
  +                .append("oqlCollectionClass", getOqlCollectionClass())
  +                .append("txManager", getTxManager())
  +                .append("lockManager", getLockManager())
  +                .toString();
  +    }
  +
  +
  +    //*****************************************************
  +    // inner classes
  +    //*****************************************************
  +
  +    abstract static class BaseFactory extends ConfigurableFactory
  +    {
  +        Object createCollectionOrMap()
  +        {
  +            return this.createNewInstance();
  +        }
  +
  +        Object createCollectionOrMap(PBKey key)
  +        {
  +            return createNewInstance(PBKey.class, key);
  +        }
  +    }
  +
  +    static final class DListFactory extends BaseFactory
  +    {
  +        static final BaseFactory singleton = new DListFactory();
  +        protected String getConfigurationKey()
  +        {
  +            return "DListClass";
  +        }
  +    }
  +
  +    static final class DArrayFactory extends BaseFactory
  +    {
  +        static final BaseFactory singleton = new DArrayFactory();
  +        protected String getConfigurationKey()
  +        {
  +            return "DArrayClass";
  +        }
  +    }
  +
  +    static final class DBagFactory extends BaseFactory
  +    {
  +        static final BaseFactory singleton = new DBagFactory();
  +        protected String getConfigurationKey()
  +        {
  +            return "DBagClass";
  +        }
  +    }
  +
  +    static final class DSetFactory extends BaseFactory
  +    {
  +        static final BaseFactory singleton = new DSetFactory();
  +        protected String getConfigurationKey()
  +        {
  +            return "DSetClass";
  +        }
  +    }
  +
  +    static final class DMapFactory extends BaseFactory
  +    {
  +        static final BaseFactory singleton = new DMapFactory();
  +        protected String getConfigurationKey()
  +        {
  +            return "DMapClass";
  +        }
  +    }
   }
  
  
  
  1.12.2.3  +4 -4      db-ojb/src/java/org/apache/ojb/odmg/NamedRootsMap.java
  
  Index: NamedRootsMap.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/NamedRootsMap.java,v
  retrieving revision 1.12.2.2
  retrieving revision 1.12.2.3
  diff -u -r1.12.2.2 -r1.12.2.3
  --- NamedRootsMap.java	3 May 2005 17:09:04 -0000	1.12.2.2
  +++ NamedRootsMap.java	4 Jun 2005 14:38:13 -0000	1.12.2.3
  @@ -183,7 +183,7 @@
                   result = tx.getBroker().getObjectByIdentity(objectIdentity);
                   // lock the persistance capable object
                   RuntimeObject rt = new RuntimeObject(result, objectIdentity, tx, false);
  -                tx.lockAndRegister(rt, Transaction.READ, false, tx.getRegistrationList());
  +                tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList());
               }
               else
               {
  @@ -237,11 +237,11 @@
               // else persist the specified named object
               if(!rt.isNew())
               {
  -                tx.lockAndRegister(rt, Transaction.READ, false, tx.getRegistrationList());
  +                tx.lockAndRegister(rt, Transaction.READ, tx.getRegistrationList());
               }
               else
               {
  -                tx.getAssociatedDatabase().makePersistent(rt);
  +                tx.makePersistent(rt);
               }
           }
           NamedEntry oldEntry = localLookup(name);
  
  
  
  1.10.2.5  +20 -0     db-ojb/src/java/org/apache/ojb/odmg/NarrowTransaction.java
  
  Index: NarrowTransaction.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/NarrowTransaction.java,v
  retrieving revision 1.10.2.4
  retrieving revision 1.10.2.5
  diff -u -r1.10.2.4 -r1.10.2.5
  --- NarrowTransaction.java	23 Mar 2005 16:56:29 -0000	1.10.2.4
  +++ NarrowTransaction.java	4 Jun 2005 14:38:13 -0000	1.10.2.5
  @@ -174,4 +174,24 @@
       {
           tx.setCascadingDelete(target, doCascade);
       }
  +
  +    public boolean isOrdering()
  +    {
  +        return tx.isOrdering();
  +    }
  +
  +    public void setOrdering(boolean ordering)
  +    {
  +        tx.setOrdering(ordering);
  +    }
  +
  +    public boolean isNoteUserOrder()
  +    {
  +        return tx.isNoteUserOrder();
  +    }
  +
  +    public void setNoteUserOrder(boolean noteUserOrder)
  +    {
  +        tx.setNoteUserOrder(noteUserOrder);
  +    }
   }
  
  
  
  1.32.2.15 +30 -15    db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java
  
  Index: ObjectEnvelope.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelope.java,v
  retrieving revision 1.32.2.14
  retrieving revision 1.32.2.15
  diff -u -r1.32.2.14 -r1.32.2.15
  --- ObjectEnvelope.java	10 May 2005 19:08:54 -0000	1.32.2.14
  +++ ObjectEnvelope.java	4 Jun 2005 14:38:13 -0000	1.32.2.15
  @@ -32,6 +32,7 @@
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.OJBRuntimeException;
  +import org.apache.ojb.broker.PersistenceBrokerInternal;
   import org.apache.ojb.broker.core.proxy.CollectionProxy;
   import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl;
   import org.apache.ojb.broker.core.proxy.CollectionProxyListener;
  @@ -44,7 +45,6 @@
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.broker.util.BrokerHelper;
   import org.apache.ojb.broker.util.ObjectModification;
  -import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.odmg.states.ModificationState;
  @@ -62,11 +62,13 @@
    */
   public class ObjectEnvelope implements ObjectModification
   {
  +    private Logger log = LoggerFactory.getLogger(ObjectEnvelope.class);
  +
       static final long serialVersionUID = -829177767933340522L;
  +
       static final int IS_MATERIALIZED_OBJECT = 11;
       static final int IS_MATERIALIZED_PROXY = 13;
       static final int IS_UNMATERIALIZED_PROXY = 17;
  -    private Logger log = LoggerFactory.getLogger(ObjectEnvelope.class);
   
       /**
        * The objects modification state, e.g. Old and Clean
  @@ -111,9 +113,9 @@
           prepareInitialState(isNewObject);
       }
   
  -    public PersistenceBroker getBroker()
  +    public PersistenceBrokerInternal getBroker()
       {
  -        return buffer.getTransaction().getBroker();
  +        return buffer.getTransaction().getBrokerInternal();
       }
   
       TransactionImpl getTx()
  @@ -219,6 +221,11 @@
           return myObj;
       }
   
  +    public Object getRealObject()
  +    {
  +        return ProxyHelper.getRealObject(getObject());
  +    }
  +
       public void refreshObjectIfNeeded(Object obj)
       {
           if(this.myObj != obj)
  @@ -402,7 +409,7 @@
       }
   
       /**
  -     * returns the Modification-state.
  +     * Returns the Modification-state.
        * @return org.apache.ojb.server.states.ModificationState
        */
       public ModificationState getModificationState()
  @@ -411,7 +418,7 @@
       }
   
       /**
  -     * returns true if the underlying Object needs an INSERT statement, else returns false.
  +     * Returns true if the underlying Object needs an INSERT statement, else returns false.
        */
       public boolean needsInsert()
       {
  @@ -419,7 +426,7 @@
       }
   
       /**
  -     * returns true if the underlying Object needs an UPDATE statement, else returns false.
  +     * Returns true if the underlying Object needs an UPDATE statement, else returns false.
        */
       public boolean needsUpdate()
       {
  @@ -427,7 +434,7 @@
       }
   
       /**
  -     * returns true if the underlying Object needs an UPDATE statement, else returns false.
  +     * Returns true if the underlying Object needs an UPDATE statement, else returns false.
        */
       public boolean needsDelete()
       {
  @@ -435,7 +442,7 @@
       }
   
       /**
  -     * sets the initial MoificationState of the wrapped object myObj. The initial state will be StateNewDirty if myObj
  +     * Sets the initial MoificationState of the wrapped object myObj. The initial state will be StateNewDirty if myObj
        * is not persisten already. The state will be set to StateOldClean if the object is already persistent.
        */
       private void prepareInitialState(boolean isNewObject)
  @@ -487,10 +494,14 @@
       {
           if(newModificationState != modificationState)
           {
  -            if(LoggerFactory.getDefaultLogger().isDebugEnabled())
  +            if(log.isDebugEnabled())
               {
  -                LoggerFactory.getDefaultLogger().debug("object state transition for object " + this.oid + " ("
  +                log.debug("object state transition for object " + this.oid + " ("
                           + modificationState + " --> " + newModificationState + ")");
  +//                try{throw new Exception();}catch(Exception e)
  +//                {
  +//                e.printStackTrace();
  +//                }
               }
               modificationState = newModificationState;
           }
  @@ -520,7 +531,7 @@
           }
           catch(Exception e)
           {
  -            LoggerFactory.getDefaultLogger().warn("Could not verify object changes, return hasChanged 'true'", e);
  +            log.warn("Could not verify object changes, return hasChanged 'true'", e);
           }
           hasChanged = (beforeImage != null && beforeImage.equals(currentImage) ? Boolean.FALSE : Boolean.TRUE);
   
  @@ -736,23 +747,27 @@
   
       public void doUpdate()
       {
  +        if(log.isDebugEnabled()) log.debug("Start UPDATE action for " + getIdentity());
           performLinkEntries();
  -        getBroker().store(getObject(), ObjectModificationDefaultImpl.UPDATE);
  +        getBroker().store(getObject(), getIdentity(), getClassDescriptor(), false, true);
       }
   
       public void doInsert()
       {
  +        if(log.isDebugEnabled()) log.debug("Start INSERT action for " + getIdentity());
           performLinkEntries();
  -        getBroker().store(getObject(), ObjectModificationDefaultImpl.INSERT);
  +        getBroker().store(getObject(), getIdentity(), getClassDescriptor(), true, true);
       }
   
       public void doDelete()
       {
  -        getBroker().delete(getObject());
  +        if(log.isDebugEnabled()) log.debug("Start DELETE action for " + getIdentity());
  +        getBroker().delete(getObject(), true);
       }
   
       public void doEvictFromCache()
       {
  +        if(log.isDebugEnabled()) log.debug("Remove from cache " + getIdentity());
           getBroker().removeFromCache(getIdentity());
       }
   
  
  
  
  1.32.2.20 +20 -3     db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java
  
  Index: ObjectEnvelopeTable.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java,v
  retrieving revision 1.32.2.19
  retrieving revision 1.32.2.20
  diff -u -r1.32.2.19 -r1.32.2.20
  --- ObjectEnvelopeTable.java	10 May 2005 19:08:54 -0000	1.32.2.19
  +++ ObjectEnvelopeTable.java	4 Jun 2005 14:38:13 -0000	1.32.2.20
  @@ -42,6 +42,7 @@
   import org.apache.ojb.odmg.link.LinkEntry;
   import org.apache.ojb.odmg.link.LinkEntryMtoN;
   import org.apache.ojb.odmg.states.StateOldClean;
  +import org.apache.ojb.odmg.states.StateTransient;
   import org.odmg.LockNotGrantedException;
   import org.odmg.ODMGRuntimeException;
   import org.odmg.Transaction;
  @@ -294,7 +295,7 @@
           {
               ObjectEnvelope mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
               mod.refreshObjectImage();
  -            if(needsCommit && mod.getModificationState() != StateOldClean.getInstance())
  +            if(needsCommit && (mod.getModificationState() != StateOldClean.getInstance() || mod.getModificationState() != StateTransient.getInstance()))
               {
                   mod.setModificationState(mod.getModificationState().markClean());
               }
  @@ -462,7 +463,7 @@
        */
       private void reorder() 
       {
  -        if (needsCommit)
  +        if (getTransaction().isOrdering() && needsCommit && mhtObjectEnvelopes.size() > 1)
           {
               ObjectEnvelopeOrdering ordering = new ObjectEnvelopeOrdering(mvOrderOfIds, mhtObjectEnvelopes);
               ordering.reorder();
  @@ -488,7 +489,7 @@
               {
                   addForDeletionDependent(mod);
               }
  -            if(mod.needsInsert())
  +            else if(mod.needsInsert())
               {
                   addForInsertDependent(mod);
               }
  @@ -731,6 +732,7 @@
                   {
                       Identity oid = getTransaction().getBroker().serviceIdentity().buildIdentity(depObj);
                       // if(!isNewAssociatedObject(oid) && !alreadyPrepared.contains(oid))
  +                    // if the object has a new association with a different object, don't delete it
                       if(!isNewAssociatedObject(oid))
                       {
                           ObjectEnvelope depMod = get(oid, depObj, false);
  @@ -820,4 +822,19 @@
               entry.execute(broker);
           }
       }
  +
  +    /**
  +     * Set the specified identity to the last position in the order list.
  +     * Note: The Identity must already exist in order list.
  +     */
  +    void moveToLastInOrderList(Identity oid)
  +    {
  +        int index = mvOrderOfIds.indexOf(oid);
  +        // move entry only if exists
  +        if(index > -1 && index < (mvOrderOfIds.size() - 1))
  +        {
  +            Object id = mvOrderOfIds.remove(index);
  +            mvOrderOfIds.add(id);
  +        }
  +    }
   }
  \ No newline at end of file
  
  
  
  1.4.2.4   +63 -1     db-ojb/src/java/org/apache/ojb/odmg/TransactionExt.java
  
  Index: TransactionExt.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionExt.java,v
  retrieving revision 1.4.2.3
  retrieving revision 1.4.2.4
  diff -u -r1.4.2.3 -r1.4.2.4
  --- TransactionExt.java	23 Mar 2005 16:56:29 -0000	1.4.2.3
  +++ TransactionExt.java	4 Jun 2005 14:38:13 -0000	1.4.2.4
  @@ -61,17 +61,26 @@
       /**
        * This method can be used to activate or deactivate the implicit
        * locking mechanism for the current transaction.
  +     * <br/>
  +     * If set <em>true</em> OJB implicitly locks objects to ODMG transactions
  +     * after performing OQL queries. Also if implicit locking is used
  +     * locking objects is recursive, that is associated objects are also
  +     * locked. If ImplicitLocking is set to 'false', no locks are obtained
  +     * in OQL queries, lookup objects and there is also no recursive locking.
  +     * <p/>
        * Turning of implicit locking may improve performance but requires
        * additional care to make sure all changed objects are properly
        * registered to the transaction.
        *
        * @param value If set <em>true</em> implicit locking is enabled,
        *        if <em>false</em>, implicit locking is disabled.
  +     * @see ImplementationExt#setImplicitLocking(boolean)
        **/
       public void setImplicitLocking(boolean value);
   
       /**
        * Returns <em>true</em> if implicite locking is enabled.
  +     * @see #setImplicitLocking(boolean)
        */
       public boolean isImplicitLocking();
   
  @@ -93,4 +102,57 @@
        * @param doCascade If <em>true</em> cascading delete is enabled, <em>false</em> disabled.
        */
       public void setCascadingDelete(Class target, boolean doCascade);
  +
  +    /**
  +     * Return <em>true</em> if the OJB ordering algorithm is enabled.
  +     * @see #setOrdering(boolean)
  +     */
  +    public boolean isOrdering();
  +
  +    /**
  +     * Allows to enable/disable the OJB persistent object ordering algorithm. If
  +     * <em>true</em> OJB try to order the modified/new/deleted objects in a correct order
  +     * (based on a algorithm) before the objects are written to the persistent storage.
  +     * <br/>
  +     * If the used databases support 'deferred checks' it's recommended to
  +     * use this feature and to disable OJB's object ordering.
  +     * <p/>
  +     * If <em>false</em> the order of the objects rely on the order specified by
  +     * the user and on settings like {@link #setImplicitLocking(boolean)}.
  +     *
  +     * @param ordering Set <em>true</em> to enable object ordering on commit.
  +     * @see ImplementationExt#setOrdering(boolean)
  +     */
  +    public void setOrdering(boolean ordering);
  +
  +    /**
  +     * Returns whether or not the persistent method calls determine
  +     * the persistent object order on commit.
  +     *
  +     * @see #setNoteUserOrder(boolean)
  +     */
  +    public boolean isNoteUserOrder();
  +
  +    /**
  +     * If <em>true</em> the order of persisting method calls like
  +     * <br/> - {@link org.odmg.Transaction#lock(Object, int)}).
  +     * <br/> - {@link org.odmg.Database#deletePersistent(Object)}).
  +     * <br/> - {@link org.odmg.Database#makePersistent(Object)})
  +     * determine the order of objects before commit.
  +     * <br/>
  +     * If <em>false</em> the ordering was determined by OJB's internal
  +     * method calls and user calls.
  +     * <br/>
  +     * However it's possible to set this value as a global property
  +     * for all transactions using {@link ImplementationExt#setNoteUserOrder(boolean)}.
  +     * <p/>
  +     * <strong>NOTE:</strong> If OJB's ordering algorithm (see
  +     * {@link #setOrdering(boolean)}) is enabled, the
  +     * order of objects may change on commit.
  +     *
  +     * @param noteUserOrder If <em>true</em> the order of persisting
  +     * method calls determine the order of objects.
  +     * @see ImplementationExt#setNoteUserOrder(boolean) 
  +     */
  +    public void setNoteUserOrder(boolean noteUserOrder);
   }
  
  
  
  1.59.2.17 +143 -26   db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
  retrieving revision 1.59.2.16
  retrieving revision 1.59.2.17
  diff -u -r1.59.2.16 -r1.59.2.17
  --- TransactionImpl.java	10 May 2005 19:08:54 -0000	1.59.2.16
  +++ TransactionImpl.java	4 Jun 2005 14:38:13 -0000	1.59.2.17
  @@ -29,6 +29,7 @@
   import org.apache.ojb.broker.PBFactoryException;
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerException;
  +import org.apache.ojb.broker.PersistenceBrokerInternal;
   import org.apache.ojb.broker.core.PersistenceBrokerFactoryFactory;
   import org.apache.ojb.broker.core.proxy.CollectionProxy;
   import org.apache.ojb.broker.core.proxy.CollectionProxyDefaultImpl;
  @@ -71,8 +72,11 @@
       private Logger log = LoggerFactory.getLogger(TransactionImpl.class);
       private boolean impliciteWriteLocks;
       private boolean implicitLocking;
  +    private boolean ordering;
  +    private boolean noteUserOrdering;
  +
       private String txGUID;
  -    protected PersistenceBroker broker = null;
  +    protected PersistenceBrokerInternal broker = null;
       private ArrayList registrationList = new ArrayList();
       private ImplementationImpl implementation;
       private NamedRootsMap namedRootsMap;
  @@ -122,6 +126,9 @@
           this.implementation = implementation;
           this.impliciteWriteLocks = implementation.isImpliciteWriteLocks();
           this.implicitLocking = implementation.isImplicitLocking();
  +        this.ordering = implementation.isOrdering();
  +        this.noteUserOrdering = implementation.isNoteUserOrder();
  +
           // assign a globally uniqe id to this tx
           txGUID = new GUID().toString();
           curDB = implementation.getCurrentDatabase();
  @@ -220,7 +227,8 @@
           if (log.isDebugEnabled()) log.debug("lock object was called on tx " + this + ", object is " + obj.toString());
           checkOpen();
           RuntimeObject rtObject = new RuntimeObject(obj, this);
  -        lockAndRegister(rtObject, lockMode, true, getRegistrationList());
  +        lockAndRegister(rtObject, lockMode, isImplicitLocking(), getRegistrationList());
  +        if(isImplicitLocking()) moveToLastInOrderList(rtObject.getIdentity());
       }
   
       /**
  @@ -244,6 +252,15 @@
        * Lock and register the specified object, make sure that when cascading locking and register
        * is enabled to specify a List to register the already processed object Identiy.
        */
  +    public void lockAndRegister(RuntimeObject rtObject, int lockMode, List registeredObjects)
  +    {
  +        lockAndRegister(rtObject, lockMode, isImplicitLocking(), registeredObjects);
  +    }
  +
  +    /**
  +     * Lock and register the specified object, make sure that when cascading locking and register
  +     * is enabled to specify a List to register the already processed object Identiy.
  +     */
       public void lockAndRegister(RuntimeObject rtObject, int lockMode, boolean cascade, List registeredObjects)
       {
           // if current object was already locked, do nothing
  @@ -532,6 +549,25 @@
           otw.setModificationState(otw.getModificationState().markDelete());
       }
   
  +    public void deletePersistent(RuntimeObject rt)
  +    {
  +//        if(rt.isNew())
  +//        {
  +//            throw new ObjectNotPersistentException("Object " + rt.getIdentity() + " is not yet persistent");
  +//        }
  +        if(rt.isProxy())
  +        {
  +            Object realObj = rt.getHandler().getRealSubject();
  +            rt = new RuntimeObject(realObj, rt.getIdentity(), this, false);
  +        }
  +        lockAndRegister(rt, Transaction.WRITE, getRegistrationList());
  +        ObjectEnvelope oe = objectEnvelopeTable.getByIdentity(rt.getIdentity());
  +        // TODO: not needed on delete - or? When optimistic locking is used we should always use the
  +        // specified object instance to use the last version of the object
  +        oe.refreshObjectIfNeeded(rt.getObj());
  +        oe.setModificationState(oe.getModificationState().markDelete());
  +    }
  +
       /**
        * @see org.apache.ojb.odmg.TransactionExt#markDirty
        */
  @@ -542,6 +578,13 @@
           otw.setModificationState(otw.getModificationState().markDirty());
       }
   
  +    void markDirty(RuntimeObject rt)
  +    {
  +        ObjectEnvelope otw = objectEnvelopeTable.get(rt.getIdentity(), rt.getObj(), rt.isNew());
  +        otw.refreshObjectIfNeeded(rt.getObj());
  +        otw.setModificationState(otw.getModificationState().markDirty());
  +    }
  +
       void markPersistent(RuntimeObject rtObj)
       {
           ObjectEnvelope oe = objectEnvelopeTable.getByIdentity(rtObj.getIdentity());
  @@ -560,6 +603,20 @@
           oe.refreshObjectIfNeeded(rtObj.getObj());
       }
   
  +    void makePersistent(RuntimeObject rt)
  +    {
  +        try
  +        {
  +            lockAndRegister(rt, Transaction.WRITE, getRegistrationList());
  +            markPersistent(rt);
  +        }
  +        catch (org.apache.ojb.broker.metadata.ClassNotPersistenceCapableException ex)
  +        {
  +            log.error("Can't persist object: " + rt.getIdentity(), ex);
  +            throw new org.odmg.ClassNotPersistenceCapableException(ex.getMessage());
  +        }
  +    }
  +
       /**
        * Upgrade the lock on the given object to the given lock mode. Method <code>
        * tryLock</code> is the same as <code>lock</code> except it returns a boolean
  @@ -941,7 +998,7 @@
                       RuntimeObject rt = isProxy ? new RuntimeObject(refObj, this, false) : new RuntimeObject(refObj, this);
                       if (!registrationList.contains(rt.getIdentity()))
                       {
  -                        lockAndRegister(rt, lockMode, true, registeredObjects);
  +                        lockAndRegister(rt, lockMode, registeredObjects);
                       }
                   }
               }
  @@ -995,7 +1052,7 @@
                               }
                               if (!registrationList.contains(rt.getIdentity()))
                               {
  -                                lockAndRegister(rt, lockMode, true, registeredObjects);
  +                                lockAndRegister(rt, lockMode, registeredObjects);
                               }
                           }
                       }
  @@ -1117,7 +1174,7 @@
        * @return Returns a PersistenceBroker
        * @throws TransactionNotInProgressException is the transaction is not open;
        */
  -    public PersistenceBroker getBroker()
  +    public PersistenceBrokerInternal getBrokerInternal()
       {
           if (broker == null || broker.isClosed())
           {
  @@ -1137,6 +1194,11 @@
           return broker;
       }
   
  +    public PersistenceBroker getBroker()
  +    {
  +        return getBrokerInternal();
  +    }
  +
       /**
        * Returns true if an {@link org.apache.ojb.broker.PersistenceBroker} was associated with this
        * tx instance.
  @@ -1337,31 +1399,33 @@
       {
           boolean result = false;
           Boolean runtimeSetting = (Boolean) runtimeCascadeDeleteMap.get(ord);
  -//        ord.setCascadingStore(ObjectReferenceDescriptor.CASCADE_NONE);
  -//        ord.setCascadingDelete(ObjectReferenceDescriptor.CASCADE_NONE);
           if(runtimeSetting == null)
           {
  -            if(ord instanceof CollectionDescriptor)
  -            {
  -                CollectionDescriptor cds = (CollectionDescriptor) ord;
  +            /*
  +            arminw: Here we use the auto-delete flag defined in metadata
  +            */
  +            result = ord.getCascadingDelete() == ObjectReferenceDescriptor.CASCADE_OBJECT;
  +/*
  +arminw:
  +these settings are nonsense (my fault), it dosen't make sense to differ cascade delete
  +on the used reference type.
  +*/
  +//            if(ord instanceof CollectionDescriptor)
  +//            {
  +//                CollectionDescriptor cds = (CollectionDescriptor) ord;
   //                if(cds.isMtoNRelation())
   //                {
  -//                    ord.setCascadingStore(ObjectReferenceDescriptor.CASCADE_NONE);
  -//                    ord.setCascadingDelete(ObjectReferenceDescriptor.CASCADE_NONE);
  +//                    result = implementation.cascadingDeleteMtoN;
   //                }
  -                if(cds.isMtoNRelation())
  -                {
  -                    result = implementation.cascadingDeleteMtoN;
  -                }
  -                else
  -                {
  -                    result = implementation.cascadingDeleteOnetoN;
  -                }
  -            }
  -            else
  -            {
  -                result = implementation.cascadingDeleteOnetoOne;
  -            }
  +//                else
  +//                {
  +//                    result = implementation.cascadingDeleteOnetoN;
  +//                }
  +//            }
  +//            else
  +//            {
  +//                result = implementation.cascadingDeleteOnetoOne;
  +//            }
           }
           else
           {
  @@ -1375,6 +1439,59 @@
           return (parentLockMode == Transaction.WRITE && impliciteWriteLocks) ? Transaction.WRITE : Transaction.READ;
       }
   
  +    /**
  +     * Return <em>true</em> if the OJB ordering algorithm is enabled.
  +     * @see #setOrdering(boolean)
  +     */
  +    public boolean isOrdering()
  +    {
  +        return ordering;
  +    }
  +
  +    /**
  +     * Allows to enable/disable the OJB persistent object ordering algorithm. If
  +     * <em>true</em> OJB try to order the modified/new/deleted objects in a correct order
  +     * (based on a algorithm) before the objects are written to the persistent storage.
  +     * <br/>
  +     * If <em>false</em> the order of the objects rely on the order specified by
  +     * the user and on settings like {@link #setImplicitLocking(boolean)}.
  +     *
  +     * @param ordering Set <em>true</em> to enable object ordering on commit.
  +     */
  +    public void setOrdering(boolean ordering)
  +    {
  +        this.ordering = ordering;
  +    }
  +
  +    /**
  +     * @see ImplementationExt#isNoteUserOrder()
  +     */
  +    public boolean isNoteUserOrder()
  +    {
  +        return noteUserOrdering;
  +    }
  +
  +    /**
  +     * @see ImplementationExt#setNoteUserOrder(boolean)
  +     */
  +    public void setNoteUserOrder(boolean noteUserOrder)
  +    {
  +        this.noteUserOrdering = noteUserOrder;
  +    }
  +
  +    /**
  +     * Move the specified {@link org.apache.ojb.broker.Identity} to the
  +     * last position in the order list if {@link #isNoteUserOrder()} returns <em>true</em>.
  +     * @param oid The object identity to move.
  +     */
  +    public void moveToLastInOrderList(Identity oid)
  +    {
  +        if(isNoteUserOrder())
  +        {
  +            objectEnvelopeTable.moveToLastInOrderList(oid);
  +        }
  +    }
  +
       //============================================================
       // inner class
       //============================================================
  
  
  

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