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 Identity.java
Date Sun, 02 Mar 2003 09:11:58 GMT
brj         2003/03/02 01:11:58

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        StatementManager.java
               src/java/org/apache/ojb/broker/util BrokerHelper.java
               src/java/org/apache/ojb/broker/metadata
                        ObjectReferenceDescriptor.java
               src/java/org/apache/ojb/broker Identity.java
  Log:
  values are converted to sql ONLY when binding an sql-statement
  
  Revision  Changes    Path
  1.23      +2 -2      db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java
  
  Index: StatementManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- StatementManager.java	1 Mar 2003 22:19:02 -0000	1.22
  +++ StatementManager.java	2 Mar 2003 09:11:57 -0000	1.23
  @@ -734,7 +734,7 @@
   	 */
   	protected Object[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Identity
oid) throws PersistenceBrokerException
   	{
  -        return oid.getPrimaryKeyValues();
  +        return broker.serviceBrokerHelper().getKeyValues(cld, oid);
   	}
   
   	/**
  
  
  
  1.10      +46 -1     db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java
  
  Index: BrokerHelper.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BrokerHelper.java	1 Mar 2003 22:20:06 -0000	1.9
  +++ BrokerHelper.java	2 Mar 2003 09:11:58 -0000	1.10
  @@ -59,6 +59,7 @@
   import java.util.StringTokenizer;
   
   import org.apache.commons.lang.SystemUtils;
  +import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBroker;
  @@ -220,6 +221,50 @@
               return result;
           }
       }
  +
  +    /**
  +     * Return key Values of an Identity
  +     * @param cld
  +     * @param oid
  +     * @return Object[]
  +     * @throws PersistenceBrokerException
  +     */
  +    public Object[] getKeyValues(ClassDescriptor cld, Identity oid)
  +            throws PersistenceBrokerException
  +    {
  +        return getKeyValues(cld, oid, true);
  +    }
  +
  +    /**
  +     * Return key Values of an Identity
  +     * @param cld
  +     * @param oid
  +     * @param convertToSql
  +     * @return Object[]
  +     * @throws PersistenceBrokerException
  +     */
  +    public Object[] getKeyValues(ClassDescriptor cld, Identity oid, boolean convertToSql)
  +            throws PersistenceBrokerException
  +    {
  +        FieldDescriptor[] pkFields = cld.getPkFields();
  +        Object[] result = new Object[pkFields.length];
  +        Object[] pkValues = oid.getPrimaryKeyValues();
  +              
  +        for (int i = 0; i < result.length; i++)
  +        {
  +            FieldDescriptor fmd = pkFields[i];
  +            Object cv = pkValues[i];
  +
  +            if (convertToSql)
  +            {
  +                // BRJ : apply type and value mapping
  +                cv = fmd.getFieldConversion().javaToSql(cv);
  +            }
  +            result[i] = cv;
  +        }
  +        return result;
  +    }
  +
   
       /**
        * returns an Array with an Objects PK VALUES, with any java-to-sql
  
  
  
  1.22      +8 -3      db-ojb/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java
  
  Index: ObjectReferenceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ObjectReferenceDescriptor.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ObjectReferenceDescriptor.java	31 Jan 2003 17:03:32 -0000	1.21
  +++ ObjectReferenceDescriptor.java	2 Mar 2003 09:11:58 -0000	1.22
  @@ -61,7 +61,6 @@
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.PersistenceBrokerException;
  -import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   
   /**
  @@ -180,8 +179,14 @@
           {
               FieldDescriptor fmd = fks[i];
               PersistentField f = fmd.getPersistentField();
  -            FieldConversion fc = fmd.getFieldConversion();
  -            Object val = fc.javaToSql(f.get(obj));
  +            
  +            // BRJ: do NOT convert. 
  +            // conversion is done when binding the sql-statement
  +            //
  +            // FieldConversion fc = fmd.getFieldConversion();
  +            // Object val = fc.javaToSql(f.get(obj));
  +            
  +            Object val = f.get(obj);
               result[i] = val;
           }
           return result;
  
  
  
  1.16      +4 -3      db-ojb/src/java/org/apache/ojb/broker/Identity.java
  
  Index: Identity.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/Identity.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Identity.java	1 Mar 2003 22:17:46 -0000	1.15
  +++ Identity.java	2 Mar 2003 09:11:58 -0000	1.16
  @@ -193,8 +193,9 @@
                   this.objectsClass = targetBroker.getTopLevelClass(objectToIdentitify.getClass());
                   this.objectsRealClass = objectToIdentitify.getClass();
            
  -                // BRJ: do convertToSql
  -                this.pkValues = targetBroker.serviceBrokerHelper().getKeyValues(cld, objectToIdentitify,
true);
  +                // BRJ: definitely do NOT convertToSql
  +                // conversion is done when binding the sql-statement              
  +                this.pkValues = targetBroker.serviceBrokerHelper().getKeyValues(cld, objectToIdentitify,
false);
               }
   
               checkForPrimaryKeys();
  
  
  

Mime
View raw message