db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r367104 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
Date Sun, 08 Jan 2006 21:53:58 GMT
Author: arminw
Date: Sun Jan  8 13:53:54 2006
New Revision: 367104

URL: http://svn.apache.org/viewcvs?rev=367104&view=rev
Log:
minor performance improvements

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java?rev=367104&r1=367103&r2=367104&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
Sun Jan  8 13:53:54 2006
@@ -549,22 +549,25 @@
             {
                 return;
             }
-            
+
             ClassDescriptor cld = getClassDescriptor(obj.getClass());
+            Identity oid = serviceIdentity().buildIdentity(cld, obj);
+
             //BRJ: check for valid pk
-            if (!serviceBrokerHelper().assertValidPkForDelete(cld, obj))
+            //if (!serviceBrokerHelper().assertValidPkForDelete(cld, obj))
+            // TODO: arminw: this simple check should do the same - verify
+            if (oid.isTransient())
             {
                 String msg = "Cannot delete object without valid PKs. " + obj;
                 logger.error(msg);
                 return;
             }
-            
+
             /**
              * MBAIRD
              * 2. register object in markedForDelete map.
              */
             markedForDelete.add(obj);
-            Identity oid = serviceIdentity().buildIdentity(cld, obj);
 
             // Invoke events on PersistenceBrokerAware instances and listeners
             BEFORE_DELETE_EVENT.setTarget(obj);
@@ -768,12 +771,14 @@
         if(obj == null) return;
 
         ClassDescriptor cld = getClassDescriptor(obj.getClass());
+        Identity oid = serviceIdentity().buildIdentity(cld, obj);
         /*
         if one of the PK fields was null, we assume the objects
         was new and needs insert
         */
-        boolean insert = serviceBrokerHelper().hasNullPKField(cld, obj);
-        Identity oid = serviceIdentity().buildIdentity(cld, obj);
+        // boolean insert = serviceBrokerHelper().hasNullPKField(cld, obj);
+        // TODO: arminw: this should do the same - verify
+        boolean insert = oid.isTransient();
         /*
         if PK values are set, lookup cache or db to see whether object
         needs insert or update
@@ -1523,8 +1528,8 @@
         }
         return newObj;
     }
-    
-    
+
+
     /**
      * Retrieve an full materialized (dependent on the metadata settings)
      * object by it's identity from the database, as well as caching the
@@ -1849,7 +1854,12 @@
     private void storeToDb(Object obj, ClassDescriptor cld, Identity oid, boolean insert,
boolean ignoreReferences)
     {
         // 1. link and store 1:1 references
-        storeReferences(obj, cld, insert, ignoreReferences);
+        // we can skip handling for 1:1 references if
+        // it's enabled and the class has no super-reference
+        if(!(ignoreReferences && cld.getSuperReference() == null))
+        {
+            storeReferences(obj, cld, insert, ignoreReferences);
+        }
 
         Object[] pkValues = oid.getPrimaryKeyValues();
         if (!serviceBrokerHelper().assertValidPksForStore(cld.getPkFields(), pkValues))
@@ -1912,7 +1922,7 @@
         // cache object for symmetry with getObjectByXXX()
         // Add the object to the cache.
         objectCache.doInternalCache(oid, obj, ObjectCacheInternal.TYPE_WRITE);
-        // 3. store 1:n and m:n associations
+        // 3. store 1:n and m:n associations except if we have to skip
         if(!ignoreReferences) storeCollections(obj, cld, insert);
     }
 



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