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/accesslayer/sql SqlQueryStatement.java
Date Sat, 03 Dec 2005 19:49:18 GMT
brj         2005/12/03 11:49:18

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql Tag:
                        OJB_1_0_RELEASE SqlQueryStatement.java
  Log:
  fix problem with pathclass hints
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.75.2.19 +31 -22    db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.75.2.18
  retrieving revision 1.75.2.19
  diff -u -r1.75.2.18 -r1.75.2.19
  --- SqlQueryStatement.java	1 Dec 2005 21:30:29 -0000	1.75.2.18
  +++ SqlQueryStatement.java	3 Dec 2005 19:49:18 -0000	1.75.2.19
  @@ -1071,6 +1071,12 @@
   				attrPath = attrPath + "." + attr;
   			}
   
  +            // use clas hints for path
  +            if (pathClasses != null)
  +            {
  +                hintClasses = (List) pathClasses.get(attrPath);     
  +            }    
  +
   			// look for outer join hint
   			outer = outer || getQuery().isPathOuterJoin(attrPath);
   
  @@ -1078,7 +1084,7 @@
   			if (ord instanceof CollectionDescriptor)
   			{
   				cod = (CollectionDescriptor) ord;
  -				cld = getItemClassDescriptor(cod, attrPath, pathClasses);
  +				cld = getItemClassDescriptor(cod, hintClasses);
   
   				if (!cod.isMtoNRelation())
   				{
  @@ -1109,7 +1115,7 @@
   			else
   			{
   				// must be n:1 or 1:1
  -				cld = getItemClassDescriptor(ord, attrPath, pathClasses);
  +				cld = getItemClassDescriptor(ord, hintClasses);
   
   			    // BRJ : if ord is taken from 'super' we have to change prev accordingly
   				if (!prev.cld.equals(ord.getClassDescriptor()))
  @@ -1431,27 +1437,30 @@
   	 * answer the ClassDescriptor for itemClass for an ObjectReferenceDescriptor
   	 * check optional hint;
   	 */
  -	private ClassDescriptor getItemClassDescriptor(ObjectReferenceDescriptor ord, String attr,
Map pathClasses)
  -	{   
  -		List itemClasses = (List)pathClasses.get(attr);
  -
  -		if (itemClasses == null)
  -		{
  -			itemClasses = new ArrayList();
  -			itemClasses.add(ord.getItemClass());
  -		}
  -
  -		List classDescriptors = new ArrayList(itemClasses.size());
  -		DescriptorRepository repo = ord.getClassDescriptor().getRepository();
  +    private ClassDescriptor getItemClassDescriptor(ObjectReferenceDescriptor ord, List
hintClasses)
  +    {   
  +        DescriptorRepository repo = ord.getClassDescriptor().getRepository();
   
  -		for (Iterator iter = itemClasses.iterator(); iter.hasNext();)
  -		{
  -			Class clazz = (Class) iter.next();
  -			classDescriptors.add(repo.getDescriptorFor(clazz));
  -		}
  +        if (hintClasses == null || hintClasses.isEmpty())
  +        {
  +            return repo.getDescriptorFor(ord.getItemClass()); 
  +        }
  +        
  +        Class resultClass = (Class) hintClasses.get(0);
  +        
  +        for (Iterator iter = hintClasses.iterator(); iter.hasNext();)
  +        {
  +            Class clazz = (Class) iter.next();
  +            Class superClazz = clazz.getSuperclass();
  +            
  +            if (hintClasses.contains(superClazz))
  +            {
  +                resultClass = superClazz;   // use superclass if it's in the hints
  +            }
  +        }
   
  -		return (ClassDescriptor) classDescriptors.get(0);
  -	}
  +        return repo.getDescriptorFor(resultClass);
  +    }
   
   	/**
        * Appends the ORDER BY clause for the Query.
  
  
  

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