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/util BrokerHelper.java
Date Wed, 23 Apr 2003 20:48:16 GMT
brj         2003/04/23 13:48:16

  Modified:    src/java/org/apache/ojb/broker/util BrokerHelper.java
  Log:
  optimize for autoincremented value.
  fix by ron gallagher
  
  Revision  Changes    Path
  1.23      +36 -41    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.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- BrokerHelper.java	23 Apr 2003 20:43:59 -0000	1.22
  +++ BrokerHelper.java	23 Apr 2003 20:48:16 -0000	1.23
  @@ -160,26 +160,26 @@
   	// methods from ClassDescriptor
   	// ***************************************************************************
   
  -    /**
  -     * Answer the real ClassDescriptor for anObj
  -     * ie. aCld may be an Interface of anObj, so the cld for anObj is returned
  -     */
  -    protected ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj)
  -    {
  -        ClassDescriptor result;
  -        
  -        if (aCld.getClassOfObject() == anObj.getClass())
  -        {
  -            result = aCld;
  -        }
  -        else
  -        {
  -            result = aCld.getRepository().getDescriptorFor(anObj.getClass());
  -        }
  -        
  -        return result;
  -    }
  -    
  +	/**
  +	 * Answer the real ClassDescriptor for anObj
  +	 * ie. aCld may be an Interface of anObj, so the cld for anObj is returned
  +	 */
  +	protected ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj)
  +	{
  +		ClassDescriptor result;
  +
  +		if (aCld.getClassOfObject() == anObj.getClass())
  +		{
  +			result = aCld;
  +		}
  +		else
  +		{
  +			result = aCld.getRepository().getDescriptorFor(anObj.getClass());
  +		}
  +
  +		return result;
  +	}
  +
   	/**
   	 * returns an Array with an Objects PK VALUES if convertToSql is true, any
   	 * associated java-to-sql conversions are applied. If the Object is a Proxy
  @@ -211,8 +211,8 @@
   		}
   		else
   		{
  -            ClassDescriptor realCld = getRealClassDescriptor(cld,objectOrProxy);
  -            return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql);
  +			ClassDescriptor realCld = getRealClassDescriptor(cld, objectOrProxy);
  +			return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql);
   		}
   	}
   
  @@ -297,17 +297,12 @@
   		if ((cv == null) || ((cv instanceof Number) && (((Number) cv).intValue() == 0)))
   		{
   			PersistentField f = fd.getPersistentField();
  -			Object result = cv;
   			try
   			{
  -				Object currentValue = f.get(obj);
  -				if ((currentValue == null) || ((cv instanceof Number) && ((Number) currentValue).intValue()
== 0))
  -				{
  -					// lookup SeqMan for a value matching db column an fieldconversion
  -					result = broker.serviceSequenceManager().getUniqueValue(fd);
  -					// reflect autoincrement value back into object
  -					f.set(obj, result);
  -				}
  +				// lookup SeqMan for a value matching db column an fieldconversion
  +				Object result = broker.serviceSequenceManager().getUniqueValue(fd);
  +				// reflect autoincrement value back into object
  +				f.set(obj, result);
   				return result;
   			}
   			catch (MetadataException e)
  @@ -353,14 +348,14 @@
   				// objects that are properly typed for sql.
   				cv = getAutoIncrementValue(fd, obj, cv);
   			}
  -         
  -            if (convertToSql)
  -            {
  -                // apply type and value conversion
  -                cv = fd.getFieldConversion().javaToSql(cv);
  -            }
   
  -            result[i] = cv;
  +			if (convertToSql)
  +			{
  +				// apply type and value conversion
  +				cv = fd.getFieldConversion().javaToSql(cv);
  +			}
  +
  +			result[i] = cv;
   		}
   		return result;
   	}
  @@ -371,7 +366,7 @@
   	 */
   	public Object[] getNonKeyRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
   	{
  -        ClassDescriptor realCld = getRealClassDescriptor(cld,obj);
  +		ClassDescriptor realCld = getRealClassDescriptor(cld, obj);
   		return getValuesForObject(realCld.getNonPkRwFields(), obj, true);
   	}
   
  @@ -381,7 +376,7 @@
   	 */
   	public Object[] getAllRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
   	{
  -        ClassDescriptor realCld = getRealClassDescriptor(cld,obj);
  +		ClassDescriptor realCld = getRealClassDescriptor(cld, obj);
   		return getValuesForObject(realCld.getAllRwFields(), obj, true);
   	}
   
  
  
  

Mime
View raw message