db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/odmg/collections DMapImpl.java DListEntry.java DListImpl.java DMapEntry.java DSetImpl.java
Date Fri, 20 Dec 2002 01:54:03 GMT
mattbaird    2002/12/19 17:54:03

  Modified:    src/java/org/apache/ojb/odmg/collections DMapImpl.java
                        DListEntry.java DListImpl.java DMapEntry.java
                        DSetImpl.java
  Log:
  check if we can do a lazy generateID based on if the persistentField uses accessors and
mutators
  
  Revision  Changes    Path
  1.11      +6 -3      jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java
  
  Index: DMapImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DMapImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DMapImpl.java	21 Nov 2002 22:25:49 -0000	1.10
  +++ DMapImpl.java	20 Dec 2002 01:54:02 -0000	1.11
  @@ -61,6 +61,7 @@
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
   import org.apache.ojb.broker.util.collections.ManageableHashSet;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  @@ -89,7 +90,8 @@
       public DMapImpl()
       {
           this.entries = new ManageableHashSet();
  -        id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +	        id = generateNewId();
       }
   
       /**
  @@ -99,7 +101,8 @@
       {
           this.entries = new ManageableHashSet();
           this.pbKey = key;
  -        id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +	        id = generateNewId();
       }
   
       /**
  
  
  
  1.11      +8 -5      jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java
  
  Index: DListEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DListEntry.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DListEntry.java	21 Nov 2002 22:25:49 -0000	1.10
  +++ DListEntry.java	20 Dec 2002 01:54:02 -0000	1.11
  @@ -60,6 +60,7 @@
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.odmg.PBCapsule;
   import org.apache.ojb.odmg.TxManagerFactory;
  @@ -74,7 +75,6 @@
       protected int id = -1;
       protected int dlistId = -1;
       protected DListImpl m_dList;
  -
       protected int position;
       protected Identity oid;
       protected Object realSubject;
  @@ -87,13 +87,15 @@
       public DListEntry()
       {
           super();
  -        id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +			id = generateNewId();
       }
   
       public DListEntry(PBKey pbKey)
       {
           this.pbKey = pbKey;
  -        id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +			id = generateNewId();
       }
   
       /**
  @@ -118,7 +120,8 @@
           Identity OID = new Identity(theObject);
           this.oid = OID;
           this.realSubject = theObject;
  -        id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +			id = generateNewId();
       }
   
       public Identity getOid()
  @@ -218,7 +221,7 @@
       /**
        * Insert the method's description here.
        * Creation date: (10.02.2001 17:58:45)
  -     * @param newRealSubject java.lang.Object
  +     * @param realSubject java.lang.Object
        */
       void setRealSubject(java.lang.Object realSubject)
       {
  
  
  
  1.11      +16 -9     jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java
  
  Index: DListImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DListImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DListImpl.java	21 Nov 2002 22:25:49 -0000	1.10
  +++ DListImpl.java	20 Dec 2002 01:54:02 -0000	1.11
  @@ -80,6 +80,8 @@
   import org.odmg.ODMGRuntimeException;
   import org.odmg.OQLQuery;
   import org.odmg.Transaction;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldPropertyImpl;
   
   /**
    * Insert the type's description here.
  @@ -90,7 +92,10 @@
           ManageableCollection, java.io.Serializable
   {
       private Logger log = LoggerFactory.getLogger(DListImpl.class);
  -
  +	/**
  +	 * decide whether we can defer ID generation based on the type of persistentField we are
using
  +	 * performance hit to generate these ID's is to much if you never use them.
  +	 */
       private int id = -1;
       private Vector elements;
       private int size;
  @@ -107,7 +112,8 @@
           super();
           elements = new Vector();
           this.size = 0;
  -        this.id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +			id = generateNewId();
       }
   
       /**
  @@ -119,7 +125,8 @@
           elements = new Vector();
           this.size = 0;
           this.pbKey = pbKey;
  -        this.id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +			id = generateNewId();
       }
   
       /**
  @@ -213,7 +220,7 @@
       {
           DListEntry entry = (DListEntry) elements.get(index);
           // if we are in a transaction: acquire locks !
  -        TransactionImpl tx = (TransactionImpl) TxManagerFactory.instance().getTransaction();
  +        TransactionImpl tx = TxManagerFactory.instance().getTransaction();
           if (tx != null)
           {
               tx.markDelete(entry);
  @@ -261,7 +268,7 @@
        * @param	predicate	An OQL boolean query predicate.
        * @return	True if there is an element of the collection that evaluates to true
        * for the predicate, otherwise false.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -340,7 +347,7 @@
        * (unless this collection is an instance of some class that provides a
        * guarantee).
        *
  -     * @returns an <tt>Iterator</tt> over the elements in this collection
  +     * @return an <tt>Iterator</tt> over the elements in this collection
        */
       public Iterator iterator()
       {
  @@ -427,7 +434,7 @@
        * return a new collection that contains each element that evaluated to true.
        * @param	predicate	An OQL boolean query predicate.
        * @return	A new collection containing the elements that evaluated true for the predicate.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public DCollection query(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -480,7 +487,7 @@
        * provided query predicate.
        * @param	predicate	An OQL boolean query predicate.
        * @return	An iterator used to iterate over the elements that evaluated true for the
predicate.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public Iterator select(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -493,7 +500,7 @@
        * @param	predicate	An OQL boolean query predicate.
        * @return The element that evaluates to true for the predicate. If no element
        * evaluates to true, null is returned.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public Object selectElement(String predicate) throws org.odmg.QueryInvalidException
       {
  
  
  
  1.9       +5 -39     jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DMapEntry.java
  
  Index: DMapEntry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DMapEntry.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DMapEntry.java	21 Nov 2002 22:25:49 -0000	1.8
  +++ DMapEntry.java	20 Dec 2002 01:54:02 -0000	1.9
  @@ -61,6 +61,7 @@
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.odmg.PBCapsule;
  @@ -114,7 +115,8 @@
       public DMapEntry(DMapImpl map, Object key, Object value)
       {
           this.pbKey = map.getPBKey();
  -        this.id = generateNewId();
  +		if (!PersistentFieldFactory.usesAccessorsAndMutators())
  +	        id = generateNewId();
           this.dmapId = map.getId();
           this.keyRealSubject = key;
           this.keyOID = new Identity(key);
  @@ -122,42 +124,6 @@
           this.valueOID = new Identity(value);
       }
   
  -//    /**
  -//     * return a unique id
  -//     */
  -//    protected int generateNewId()
  -//    {
  -//        PersistenceBroker broker = null;
  -//        try
  -//        {
  -//            if (pbKey != null)
  -//            {
  -//                broker = PersistenceBrokerFactory.createPersistenceBroker(pbKey);
  -//            }
  -//            else
  -//            {
  -//                LoggerFactory.getDefaultLogger().info("DMapEntry: No PBKey set for this
entry, try to use default");
  -//                broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  -//            }
  -//            broker.beginTransaction();
  -//            int result = broker.getUniqueId(this.getClass(), "id");
  -//            broker.commitTransaction();
  -//            return result;
  -//        }
  -//        catch (Exception e)
  -//        {
  -//            LoggerFactory.getDefaultLogger().error("DMapEntry: Generation of new id failed",
e);
  -//            throw new PersistenceBrokerException(e);
  -//        }
  -//        finally
  -//        {
  -//            if (broker != null)
  -//            {
  -//                broker.close();
  -//            }
  -//        }
  -//    }
  -
       /**
        * return a unique id
        */
  @@ -295,4 +261,4 @@
       {
           this.valueOID = valueOID;
       }
  -}
  \ No newline at end of file
  +}
  
  
  
  1.10      +5 -5      jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java
  
  Index: DSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/collections/DSetImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DSetImpl.java	1 Dec 2002 11:48:17 -0000	1.9
  +++ DSetImpl.java	20 Dec 2002 01:54:02 -0000	1.10
  @@ -181,7 +181,7 @@
        * @param	predicate	An OQL boolean query predicate.
        * @return	True if there is an element of the collection that evaluates to true
        * for the predicate, otherwise false.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public boolean existsElement(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -270,7 +270,7 @@
        * (unless this collection is an instance of some class that provides a
        * guarantee).
        *
  -     * @returns an <tt>Iterator</tt> over the elements in this collection
  +     * @return an <tt>Iterator</tt> over the elements in this collection
        */
       public java.util.Iterator iterator()
       {
  @@ -306,7 +306,7 @@
        * return a new collection that contains each element that evaluated to true.
        * @param	predicate	An OQL boolean query predicate.
        * @return	A new collection containing the elements that evaluated true for the predicate.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public org.odmg.DCollection query(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -393,7 +393,7 @@
        * provided query predicate.
        * @param	predicate	An OQL boolean query predicate.
        * @return	An iterator used to iterate over the elements that evaluated true for the
predicate.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public java.util.Iterator select(String predicate) throws org.odmg.QueryInvalidException
       {
  @@ -406,7 +406,7 @@
        * @param	predicate	An OQL boolean query predicate.
        * @return The element that evaluates to true for the predicate. If no element
        * evaluates to true, null is returned.
  -     * @exception	QueryInvalidException	The query predicate is invalid.
  +     * @exception	org.odmg.QueryInvalidException	The query predicate is invalid.
        */
       public Object selectElement(String predicate) throws org.odmg.QueryInvalidException
       {
  
  
  

Mime
View raw message