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 StatementManager.java
Date Thu, 20 Mar 2003 20:48:48 GMT
brj         2003/03/20 12:48:48

  Modified:    src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlGeneratorDefaultImpl.java SqlQueryStatement.java
               src/java/org/apache/ojb/broker/accesslayer
                        StatementManager.java
  Log:
  drop ColumnCriteria
  
  Revision  Changes    Path
  1.16      +1 -17     db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java
  
  Index: SqlGeneratorDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlGeneratorDefaultImpl.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SqlGeneratorDefaultImpl.java	31 Jan 2003 16:59:01 -0000	1.15
  +++ SqlGeneratorDefaultImpl.java	20 Mar 2003 20:48:47 -0000	1.16
  @@ -62,7 +62,6 @@
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.platforms.Platform;
   import org.apache.ojb.broker.query.BetweenCriteria;
  -import org.apache.ojb.broker.query.ColumnCriteria;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.ExistsCriteria;
   import org.apache.ojb.broker.query.FieldCriteria;
  @@ -372,9 +371,6 @@
           if (c instanceof FieldCriteria)
               return toSQLClause((FieldCriteria) c, cld);
   
  -        if (c instanceof ColumnCriteria)
  -            return toSQLClause((ColumnCriteria) c, cld);
  -
           if (c instanceof NullCriteria)
               return toSQLClause((NullCriteria) c, cld);
   
  @@ -412,18 +408,6 @@
        * @param cld ClassDescriptor
        */
       private String toSQLClause(FieldCriteria c, ClassDescriptor cld)
  -    {
  -        String colName = c.getAttribute();
  -        return colName + c.getClause() + c.getValue();
  -    }
  -
  -    /**
  -     * Answer the SQL-Clause for a ColumnCriteria
  -     *
  -     * @param c ColumnCriteria
  -     * @param cld ClassDescriptor
  -     */
  -    private String toSQLClause(ColumnCriteria c, ClassDescriptor cld)
       {
           String colName = c.getAttribute();
           return colName + c.getClause() + c.getValue();
  
  
  
  1.28      +54 -38    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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SqlQueryStatement.java	18 Mar 2003 19:56:26 -0000	1.27
  +++ SqlQueryStatement.java	20 Mar 2003 20:48:47 -0000	1.28
  @@ -297,6 +297,28 @@
       }
   
       /**
  +     * Add the Column to the StringBuffer <br>
  +     * if translate try to convert attribute name into column name
  +     * 
  +     * @param aTableAlias
  +     * @param aPathInfo
  +     * @param translate
  +     * @param buf
  +     */
  +    protected void appendColName(TableAlias aTableAlias, PathInfo aPathInfo, boolean translate,
StringBuffer buf)
  +    {
  +        if (translate)
  +        {
  +            appendColName(aTableAlias, aPathInfo, buf);
  +        }
  +        else
  +        {
  +            buf.append(aPathInfo.column);
  +        }
  +        
  +    }
  +    
  +    /**
        * appends a WHERE-clause to the Statement
        */
       protected void appendWhereClause(StringBuffer where, Criteria crit, StringBuffer stmt)
  @@ -439,7 +461,7 @@
        */
       private void appendBetweenCriteria(TableAlias alias, PathInfo pathInfo, BetweenCriteria
c, StringBuffer buf)
       {
  -        appendColName(alias, pathInfo, buf);
  +        appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
           appendParameter(c.getValue(), buf);
           buf.append("AND");
  @@ -447,22 +469,6 @@
       }
   
       /**
  -     * Answer the SQL-Clause for a ColumnCriteria<br>
  -     * The value of the ColumnCriteria will NOT be translated
  -     * 
  -     * @param alias
  -     * @param pathInfo
  -     * @param c ColumnCriteria
  -     * @param buf
  -     */
  -    private void appendColumnCriteria(TableAlias alias, PathInfo pathInfo, ColumnCriteria
c, StringBuffer buf)
  -    {
  -        appendColName(alias, pathInfo, buf);
  -        buf.append(c.getClause());
  -        buf.append(c.getValue());
  -    }
  -
  -    /**
        * Answer the SQL-Clause for an ExistsCriteria
        * @param c ExistsCriteria
        */
  @@ -485,9 +491,17 @@
        */
       private void appendFieldCriteria(TableAlias alias, PathInfo pathInfo,FieldCriteria
c, StringBuffer buf)
       {
  -        appendColName(alias, pathInfo, buf);
  +        appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
  -        appendColName((String) c.getValue(), false, c.getAlias(), buf);
  +
  +        if (c.isTranslateField())
  +        {   
  +            appendColName((String) c.getValue(), false, c.getAlias(), buf);
  +        }
  +        else
  +        {
  +            buf.append(c.getValue());
  +        }
       }
   
       /**
  @@ -500,7 +514,7 @@
        */
       private void appendInCriteria(TableAlias alias, PathInfo pathInfo, InCriteria c, StringBuffer
buf)
       {
  -        appendColName(alias, pathInfo, buf);
  +        appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
   
           if (c.getValue() instanceof Collection)
  @@ -533,7 +547,7 @@
        */
       private void appendNullCriteria(TableAlias alias, PathInfo pathInfo, NullCriteria c,
StringBuffer buf)
       {
  -        appendColName(alias, pathInfo, buf);
  +        appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
           buf.append(c.getClause());
       }
   
  @@ -553,21 +567,30 @@
       /**
        * Answer the SQL-Clause for a SelectionCriteria
        * 
  +     * @param c
  +     * @param buf
  +     */
  +    private void appendSelectionCriteria(TableAlias alias, PathInfo pathInfo, SelectionCriteria
c, StringBuffer buf)
  +    {
  +        appendColName(alias, pathInfo, c.isTranslateAttribute(), buf);
  +        buf.append(c.getClause());
  +        appendParameter(c.getValue(), buf);      
  +    }
  +
  +    /**
  +     * Answer the SQL-Clause for a SelectionCriteria
  +     * 
        * @param alias
        * @param pathInfo
        * @param c SelectionCriteria
        * @param buf
        */
  -    protected void appendSelectionCriteria(TableAlias alias, PathInfo pathInfo, SelectionCriteria
c, StringBuffer buf)
  +    protected void appendCriteria(TableAlias alias, PathInfo pathInfo, SelectionCriteria
c, StringBuffer buf)
       {
           if (c instanceof FieldCriteria)
           {
               appendFieldCriteria(alias, pathInfo,(FieldCriteria) c, buf);
           }
  -        else if (c instanceof ColumnCriteria)
  -        {
  -            appendColumnCriteria(alias, pathInfo,(ColumnCriteria) c, buf);
  -        }
           else if (c instanceof NullCriteria)
           {
               appendNullCriteria(alias, pathInfo, (NullCriteria) c, buf);
  @@ -589,10 +612,8 @@
               appendExistsCriteria((ExistsCriteria) c, buf);
           }
           else
  -        {            
  -            appendColName(alias, pathInfo, buf);
  -            buf.append(c.getClause());
  -            appendParameter(c.getValue(), buf);      
  +        {      
  +            appendSelectionCriteria(alias,pathInfo,c,buf);   
           }   
       }
   
  @@ -607,7 +628,7 @@
           AttributeInfo attrInfo = getAttributeInfo(c.getAttribute(), false, c.getAlias());
           TableAlias alias = attrInfo.tableAlias;
           
  -        appendSelectionCriteria(alias, attrInfo.pathInfo, c, buf);
  +        appendCriteria(alias, attrInfo.pathInfo, c, buf);
   
           if (alias != null)
           {
  @@ -616,7 +637,7 @@
               while (iter.hasNext())
               {
                   buf.append(" OR ");
  -                appendSelectionCriteria((TableAlias) iter.next(), attrInfo.pathInfo, c,
buf);
  +                appendCriteria((TableAlias) iter.next(), attrInfo.pathInfo, c, buf);
               }
           }
   
  @@ -1142,11 +1163,6 @@
                   if (c instanceof FieldCriteria)
                   {
                       FieldCriteria cc = (FieldCriteria) c;
  -                    buildJoinTreeForColumn((String) cc.getValue(), useOuterJoin, crit.getAlias());
  -                }
  -                else if (c instanceof ColumnCriteria)
  -                {
  -                    ColumnCriteria cc = (ColumnCriteria) c;
                       buildJoinTreeForColumn((String) cc.getValue(), useOuterJoin, crit.getAlias());
                   }
               }
  
  
  
  1.28      +1 -16     db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java
  
  Index: StatementManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- StatementManager.java	12 Mar 2003 22:35:40 -0000	1.27
  +++ StatementManager.java	20 Mar 2003 20:48:48 -0000	1.28
  @@ -75,7 +75,6 @@
   import org.apache.ojb.broker.platforms.PlatformException;
   import org.apache.ojb.broker.platforms.PlatformFactory;
   import org.apache.ojb.broker.query.BetweenCriteria;
  -import org.apache.ojb.broker.query.ColumnCriteria;
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.ExistsCriteria;
   import org.apache.ojb.broker.query.FieldCriteria;
  @@ -322,18 +321,6 @@
   	}
   
   	/**
  -	 * bind ColumnCriteria
  -	 * @param stmt , the PreparedStatement
  -	 * @param index , the position of the parameter to bind
  -	 * @param crit , the Criteria containing the parameter
  -	 * @return next index for PreparedStatement
  -	 */
  -	private int bindStatement(PreparedStatement stmt, int index, ColumnCriteria crit) throws
SQLException
  -	{
  -		return index;
  -	}
  -
  -	/**
   	 * bind SqlCriteria
   	 * @param stmt the PreparedStatement
   	 * @param index the position of the parameter to bind
  @@ -481,8 +468,6 @@
   			index = bindStatement(stmt, index, (SqlCriteria) crit);
   		else if (crit instanceof FieldCriteria)
   			index = bindStatement(stmt, index, (FieldCriteria) crit);
  -		else if (crit instanceof ColumnCriteria)
  -			index = bindStatement(stmt, index, (ColumnCriteria) crit);
   		else if (crit instanceof ExistsCriteria)
   			index = bindStatement(stmt, index, (ExistsCriteria) crit, cld);
   		else
  
  
  

Mime
View raw message