You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2004/08/15 01:21:28 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/odmg TransactionImpl.java

arminw      2004/08/14 16:21:28

  Modified:    src/java/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        TransactionImpl.java
  Log:
  We are using a lot of objects that have
  references to other, proxied objects and when looking at the database
  logs I noticed that these proxies were constantly materialized.
  
  Fix by Georg Schneider, avoid proxy materialization on FK assignment
  
  <snip>
  I narrowed down the problem to the method assertFkAssignment(...) in TransactionImpl:
              if (!ProxyHelper.isProxy(obj) && (ref != null))
              {
                  Object refInstance = ProxyHelper.getRealObject(ref);
  
  The preceeding code checks if the object on which the FKs are set is not
  a proxy and the reference is not null and then it immediately
  materializes the proxy, making a proxy useless. Besides the code a few
  lines down
  
  refPkValues = getBroker().serviceBrokerHelper().getKeyValues(refCld,
  refInstance, false);
  
  perfectly handles proxies anyway because getKeyValues(...) in
  BrokerHelper doesn't materialize if refInstance is a proxy.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.59.2.1  +8 -18     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
  retrieving revision 1.59.2.1
  diff -u -r1.59 -r1.59.2.1
  --- TransactionImpl.java	24 Jun 2004 15:36:56 -0000	1.59
  +++ TransactionImpl.java	14 Aug 2004 23:21:27 -0000	1.59.2.1
  @@ -17,7 +17,6 @@
   
   import javax.transaction.Status;
   import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.Collection;
   import java.util.Enumeration;
   import java.util.Hashtable;
  @@ -871,31 +870,22 @@
           {
               if (!ProxyHelper.isProxy(obj) && (ref != null))
               {
  -                Object refInstance = ProxyHelper.getRealObject(ref);
  +                Class refClass = ProxyHelper.getRealClass(ref);
                   ClassDescriptor objCld = this.getBroker().getClassDescriptor(obj.getClass());
                   FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
   
  -                // oma: refInstance might be null in case of dangling foreign keys.
                   ValueContainer[] refPkValues;
  -                if (refInstance != null)
  -                {
  -                    ClassDescriptor refCld = this.getBroker().getClassDescriptor(refInstance.getClass());
  -                    refPkValues = getBroker().serviceBrokerHelper().getKeyValues(refCld, refInstance, false);
  -                }
  -                else
  -                {
  -                    refPkValues = new ValueContainer[objFkFields.length];
  -                    Arrays.fill(refPkValues, null);
  -                }
  +                ClassDescriptor refCld = this.getBroker().getClassDescriptor(refClass);
  +                refPkValues = getBroker().serviceBrokerHelper().getKeyValues(refCld, ref, false);
   
  -                /**
  +                /*
                    * MBAIRD:
  -                 * objFkFields could end up being null in case of non-mapped indirection table of m:n relationship
  -                 *
  +                 * objFkFields could end up being null in case of non-mapped indirection table
  +                 * of m:n relationship
                    */
                   if (objFkFields != null)
                   {
  -                    org.apache.ojb.broker.metadata.FieldDescriptor fld = null;
  +                    FieldDescriptor fld = null;
                       for (int i = 0; i < objFkFields.length; i++)
                       {
                           fld = objFkFields[i];
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org