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:43:59 GMT
brj         2003/04/23 13:43:59

  Modified:    src/java/org/apache/ojb/broker/util BrokerHelper.java
  Log:
  fixed problem with polymorphicMNUpdate and Insert caused
  by ClassDescriptor pointing to Interface.
  
  Revision  Changes    Path
  1.22      +27 -4     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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- BrokerHelper.java	23 Apr 2003 16:57:15 -0000	1.21
  +++ BrokerHelper.java	23 Apr 2003 20:43:59 -0000	1.22
  @@ -160,6 +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;
  +    }
  +    
   	/**
   	 * 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
  @@ -191,7 +211,8 @@
   		}
   		else
   		{
  -            return getValuesForObject(cld.getPkFields(), objectOrProxy, convertToSql);
  +            ClassDescriptor realCld = getRealClassDescriptor(cld,objectOrProxy);
  +            return getValuesForObject(realCld.getPkFields(), objectOrProxy, convertToSql);
   		}
   	}
   
  @@ -350,7 +371,8 @@
   	 */
   	public Object[] getNonKeyRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
   	{
  -		return getValuesForObject(cld.getNonPkRwFields(), obj, true);
  +        ClassDescriptor realCld = getRealClassDescriptor(cld,obj);
  +		return getValuesForObject(realCld.getNonPkRwFields(), obj, true);
   	}
   
   	/**
  @@ -359,7 +381,8 @@
   	 */
   	public Object[] getAllRwValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
   	{
  -		return getValuesForObject(cld.getAllRwFields(), obj, true);
  +        ClassDescriptor realCld = getRealClassDescriptor(cld,obj);
  +		return getValuesForObject(realCld.getAllRwFields(), obj, true);
   	}
   
   	public static String buildMessageString(Object obj, Object value, Field field)
  
  
  

Mime
View raw message