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 br...@apache.org on 2004/05/06 21:46:40 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java

brj         2004/05/06 12:46:40

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  handle fields read from 'super' cld
  
  Revision  Changes    Path
  1.73      +28 -5     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.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- SqlQueryStatement.java	24 Apr 2004 08:25:37 -0000	1.72
  +++ SqlQueryStatement.java	6 May 2004 19:46:40 -0000	1.73
  @@ -58,6 +58,8 @@
       private QueryByCriteria m_query;
       /** the mapping of paths to TableAliases */
       private HashMap m_pathToAlias = new HashMap();
  +    /** the mapping of ClassDescriptor to TableAliases */
  +    private HashMap m_cldToAlias = new HashMap();
       /** maps trees of joins to criteria */
       private HashMap m_joinTreeToCriteria = new HashMap();
   
  @@ -1021,6 +1023,12 @@
   			{
   				// must be n:1 or 1:1
   				cld = getItemClassDescriptor(ord, attrPath, pathClasses);
  +				
  +			    // BRJ : if ord is taken from 'super' we have to change prev accordingly
  +				if (!prev.cld.equals(ord.getClassDescriptor()))
  +				{
  +				    prev = getTableAliasForClassDescriptor(ord.getClassDescriptor());
  +				}	
   
   				prevKeys = ord.getForeignKeyFieldDescriptors(prev.cld);
   				keys = cld.getPkFields();
  @@ -1202,6 +1210,8 @@
           alias = new TableAlias(cld, aliasName, lookForExtents, hints);
   
           m_pathToAlias.put(path, alias);
  +//        m_cldToAlias.put(cld, alias);
  +        
           return alias;
       }
   
  @@ -1257,6 +1267,16 @@
       }
   
       /**
  +     * Answer the TableAlias for ClassDescriptor
  +     * @param aCld
  +     * @return
  +     */
  +    private TableAlias getTableAliasForClassDescriptor(ClassDescriptor aCld)
  +    {
  +        return (TableAlias) m_cldToAlias.get(aCld);
  +    }
  +    
  +    /**
        * Answer the TableAlias for aPath or aUserAlias
        * @param aPath
        * @param aUserAlias
  @@ -1729,7 +1749,7 @@
       /**
        * This class represents one table (possibly with alias) in the SQL query
        */
  -    static final class TableAlias
  +    final class TableAlias
       {
           Logger logger = LoggerFactory.getLogger(TableAlias.class);
           ClassDescriptor cld; // Is null for indirection table of M:N relation
  @@ -1758,6 +1778,9 @@
               this.alias = anAlias;
               boolean useHintsOnExtents = false;
   
  +            // BRJ: store alias map of in enclosing class
  +			m_cldToAlias.put(aCld, this);
  +			
               //LEANDRO: use hints
               if (hints != null && hints.size() > 0)
               {
  @@ -1776,7 +1799,7 @@
                   Class extClass;
                   String extTable;
                   Map extMap = new HashMap(); // only one Alias per Table
  -                int firtsNonAbstractExtentIndex = 0;
  +                int firstNonAbstractExtentIndex = 0;
   
                   for (int i = 0; i < extCLDs.length; i++)
                   {
  @@ -1786,7 +1809,7 @@
                       {
                           //LEANDRO: don't include this class
                           logger.debug("Skipping class [" + extClass + "] from extents List");
  -                        firtsNonAbstractExtentIndex++;
  +                        firstNonAbstractExtentIndex++;
                           continue;
                       }
                       extTable = extCd.getFullTableName();
  @@ -1794,7 +1817,7 @@
                       // BRJ : Use the first non abstract extent
                       // if the main cld is abstract
                       //logger.debug("cld abstract["+aCld.isAbstract()+"] i["+i+"] index ["+firtsNonAbstractExtentIndex+"]");
  -                    if (aCld.isAbstract() && i == firtsNonAbstractExtentIndex)
  +                    if (aCld.isAbstract() && i == firstNonAbstractExtentIndex)
                       {
                           this.cld = extCd;
                           this.table = extTable;
  
  
  

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