db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/core PersistenceBrokerImpl.java
Date Tue, 01 Jun 2004 20:19:32 GMT
brj         2004/06/01 13:19:32

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
  Log:
  - check doInsert only once (by felix braun)
  - some minor refactorings
  
  Revision  Changes    Path
  1.82      +16 -15    db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- PersistenceBrokerImpl.java	31 May 2004 23:23:06 -0000	1.81
  +++ PersistenceBrokerImpl.java	1 Jun 2004 20:19:32 -0000	1.82
  @@ -628,7 +628,7 @@
           while (i.hasNext())
           {
               CollectionDescriptor cds = (CollectionDescriptor) i.next();
  -            if(cds.getCascadingDelete() != CollectionDescriptor.CASCADE_NONE)
  +            if(cds.getCascadingDelete() != ObjectReferenceDescriptor.CASCADE_NONE)
               {
                   if(cds.isMtoNRelation())
                   {
  @@ -691,17 +691,18 @@
               {
                   doInsert = deletedDuringTransaction.contains(oid);
                   shouldRemoveFromDeleted = true;
  +                
  +                /*
  +                if PK values are set, lookup cache or db to see whether object
  +                needs insert or update
  +                */
  +                if (!doInsert)
  +                {
  +                    doInsert = objectCache.lookup(oid) == null
  +                        && !serviceBrokerHelper().doesExist(cld, oid, obj);
  +                }
               }
  -
  -            /*
  -            if PK values are set, lookup cache or db to see whether object
  -            needs insert or update
  -            */
  -            if (!doInsert)
  -            {
  -                doInsert = objectCache.lookup(oid) == null
  -                    && !serviceBrokerHelper().doesExist(cld, oid, obj);
  -            }
  +            
               // now store it:
               store(obj, oid, cld, doInsert);
   
  @@ -794,7 +795,7 @@
               /*
               if CASCADE_NONE was set, do nothing with referenced objects
               */
  -            if(cod.getCascadingStore() != CollectionDescriptor.CASCADE_NONE)
  +            if(cod.getCascadingStore() != ObjectReferenceDescriptor.CASCADE_NONE)
               {
                   Object referencedObjects = cod.getPersistentField().get(obj);
                   if(cod.isMtoNRelation())
  @@ -874,7 +875,7 @@
                       Object refObj = referencedObjectsIterator.next();
                       // If cascade store is enabled and we don't want to link only,
                       // store depended upon object first to avoid FK violation
  -                    if(!onlyLink && cod.getCascadingStore() == CollectionDescriptor.CASCADE_OBJECT)
  +                    if(!onlyLink && cod.getCascadingStore() == ObjectReferenceDescriptor.CASCADE_OBJECT)
                       {
                           store(refObj);
                           // BRJ: store could have inserted MtoNImplementors
  @@ -933,7 +934,7 @@
                       refObj = ProxyHelper.getRealObject(refObj);
                       link(refObj, refCld, cod, obj, insert);
                       // if enabled cascade store and not only link, store the refObj
  -                    if(!linkOnly && cod.getCascadingStore() == CollectionDescriptor.CASCADE_OBJECT)
  +                    if(!linkOnly && cod.getCascadingStore() == ObjectReferenceDescriptor.CASCADE_OBJECT)
                       {
                           store(refObj);
                       }
  
  
  

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