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 Mon, 08 Mar 2004 21:16:41 GMT
brj         2004/03/08 13:16:41

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  removed TAB character
  
  Revision  Changes    Path
  1.67      +265 -264  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.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- SqlQueryStatement.java	3 Mar 2004 17:19:26 -0000	1.66
  +++ SqlQueryStatement.java	8 Mar 2004 21:16:41 -0000	1.67
  @@ -88,7 +88,7 @@
   {
       private SqlQueryStatement m_parentStatement;
       /** the logger */
  -    Logger m_logger;
  +    private Logger m_logger;
       /** the target table of the query */
       private TableAlias m_root;
       /** the search table of the query */
  @@ -105,18 +105,28 @@
       private ClassDescriptor m_searchCld;
   
       private int m_aliasCount = 0;
  -    
   
       /**
        * Constructor for SqlCriteriaStatement.
  +     *
  +     * @param pf the Platform
  +     * @param cld the ClassDescriptor
  +     * @param query the Query
  +     * @param logger the Logger
        */
       public SqlQueryStatement(Platform pf, ClassDescriptor cld, Query query, Logger logger)
       {
  -        this (null, pf, cld, query, logger);
  +        this(null, pf, cld, query, logger);
       }
   
       /**
        * Constructor for SqlCriteriaStatement.
  +     *
  +     * @param parent the Parent Query
  +     * @param pf the Platform
  +     * @param cld the ClassDescriptor
  +     * @param query the Query
  +     * @param logger the Logger
        */
       public SqlQueryStatement(SqlQueryStatement parent, Platform pf, ClassDescriptor cld,
Query query, Logger logger)
       {
  @@ -146,9 +156,8 @@
               m_search = getTableAlias(m_query.getObjectProjectionAttribute(), false, null,
null);
           }
   
  -
           // Walk the super reference-descriptor
  -        buildSuperJoinTree( m_root, m_baseCld, "" );
  +        buildSuperJoinTree(m_root, m_baseCld, "");
   
           // In some cases it is necessary to split the query criteria
           // and then to generate UNION of several SELECTs
  @@ -159,8 +168,6 @@
           }
       }
   
  -
  -
       protected ClassDescriptor getBaseClassDescriptor()
       {
           return m_baseCld;
  @@ -194,7 +201,7 @@
           // this prefix is temporary !
           if (colName.startsWith(Criteria.PARENT_QUERY_PREFIX) && m_parentStatement
!= null)
           {
  -            String[] fieldNameRef = { colName.substring(Criteria.PARENT_QUERY_PREFIX.length())};
  +            String[] fieldNameRef = {colName.substring(Criteria.PARENT_QUERY_PREFIX.length())};
               return m_parentStatement.getAttributeInfo(fieldNameRef[0], useOuterJoins, aUserAlias);
           }
   
  @@ -206,7 +213,7 @@
           else
           {
               String pathName = colName.substring(0, sp);
  -            String[] fieldNameRef = { colName.substring(sp + 1)};
  +            String[] fieldNameRef = {colName.substring(sp + 1)};
   
               tableAlias = getTableAlias(pathName, useOuterJoins, aUserAlias, fieldNameRef);
               /**
  @@ -248,44 +255,42 @@
        * @param translate
        * @return
        */
  -	protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
  -	{
  -		FieldDescriptor fld = null;
  -		String result = null;
  -
  +    protected String getColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate)
  +    {
  +        FieldDescriptor fld = null;
  +        String result = null;
   
  -		if (translate)
  -		{
  +        if (translate)
  +        {
               // translate attribute name into column name
  -			fld = getFieldDescriptor(aTableAlias, aPathInfo);
  +            fld = getFieldDescriptor(aTableAlias, aPathInfo);
   
  -			if (fld != null)
  -			{
  +            if (fld != null)
  +            {
                   // added to suport the super reference descriptor
  -                if(!fld.getClassDescriptor().getFullTableName().equals( aTableAlias.table)
  -                    && aTableAlias.hasJoins())
  +                if (!fld.getClassDescriptor().getFullTableName().equals(aTableAlias.table)
&& aTableAlias.hasJoins())
                   {
                       Iterator itr = aTableAlias.joins.iterator();
  -                    while( itr.hasNext() )
  +                    while (itr.hasNext())
                       {
                           Join join = (Join) itr.next();
  -                        if( join.right.table.equals(fld.getClassDescriptor().getFullTableName())
)
  +                        if (join.right.table.equals(fld.getClassDescriptor().getFullTableName()))
                           {
                               result = join.right.alias + "." + fld.getColumnName();
                               break;
                           }
                       }
   
  -                    if( result == null )
  +                    if (result == null)
                       {
                           result = aPathInfo.column;
                       }
                   }
                   else
                   {
  -				    result = aTableAlias.alias + "." + fld.getColumnName();
  +                    result = aTableAlias.alias + "." + fld.getColumnName();
                   }
  -			}
  +            }
               else if ("*".equals(aPathInfo.column))
               {
                   result = aPathInfo.column;
  @@ -295,30 +300,30 @@
                   // throw new IllegalArgumentException("No Field found for : " + aPathInfo.column);
                   result = aPathInfo.column;
               }
  -		}
  +        }
           else
           {
               // use attribute name
               result = aPathInfo.column;
           }
   
  -		return result;
  -	}
  +        return result;
  +    }
   
       /**
        * Add the Column to the StringBuffer <br>
        *
        * @param aTableAlias
        * @param aPathInfo
  -     * @param translate, flag to indicate translation of pathInfo 
  +     * @param translate, flag to indicate translation of pathInfo
        * @param buf
        * @return true if appended
        */
  -	protected boolean appendColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate,
StringBuffer buf)
  -	{
  -		String prefix = aPathInfo.prefix;
  +    protected boolean appendColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean
translate, StringBuffer buf)
  +    {
  +        String prefix = aPathInfo.prefix;
           String suffix = aPathInfo.suffix;
  -		String colName = getColName(aTableAlias, aPathInfo ,translate);
  +        String colName = getColName(aTableAlias, aPathInfo, translate);
   
           if (prefix != null) // rebuild function contains (
           {
  @@ -342,30 +347,30 @@
        * @param aPathInfo
        * @return FieldDescriptor
        */
  -	protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo)
  -	{
  -		FieldDescriptor fld = null;
  -		String colName = aPathInfo.column;
  -
  -		if (aTableAlias != null)
  -		{
  -			fld = aTableAlias.cld.getFieldDescriptorByName(colName);
  -			if (fld == null)
  -			{
  -				ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName);
  -				if (ord != null)
  -				{
  -					fld = getFldFromReference(aTableAlias, ord);
  -				}
  +    protected FieldDescriptor getFieldDescriptor(TableAlias aTableAlias, PathInfo aPathInfo)
  +    {
  +        FieldDescriptor fld = null;
  +        String colName = aPathInfo.column;
  +
  +        if (aTableAlias != null)
  +        {
  +            fld = aTableAlias.cld.getFieldDescriptorByName(colName);
  +            if (fld == null)
  +            {
  +                ObjectReferenceDescriptor ord = aTableAlias.cld.getObjectReferenceDescriptorByName(colName);
  +                if (ord != null)
  +                {
  +                    fld = getFldFromReference(aTableAlias, ord);
  +                }
                   else
                   {
                       fld = getFldFromJoin(aTableAlias, colName);
                   }
  -			}
  -		}
  +            }
  +        }
   
  -		return fld;
  -	}
  +        return fld;
  +    }
   
       /**
        * get FieldDescriptor from joined superclass
  @@ -373,23 +378,23 @@
        * @param aColName
        * @return
        */
  -    private FieldDescriptor getFldFromJoin(TableAlias aTableAlias,  String aColName)
  +    private FieldDescriptor getFldFromJoin(TableAlias aTableAlias, String aColName)
       {
           FieldDescriptor fld = null;
   
           // Search Join Structure for attribute
  -        if( aTableAlias.joins != null )
  +        if (aTableAlias.joins != null)
           {
               Iterator itr = aTableAlias.joins.iterator();
  -            while( itr.hasNext() )
  +            while (itr.hasNext())
               {
                   Join join = (Join) itr.next();
                   ClassDescriptor cld = join.right.cld;
   
                   if (cld != null)
                   {
  -                    fld = cld.getFieldDescriptorByName( aColName );
  -                    if( fld != null )
  +                    fld = cld.getFieldDescriptorByName(aColName);
  +                    if (fld != null)
                       {
                           break;
                       }
  @@ -412,26 +417,27 @@
   
           if (aTableAlias == getRoot())
           {
  -        	// no path expression
  -        	FieldDescriptor[] fk = anOrd.getForeignKeyFieldDescriptors(aTableAlias.cld);
  -        	if (fk.length > 0)
  -        	{
  -        		fld = fk[0];
  -        	}
  +            // no path expression
  +            FieldDescriptor[] fk = anOrd.getForeignKeyFieldDescriptors(aTableAlias.cld);
  +            if (fk.length > 0)
  +            {
  +                fld = fk[0];
  +            }
           }
           else
           {
  -        	// attribute with path expression
  -        	/**
  -        	 * MBAIRD
  -        	 * potentially people are referring to objects, not to the object's primary key,
and then we need to take the
  -        	 * primary key attribute of the referenced object to help them out.
  -        	 */
  -        	ClassDescriptor cld = aTableAlias.cld.getRepository().getDescriptorFor(anOrd.getItemClass());
  -        	if (cld != null)
  -        	{
  -        		fld = aTableAlias.cld.getFieldDescriptorByName(cld.getPkFields()[0].getPersistentField().getName());
  -        	}
  +            // attribute with path expression
  +            /**
  +             * MBAIRD
  +             * potentially people are referring to objects, not to the object's primary
key, 
  +             * and then we need to take the primary key attribute of the referenced object

  +             * to help them out.
  +             */
  +            ClassDescriptor cld = aTableAlias.cld.getRepository().getDescriptorFor(anOrd.getItemClass());
  +            if (cld != null)
  +            {
  +                fld = aTableAlias.cld.getFieldDescriptorByName(cld.getPkFields()[0].getPersistentField().getName());
  +            }
           }
   
           return fld;
  @@ -444,7 +450,7 @@
        * field names in functions (ie: sum(name) ) are tried to resolve
        * ie: name from FIELDDESCRIPTOR , UPPER(name_test) from Criteria<br>
        * also resolve pathExpression adress.city or owner.konti.saldo
  -     * 
  +     *
        * @param attr
        * @param useOuterJoins
        * @param aUserAlias
  @@ -458,7 +464,7 @@
   
           return appendColName(tableAlias, attrInfo.pathInfo, true, buf);
       }
  -  
  +
       /**
        * Append the appropriate ColumnName to the buffer<br>
        * if a FIELDDESCRIPTOR is found for the Criteria the colName is taken from
  @@ -466,20 +472,21 @@
        * field names in functions (ie: sum(name) ) are tried to resolve
        * ie: name from FIELDDESCRIPTOR , UPPER(name_test) from Criteria<br>
        * also resolve pathExpression adress.city or owner.konti.saldo
  -     * 
  +     *
        * @param attr
  -     * @param attrAlias, column alias 
  +     * @param attrAlias column alias
        * @param useOuterJoins
        * @param aUserAlias
        * @param buf
        * @return
        */
  -    protected boolean appendColName(String attr, String attrAlias, boolean useOuterJoins,
String aUserAlias, StringBuffer buf)
  +    protected boolean appendColName(String attr, String attrAlias, boolean useOuterJoins,
String aUserAlias,
  +            StringBuffer buf)
       {
           AttributeInfo attrInfo = getAttributeInfo(attr, useOuterJoins, aUserAlias);
           TableAlias tableAlias = attrInfo.tableAlias;
  -        PathInfo pi = attrInfo.pathInfo;   
  -        
  +        PathInfo pi = attrInfo.pathInfo;
  +
           if (pi.suffix != null)
           {
               pi.suffix = pi.suffix + " as " + attrAlias;
  @@ -488,11 +495,10 @@
           {
               pi.suffix = " as " + attrAlias;
           }
  -        
  -        
  +
           return appendColName(tableAlias, pi, true, buf);
       }
  -    
  +
       /**
        * appends a WHERE-clause to the Statement
        * @param where
  @@ -539,35 +545,35 @@
        * @param crit
        * @param stmt
        */
  -	protected void appendClause(StringBuffer clause, Criteria crit, StringBuffer stmt)
  -	{
  -		/**
  -		 * MBAIRD
  -		 * when generating the "WHERE/HAVING" clause we need to append the criteria for multi-mapped
  -		 * tables. We only need to do this for the root classdescriptor and not for joined tables
  -		 * because we assume you cannot make a relation of the wrong type upon insertion. Of
course,
  -		 * you COULD mess the data up manually and this would cause a problem.
  -		 */
  -
  -		if (clause != null)
  -		{
  -			stmt.append(clause.toString());
  -		}
  -		if (crit != null)
  -		{
  -			if (clause == null)
  -			{
  -				stmt.append(asSQLStatement(crit));
  -			}
  -			else
  -			{
  -				stmt.append(" AND (");
  -				stmt.append(asSQLStatement(crit));
  -				stmt.append(")");
  -			}
  -            
  - 		}
  -	}
  +    protected void appendClause(StringBuffer clause, Criteria crit, StringBuffer stmt)
  +    {
  +        /**
  +         * MBAIRD
  +         * when generating the "WHERE/HAVING" clause we need to append the criteria for
multi-mapped
  +         * tables. We only need to do this for the root classdescriptor and not for joined
tables
  +         * because we assume you cannot make a relation of the wrong type upon insertion.
Of course,
  +         * you COULD mess the data up manually and this would cause a problem.
  +         */
  +
  +        if (clause != null)
  +        {
  +            stmt.append(clause.toString());
  +        }
  +        if (crit != null)
  +        {
  +            if (clause == null)
  +            {
  +                stmt.append(asSQLStatement(crit));
  +            }
  +            else
  +            {
  +                stmt.append(" AND (");
  +                stmt.append(asSQLStatement(crit));
  +                stmt.append(")");
  +            }
  +
  +        }
  +    }
   
       /**
        * create SQL-String based on Criteria
  @@ -578,7 +584,7 @@
       {
           Enumeration e = crit.getElements();
           StringBuffer statement = new StringBuffer();
  -                
  +
           while (e.hasMoreElements())
           {
               Object o = e.nextElement();
  @@ -601,7 +607,7 @@
   
                   switch (pc.getType())
                   {
  -                    case (Criteria.OR):
  +                    case (Criteria.OR) :
                           {
                               if (statement.length() > 0)
                               {
  @@ -612,7 +618,7 @@
                               statement.append(addAtEnd);
                               break;
                           }
  -                    case (Criteria.AND):
  +                    case (Criteria.AND) :
                           {
                               if (statement.length() > 0)
                               {
  @@ -685,7 +691,7 @@
        * @param c ColumnCriteria
        * @param buf
        */
  -    private void appendFieldCriteria(TableAlias alias, PathInfo pathInfo,FieldCriteria
c, StringBuffer buf)
  +    private void appendFieldCriteria(TableAlias alias, PathInfo pathInfo, FieldCriteria
c, StringBuffer buf)
       {
           appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
  @@ -775,8 +781,7 @@
        * @param c
        * @param buf
        */
  -    private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c,
  -            StringBuffer buf)
  +    private void appendLikeCriteria(TableAlias alias, PathInfo pathInfo, LikeCriteria c,
StringBuffer buf)
       {
           appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
  @@ -797,7 +802,7 @@
       {
           if (c instanceof FieldCriteria)
           {
  -            appendFieldCriteria(alias, pathInfo,(FieldCriteria) c, buf);
  +            appendFieldCriteria(alias, pathInfo, (FieldCriteria) c, buf);
           }
           else if (c instanceof NullCriteria)
           {
  @@ -805,7 +810,7 @@
           }
           else if (c instanceof BetweenCriteria)
           {
  -            appendBetweenCriteria(alias, pathInfo,(BetweenCriteria) c, buf);
  +            appendBetweenCriteria(alias, pathInfo, (BetweenCriteria) c, buf);
           }
           else if (c instanceof InCriteria)
           {
  @@ -821,11 +826,11 @@
           }
           else if (c instanceof LikeCriteria)
           {
  -            appendLikeCriteria(alias,pathInfo,(LikeCriteria) c, buf);
  +            appendLikeCriteria(alias, pathInfo, (LikeCriteria) c, buf);
           }
           else
           {
  -            appendSelectionCriteria(alias,pathInfo,c,buf);
  +            appendSelectionCriteria(alias, pathInfo, c, buf);
           }
       }
   
  @@ -840,17 +845,16 @@
           // BRJ : criteria attribute is a query
           if (c.getAttribute() instanceof Query)
           {
  -            Query q = (Query)c.getAttribute();
  +            Query q = (Query) c.getAttribute();
               buf.append("(");
               buf.append(getSubQuerySQL(q));
               buf.append(")");
               buf.append(c.getClause());
               appendParameter(c.getValue(), buf);
               return;
  -        }    
  +        }
   
  -            
  -        AttributeInfo attrInfo = getAttributeInfo((String)c.getAttribute(), false, c.getAlias());
  +        AttributeInfo attrInfo = getAttributeInfo((String) c.getAttribute(), false, c.getAlias());
           TableAlias alias = attrInfo.tableAlias;
   
           if (alias != null)
  @@ -887,7 +891,6 @@
   
       }
   
  -
       /**
        * Append the Parameter
        * Add the place holder ? or the SubQuery
  @@ -916,7 +919,6 @@
           buf.append(") ");
       }
   
  -
       /**
        * Convert subQuery to SQL
        * @param subQuery the subQuery value of SelectionCriteria
  @@ -932,7 +934,7 @@
           }
           else
           {
  -            sql = new SqlSelectStatement(this ,m_platform, cld, subQuery, m_logger).getStatement();
  +            sql = new SqlSelectStatement(this, m_platform, cld, subQuery, m_logger).getStatement();
           }
   
           return sql;
  @@ -948,8 +950,7 @@
        * In the case of related table's primary key the "related.pk" attribute
        * must not add new join, but use the value of foreign key
        */
  -    private TableAlias getTableAlias(String aPath, boolean useOuterJoins,
  -                                     String aUserAlias, String[] fieldRef)
  +    private TableAlias getTableAlias(String aPath, boolean useOuterJoins, String aUserAlias,
String[] fieldRef)
       {
           TableAlias curr, prev, indirect;
           String attr, attrPath = null;
  @@ -964,7 +965,7 @@
   
           curr = getTableAliasForPath(aPath, aUserAlias);
   
  -        if(curr != null)
  +        if (curr != null)
           {
               return curr;
           }
  @@ -972,15 +973,15 @@
           descriptors = getRoot().cld.getAttributeDescriptorsForPath(aPath, getQuery().getPathClasses());
           prev = getRoot();
   
  -        if( descriptors == null || descriptors.size() == 0 )
  +        if (descriptors == null || descriptors.size() == 0)
           {
  -            if( prev.hasJoins() )
  +            if (prev.hasJoins())
               {
  -                for( Iterator itr = prev.iterateJoins(); itr.hasNext(); )
  +                for (Iterator itr = prev.iterateJoins(); itr.hasNext();)
                   {
  -                    prev = ((Join)itr.next()).left;
  +                    prev = ((Join) itr.next()).left;
                       descriptors = prev.cld.getAttributeDescriptorsForPath(aPath, getQuery().getPathClasses());
  -                    if( descriptors.size() > 0 )
  +                    if (descriptors.size() > 0)
                       {
                           break;
                       }
  @@ -1076,12 +1077,12 @@
               if (curr == null)
               {
                   List hintClasses = (List) getQuery().getPathClasses().get(aPath);
  -                curr = createTableAlias(cld, attrPath, aUserAlias, aPath,hintClasses);
  +                curr = createTableAlias(cld, attrPath, aUserAlias, aPath, hintClasses);
   
                   outer = outer || (curr.cld == prev.cld) || curr.hasExtents() || useOuterJoins;
                   addJoin(prev, prevKeys, curr, keys, outer, attr);
   
  -                buildSuperJoinTree( curr, cld, aPath );
  +                buildSuperJoinTree(curr, cld, aPath);
               }
   
               prev = curr;
  @@ -1119,7 +1120,8 @@
        * @param outer
        * @param name
        */
  -    private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[]
rightKeys, boolean outer, String name)
  +    private void addJoin(TableAlias left, Object[] leftKeys, TableAlias right, Object[]
rightKeys, boolean outer,
  +            String name)
       {
           TableAlias extAlias, rightCopy;
   
  @@ -1131,7 +1133,7 @@
               for (int i = 0; i < right.extents.size(); i++)
               {
                   extAlias = (TableAlias) right.extents.get(i);
  -                FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])rightKeys);
  +                FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])
rightKeys);
   
                   left.addJoin(new Join(left, leftKeys, extAlias, extKeys, true, name));
               }
  @@ -1140,18 +1142,18 @@
           // we need to copy the alias on the right for each extent on the left
           if (left.hasExtents())
           {
  -           for (int i = 0; i < left.extents.size(); i++)
  -           {
  -               extAlias = (TableAlias) left.extents.get(i);
  -               FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])leftKeys);
  -               rightCopy = right.copy("C" + i);
  -
  -               // copies are treated like normal extents
  -               right.extents.add(rightCopy);
  -               right.extents.addAll(rightCopy.extents);
  +            for (int i = 0; i < left.extents.size(); i++)
  +            {
  +                extAlias = (TableAlias) left.extents.get(i);
  +                FieldDescriptor[] extKeys = getExtentFieldDescriptors(extAlias, (FieldDescriptor[])
leftKeys);
  +                rightCopy = right.copy("C" + i);
   
  -               addJoin(extAlias, extKeys, rightCopy ,rightKeys, true ,name);
  -           }
  +                // copies are treated like normal extents
  +                right.extents.add(rightCopy);
  +                right.extents.addAll(rightCopy.extents);
  +
  +                addJoin(extAlias, extKeys, rightCopy, rightKeys, true, name);
  +            }
           }
       }
   
  @@ -1164,23 +1166,22 @@
       private FieldDescriptor[] getExtentFieldDescriptors(TableAlias extAlias, FieldDescriptor[]
fds)
       {
           FieldDescriptor[] result = new FieldDescriptor[fds.length];
  -        
  +
           for (int i = 0; i < fds.length; i++)
           {
               result[i] = extAlias.cld.getFieldDescriptorByName(fds[i].getAttributeName());
           }
  -            
  +
           return result;
       }
  -                       
  -    
  +
       private char getAliasChar()
       {
           char result = 'A';
   
           if (m_parentStatement != null)
           {
  -            result = (char)(m_parentStatement.getAliasChar() + 1);
  +            result = (char) (m_parentStatement.getAliasChar() + 1);
           }
   
           return result;
  @@ -1196,7 +1197,8 @@
        * @return TableAlias
        *
        */
  -    private TableAlias createTableAlias(ClassDescriptor aCld, String aPath, String aUserAlias,
String anOriginalPath,List hints)
  +    private TableAlias createTableAlias(ClassDescriptor aCld, String aPath, String aUserAlias,
String anOriginalPath,
  +            List hints)
       {
           if (aUserAlias == null || !anOriginalPath.equals(aPath))
           {
  @@ -1204,7 +1206,7 @@
           }
           else
           {
  -            return createTableAlias(aCld, hints,aUserAlias);
  +            return createTableAlias(aCld, hints, aUserAlias);
           }
       }
   
  @@ -1225,9 +1227,9 @@
           }
   
           String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; // m_pathToAlias.size();
  -        alias = new TableAlias(cld, aliasName, lookForExtents,hints);
  +        alias = new TableAlias(cld, aliasName, lookForExtents, hints);
   
  -        m_pathToAlias.put(path, alias );
  +        m_pathToAlias.put(path, alias);
           return alias;
       }
   
  @@ -1265,7 +1267,7 @@
               getLogger().warn("Creating TableAlias without table for path: " + path);
           }
   
  -        String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;  // + m_pathToAlias.size();
  +        String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++; // + m_pathToAlias.size();
           alias = new TableAlias(table, aliasName);
           m_pathToAlias.put(path, alias);
   
  @@ -1359,25 +1361,25 @@
       {
           FieldHelper cf;
   
  -		if (orderByColumnNumbers == null)
  -		{
  -			return;
  -		}
  -
  -		buf.append(" ORDER BY ");
  -		for (int i = 0; i < orderByColumnNumbers.length; i++)
  -		{
  -			cf = (FieldHelper) orderByFields.get(i);
  -			if (i > 0)
  -			{
  -				buf.append(",");
  -			}
  -			buf.append(orderByColumnNumbers[i]);
  -			if (!cf.isAscending)
  -			{
  -				buf.append(" DESC");
  -			}
  -		}
  +        if (orderByColumnNumbers == null)
  +        {
  +            return;
  +        }
  +
  +        buf.append(" ORDER BY ");
  +        for (int i = 0; i < orderByColumnNumbers.length; i++)
  +        {
  +            cf = (FieldHelper) orderByFields.get(i);
  +            if (i > 0)
  +            {
  +                buf.append(",");
  +            }
  +            buf.append(orderByColumnNumbers[i]);
  +            if (!cf.isAscending)
  +            {
  +                buf.append(" DESC");
  +            }
  +        }
       }
   
       /**
  @@ -1387,21 +1389,21 @@
       {
           FieldHelper cf;
   
  -		if (groupByFields == null || groupByFields.size() == 0)
  -		{
  -			return;
  -		}
  -
  -		buf.append(" GROUP BY ");
  -		for (int i = 0; i < groupByFields.size(); i++)
  -		{
  -			cf = (FieldHelper) groupByFields.get(i);
  -			if (i > 0)
  -			{
  -				buf.append(",");
  -			}
  -			appendColName(cf.name, false, null, buf);
  -		}
  +        if (groupByFields == null || groupByFields.size() == 0)
  +        {
  +            return;
  +        }
  +
  +        buf.append(" GROUP BY ");
  +        for (int i = 0; i < groupByFields.size(); i++)
  +        {
  +            cf = (FieldHelper) groupByFields.get(i);
  +            if (i > 0)
  +            {
  +                buf.append(",");
  +            }
  +            appendColName(cf.name, false, null, buf);
  +        }
       }
   
       /**
  @@ -1416,7 +1418,7 @@
   
           if (joinSyntax == SQL92_JOIN_SYNTAX)
           {
  -            stmtFromPos = buf.length();  // store position of join (by: Terry Dexter)
  +            stmtFromPos = buf.length(); // store position of join (by: Terry Dexter)
           }
   
           if (!(joinSyntax == SQL92_NOPAREN_JOIN_SYNTAX && alias != getRoot()))
  @@ -1549,7 +1551,7 @@
           }
           return columnNumbers;
       }
  -    
  +
       /**
        * Build the tree of joins for the given criteria
        */
  @@ -1573,7 +1575,7 @@
                   // BRJ: do not build join tree for subQuery attribute                 

                   if (c.getAttribute() != null && c.getAttribute() instanceof String)
                   {
  -                    buildJoinTreeForColumn((String)c.getAttribute(), useOuterJoin, c.getAlias());
  +                    buildJoinTreeForColumn((String) c.getAttribute(), useOuterJoin, c.getAlias());
                   }
                   if (c instanceof FieldCriteria)
                   {
  @@ -1596,8 +1598,8 @@
   
           if (sepPos >= 0)
           {
  -            getTableAlias(pathName.substring(0, sepPos), useOuterJoin, aUserAlias,
  -                          new String[] {pathName.substring(sepPos + 1)});
  +            getTableAlias(pathName.substring(0, sepPos), useOuterJoin, aUserAlias, new
String[]{pathName
  +                    .substring(sepPos + 1)});
           }
   
       }
  @@ -1609,10 +1611,10 @@
        * @param cld
        * @param name
        */
  -    protected void buildSuperJoinTree( TableAlias left, ClassDescriptor cld, String name
)
  +    protected void buildSuperJoinTree(TableAlias left, ClassDescriptor cld, String name)
       {
           Iterator objRefs = cld.getObjectReferenceDescriptors().iterator();
  -        while( objRefs.hasNext() )
  +        while (objRefs.hasNext())
           {
               ObjectReferenceDescriptor objRef = (ObjectReferenceDescriptor) objRefs.next();
               FieldDescriptor[] leftFields = objRef.getForeignKeyFieldDescriptors(cld);
  @@ -1620,15 +1622,15 @@
               ClassDescriptor refCld = cld.getRepository().getDescriptorFor(objRef.getItemClassName());
               if (objRef.getPersistentField() instanceof AnonymousPersistentFieldForInheritance)
               {
  -                TableAlias base_alias = getTableAliasForPath( name, null );
  +                TableAlias base_alias = getTableAliasForPath(name, null);
   
                   String aliasName = String.valueOf(getAliasChar()) + m_aliasCount++;
  -                TableAlias right = new TableAlias( refCld, aliasName, false, null );
  +                TableAlias right = new TableAlias(refCld, aliasName, false, null);
   
                   Join join1to1 = new Join(left, leftFields, right, refCld.getPkFields(),
false, "superClass");
  -                base_alias.addJoin( join1to1 );
  +                base_alias.addJoin(join1to1);
   
  -                buildSuperJoinTree( right, refCld, name);
  +                buildSuperJoinTree(right, refCld, name);
               }
           }
       }
  @@ -1640,19 +1642,19 @@
        */
       protected void splitCriteria()
       {
  -		Criteria whereCrit = getQuery().getCriteria();
  -		Criteria havingCrit = getQuery().getHavingCriteria();
  +        Criteria whereCrit = getQuery().getCriteria();
  +        Criteria havingCrit = getQuery().getHavingCriteria();
   
  -		if (whereCrit == null || whereCrit.isEmpty())
  -		{
  -			getJoinTreeToCriteria().put(getRoot(), null);
  -		}
  -		else
  -		{
  -			// TODO: parameters list shold be modified when the form is reduced to DNF.
  +        if (whereCrit == null || whereCrit.isEmpty())
  +        {
  +            getJoinTreeToCriteria().put(getRoot(), null);
  +        }
  +        else
  +        {
  +            // TODO: parameters list shold be modified when the form is reduced to DNF.
               getJoinTreeToCriteria().put(getRoot(), whereCrit);
  -			buildJoinTree(whereCrit);
  -		}
  +            buildJoinTree(whereCrit);
  +        }
   
           if (havingCrit == null || havingCrit.isEmpty())
           {
  @@ -1762,18 +1764,18 @@
   
           TableAlias(ClassDescriptor aCld, String anAlias)
           {
  -            this(aCld, anAlias, false,null);
  +            this(aCld, anAlias, false, null);
           }
   
  -		TableAlias(ClassDescriptor aCld, String anAlias, boolean lookForExtents,List hints)
  -		{
  -			this.cld = aCld;
  -			this.table = aCld.getFullTableName();
  -			this.alias = anAlias;
  +        TableAlias(ClassDescriptor aCld, String anAlias, boolean lookForExtents, List hints)
  +        {
  +            this.cld = aCld;
  +            this.table = aCld.getFullTableName();
  +            this.alias = anAlias;
               boolean useHintsOnExtents = false;
   
               //LEANDRO: use hints
  -            if(hints != null && hints.size() > 0)
  +            if (hints != null && hints.size() > 0)
               {
                   useHintsOnExtents = true;
               }
  @@ -1781,56 +1783,56 @@
               logger.debug("TableAlias(): using hints ? " + useHintsOnExtents);
   
               // BRJ : build alias for extents, only one per Table
  -			if (lookForExtents)
  -			{
  -				ClassDescriptor[] extCLDs = (ClassDescriptor[]) aCld.getRepository().
  -					getAllConcreteSubclassDescriptors(aCld).toArray(new ClassDescriptor[0]);
  -				
  -				ClassDescriptor extCd;
  -				Class extClass;
  -				String extTable;
  -				Map extMap = new HashMap(); // only one Alias per Table
  +            if (lookForExtents)
  +            {
  +                ClassDescriptor[] extCLDs = (ClassDescriptor[]) aCld.getRepository().getAllConcreteSubclassDescriptors(
  +                        aCld).toArray(new ClassDescriptor[0]);
  +
  +                ClassDescriptor extCd;
  +                Class extClass;
  +                String extTable;
  +                Map extMap = new HashMap(); // only one Alias per Table
                   int firtsNonAbstractExtentIndex = 0;
   
  -				for (int i = 0; i < extCLDs.length; i++)
  -				{
  -					extCd = extCLDs[i];
  +                for (int i = 0; i < extCLDs.length; i++)
  +                {
  +                    extCd = extCLDs[i];
                       extClass = extCd.getClassOfObject();
  -                    if(useHintsOnExtents &&  (!hints.contains(extClass)))
  +                    if (useHintsOnExtents && (!hints.contains(extClass)))
                       {
                           //LEANDRO: don't include this class
  -                        logger.debug("Skipping class ["+extClass+"] from extents List");
  +                        logger.debug("Skipping class [" + extClass + "] from extents List");
                           firtsNonAbstractExtentIndex++;
                           continue;
                       }
  -					extTable = extCd.getFullTableName();
  +                    extTable = extCd.getFullTableName();
   
  -					// BRJ : Use the first non abstract extent
  +                    // 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 == firtsNonAbstractExtentIndex)
  +                    {
                           this.cld = extCd;
  -						this.table = extTable;
  -					}
  -					else
  -					{
  -						// Add a new extent entry only if the table of the extent
  -						// does not match the table of the 'base' class.
  -						if (extMap.get(extTable) == null && !extTable.equals(table))
  -						{
  -							extMap.put(extTable, new TableAlias(extCd, anAlias + "E" + i, false,hints));
  -						}
  -					}
  -				}
  -				extents.addAll(extMap.values());
  -			}
  +                        this.table = extTable;
  +                    }
  +                    else
  +                    {
  +                        // Add a new extent entry only if the table of the extent
  +                        // does not match the table of the 'base' class.
  +                        if (extMap.get(extTable) == null && !extTable.equals(table))
  +                        {
  +                            extMap.put(extTable, new TableAlias(extCd, anAlias + "E" +
i, false, hints));
  +                        }
  +                    }
  +                }
  +                extents.addAll(extMap.values());
  +            }
   
               if (cld == null)
               {
                   throw new PersistenceBrokerSQLException("Table is NULL for alias: " + alias);
               }
  -		}
  +        }
   
           ClassDescriptor getClassDescriptor()
           {
  @@ -1874,7 +1876,7 @@
   
               while (iter.hasNext())
               {
  -                temp = (TableAlias)iter.next();
  +                temp = (TableAlias) iter.next();
                   result.extents.add(temp.copy(aPostfix));
               }
   
  @@ -1935,14 +1937,13 @@
           {
               TableAlias t = (TableAlias) obj;
   
  -            return table.equals(t.table);       // BRJ: check table only
  +            return table.equals(t.table); // BRJ: check table only
           }
   
           public int hashCode()
           {
               return table.hashCode();
           }
  -
   
       }
   
  
  
  

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