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 Fri, 24 Sep 2004 19:36:14 GMT
brj         2004/09/24 12:36:13

  Modified:    src/java/org/apache/ojb/broker/query BetweenCriteria.java
                        SqlCriteria.java ExistsCriteria.java Criteria.java
                        NullCriteria.java SelectionCriteria.java
                        UserAlias.java AbstractCriterion.java
                        FieldCriteria.java InCriteria.java
                        IdentityCriterion.java ValueCriteria.java
                        Criterion.java LikeCriteria.java
               src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
  Log:
  moved UserAlias from SelectionCriteria to Criteria
  
  Revision  Changes    Path
  1.11      +3 -9      db-ojb/src/java/org/apache/ojb/broker/query/BetweenCriteria.java
  
  Index: BetweenCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/BetweenCriteria.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BetweenCriteria.java	22 May 2004 08:37:23 -0000	1.10
  +++ BetweenCriteria.java	24 Sep 2004 19:36:13 -0000	1.11
  @@ -26,18 +26,12 @@
   {
       private Object value2;
   	
  -	BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause, String anAlias)
  +	BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause)
   	{
  -		super(anAttribute, aValue1, aClause, anAlias);
  +		super(anAttribute, aValue1, aClause);
   		setValue2(aValue2);
   	}
   
  -	// PAW
  -	BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause, UserAlias aUserAlias)
  -	{
  -		super(anAttribute, aValue1, aClause, aUserAlias);
  -		setValue2(aValue2);
  -	}
   
       /**
        * sets the value of the criteria to newValue. 
  
  
  
  1.9       +2 -2      db-ojb/src/java/org/apache/ojb/broker/query/SqlCriteria.java
  
  Index: SqlCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/SqlCriteria.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SqlCriteria.java	22 May 2004 08:37:23 -0000	1.8
  +++ SqlCriteria.java	24 Sep 2004 19:36:13 -0000	1.9
  @@ -30,7 +30,7 @@
        */
       SqlCriteria(String anSqlStatement)
       {
  -        super(anSqlStatement, null, (String)null);
  +        super(anSqlStatement, null);
       }
   
       /*
  
  
  
  1.8       +2 -2      db-ojb/src/java/org/apache/ojb/broker/query/ExistsCriteria.java
  
  Index: ExistsCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/ExistsCriteria.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ExistsCriteria.java	22 May 2004 08:37:23 -0000	1.7
  +++ ExistsCriteria.java	24 Sep 2004 19:36:13 -0000	1.8
  @@ -31,7 +31,7 @@
        */
       ExistsCriteria(Query subQuery, boolean negative)
       {
  -        super("", subQuery, (String)null);
  +        super("", subQuery);
           m_negative = negative;
       }
   
  
  
  
  1.51      +181 -123  db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/Criteria.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- Criteria.java	22 Sep 2004 20:18:53 -0000	1.50
  +++ Criteria.java	24 Sep 2004 19:36:13 -0000	1.51
  @@ -23,6 +23,7 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  +import java.util.StringTokenizer;
   import java.util.Vector;
   
   import org.apache.ojb.broker.PersistenceBroker;
  @@ -66,16 +67,14 @@
       private boolean m_embraced;
       private boolean m_negative = false;
   
  -    // holding CriteriaFields for orderBy and groupBy
  +	// holds the path segment(s) to which the alias applies
  +	private UserAlias m_userAlias = null;
  +
  +	// holding CriteriaFields for orderBy and groupBy
       private List m_orderby = null;
       private List m_groupby = null;
       private List m_prefetchedRelationships = null;
   
  -	// optional alias
  -	private String m_alias = null;
  -	// an aliasPath to be used for this criteria
  -	private String m_aliasPath = null;
  -
   	/** the max. number of parameters in a IN-statement */
       protected static final int IN_LIMIT = getSqlInLimit();
   
  @@ -142,6 +141,8 @@
   
       protected void addSelectionCriteria(SelectionCriteria selectionCrit)
       {
  +        updateUserAlias(selectionCrit.getAttribute());
  +        
           selectionCrit.setParentCriterion(this);
           m_criteria.add(selectionCrit);
       }
  @@ -208,14 +209,19 @@
   
       private InCriteria buildInCriteria(Object attribute, boolean negative, Collection values)
       {
  +        InCriteria result;
  +        
           if (negative)
           {
  -			return ValueCriteria.buildNotInCriteria(attribute, values, getUserAlias(attribute));
  +			result = ValueCriteria.buildNotInCriteria(attribute, values);
           }
           else
           {
  -			return ValueCriteria.buildInCriteria(attribute, values, getUserAlias(attribute));
  +			result = ValueCriteria.buildInCriteria(attribute, values);
           }
  +        
  +        updateUserAlias(attribute);
  +        return result;
       }
   
       /**
  @@ -292,7 +298,7 @@
        */
       public Criteria addEqualTo(String attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildEqualToCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildEqualToCriteria(attribute, value));
           return this;
       }
   
  @@ -307,7 +313,7 @@
        */
       public Criteria addColumnEqualTo(String column, Object value)
       {
  -		SelectionCriteria c = ValueCriteria.buildEqualToCriteria(column, value, getUserAlias(column));
  +		SelectionCriteria c = ValueCriteria.buildEqualToCriteria(column, value);
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
           return this;
  @@ -323,7 +329,7 @@
        */
       public Criteria addColumnEqualToField(String column, Object fieldName)
       {
  -		SelectionCriteria c = FieldCriteria.buildEqualToCriteria(column, fieldName, getUserAlias(column));
  +		SelectionCriteria c = FieldCriteria.buildEqualToCriteria(column, fieldName);
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
           return this;
  @@ -340,7 +346,7 @@
        */
       public Criteria addEqualToField(String attribute, String fieldName)
       {
  -		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, fieldName, getUserAlias(attribute));
  +		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, fieldName);
           addSelectionCriteria(c);
           return this;
       }
  @@ -356,7 +362,7 @@
        */
       public Criteria addNotEqualToField(String attribute, String fieldName)
       {
  -		SelectionCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, fieldName, getUserAlias(attribute));
  +		SelectionCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, fieldName);
           addSelectionCriteria(c);
           return this;
       }
  @@ -372,7 +378,7 @@
        */
       public Criteria addNotEqualToColumn(String attribute, String colName)
       {
  -		FieldCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, colName, getUserAlias(attribute));
  +		FieldCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, colName);
           c.setTranslateField(false);
           addSelectionCriteria(c);
           return this;
  @@ -389,7 +395,7 @@
        */
       public Criteria addEqualToColumn(String attribute, String colName)
       {
  -		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getUserAlias(attribute));
  +		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName);
           c.setTranslateField(false);
           addSelectionCriteria(c);
           return this;
  @@ -404,7 +410,7 @@
        */
       public Criteria addGreaterOrEqualThan(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotLessCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotLessCriteria(attribute, value));
           return this;
       }
   
  @@ -417,7 +423,7 @@
        */
       public Criteria addGreaterOrEqualThanField(String attribute, Object value)
       {
  -		addSelectionCriteria(FieldCriteria.buildNotLessCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(FieldCriteria.buildNotLessCriteria(attribute, value));
           return this;
       }
   
  @@ -430,7 +436,7 @@
        */
       public Criteria addLessOrEqualThan(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotGreaterCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotGreaterCriteria(attribute, value));
           return this;
       }
   
  @@ -443,7 +449,7 @@
        */
       public Criteria addLessOrEqualThanField(String attribute, Object value)
       {
  -		addSelectionCriteria(FieldCriteria.buildNotGreaterCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(FieldCriteria.buildNotGreaterCriteria(attribute, value));
           return this;
       }
   
  @@ -457,7 +463,7 @@
        */
       public Criteria addLike(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildLikeCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildLikeCriteria(attribute, value));
           return this;
       }
   
  @@ -471,7 +477,7 @@
        */
       public Criteria addNotLike(String attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotLikeCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotLikeCriteria(attribute, value));
           return this;
       }
   
  @@ -484,7 +490,7 @@
        */
       public Criteria addNotEqualTo(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotEqualToCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotEqualToCriteria(attribute, value));
           return this;
       }
   
  @@ -497,7 +503,7 @@
        */
       public Criteria addGreaterThan(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildGreaterCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildGreaterCriteria(attribute, value));
           return this;
       }
   
  @@ -510,7 +516,7 @@
        */
       public Criteria addGreaterThanField(String attribute, Object value)
       {
  -		addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value));
           return this;
       }
   
  @@ -523,7 +529,7 @@
        */
       public Criteria addLessThan(Object attribute, Object value)
       {
  -		addSelectionCriteria(ValueCriteria.buildLessCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildLessCriteria(attribute, value));
           return this;
       }
   
  @@ -536,7 +542,7 @@
        */
       public Criteria addLessThanField(String attribute, Object value)
       {
  -		addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value));
           return this;
       }
   
  @@ -662,7 +668,7 @@
        */
       public Criteria addIsNull(String attribute)
       {
  -		addSelectionCriteria(ValueCriteria.buildNullCriteria(attribute, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNullCriteria(attribute));
           return this;
       }
   
  @@ -675,7 +681,7 @@
        */
       public Criteria addColumnIsNull(String column)
       {
  -		SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getUserAlias(column));
  +		SelectionCriteria c = ValueCriteria.buildNullCriteria(column);
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
           return this;
  @@ -689,7 +695,7 @@
        */
       public Criteria addNotNull(String attribute)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotNullCriteria(attribute, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotNullCriteria(attribute));
           return this;
       }
   
  @@ -702,7 +708,7 @@
        */
       public Criteria addColumnNotNull(String column)
       {
  -		SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getUserAlias(column));
  +		SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column);
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
           return this;
  @@ -718,7 +724,7 @@
        */
       public Criteria addBetween(Object attribute, Object value1, Object value2)
       {
  -		addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2));
           return this;
       }
   
  @@ -732,7 +738,7 @@
        */
       public Criteria addNotBetween(Object attribute, Object value1, Object value2)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2));
           return this;
       }
   
  @@ -827,7 +833,7 @@
        */
       public Criteria addIn(Object attribute, Query subQuery)
       {
  -		addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery));
           return this;
       }
   
  @@ -838,7 +844,7 @@
        */
       public Criteria addNotIn(String attribute, Query subQuery)
       {
  -		addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery, getUserAlias(attribute)));
  +		addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery));
           return this;
       }
   
  @@ -910,7 +916,7 @@
        */
       public Criteria addIdentityEqualTo(String attribute, Object value)
       {
  -		addSelectionCriteria(IdentityCriterion.buildEqualToCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(IdentityCriterion.buildEqualToCriteria(attribute, value));
           return this;
       }
   
  @@ -923,7 +929,7 @@
        */
       public Criteria addIdentityNotEqualTo(String attribute, Object value)
       {
  -		addSelectionCriteria(IdentityCriterion.buildNotEqualToCriteria(attribute, value, getUserAlias(attribute)));
  +		addSelectionCriteria(IdentityCriterion.buildNotEqualToCriteria(attribute, value));
           return this;
       }
       
  @@ -1045,124 +1051,90 @@
       }
   
   	/**
  -	 * Retrieves or if necessary, creates a user alias to be used
  -	 * by a child criteria .
  -	 * @param attribute The alias to set
  +	 * Retrieves the user alias to be used by a child criteria.
  +	 * The attribute is added to the user alias
  +	 * @param attribute 
   	 */
  -	private UserAlias getUserAlias(Object attribute)
  +	private void updateUserAlias(Object attribute)
   	{
  -		if (getUserAlias() != null)
  -		{
  -			return getUserAlias();
  -		}
  -		else if (!(attribute instanceof String))
  -		{	
  -			return null;
  -		}
  -		else if (getAlias() == null)
  -		{
  -			return null;
  -		}
  -		if (m_aliasPath == null)
  +	    UserAlias ua = getUserAlias();
  +
  +	    if (ua != null)
   		{
  -			boolean allPathsAliased = true;
  -			return new UserAlias(getAlias(), (String)attribute, allPathsAliased);
  +		    if (attribute instanceof String)
  +		    {
  +		        ua.addAttributePath((String)attribute);
  +		    }
   		}
  -		
  -		return new UserAlias(getAlias(), (String)attribute, m_aliasPath);
   	}
   
  -
  -    /**
  -     * @see org.apache.ojb.broker.query.Criterion#getAlias()
  -     */
  -    public String getAlias()
  -    {
  -        return m_alias;
  -    }
  -
  -    /**
  -     * Sets the alias. an empty String is regarded as null.
  -     * @param alias
  -     */
  -    private void _setAlias(String alias)
  -    {
  -		if (alias == null || alias.trim().equals(""))
  -		{
  -			m_alias = null;
  -		}
  -		else
  -		{    
  -		    m_alias = alias;
  -		}    
  -    }
   	
   	/**
   	 * Sets the alias. Empty String is regarded as null.
   	 * @param alias The alias to set
   	 */
  -	public Criterion setAlias(String alias)
  +	private void setImplicitAlias(ImplicitUserAlias ua)
   	{
  -	    _setAlias(alias);
  +	    setAlias(ua);
   
  -		// propagate to SelectionCriteria,not to Criteria
  -		for (int i = 0; i < m_criteria.size(); i++)
  +	    Iterator iter = getIterator();
  +	    
  +	    while (iter.hasNext())
   		{
  -			if ((m_criteria.get(i) instanceof SelectionCriteria))
  +	        Object obj = iter.next();
  +		    // propagate to SelectionCriteria,not to Criteria
  +			if (obj instanceof SelectionCriteria)
   			{
  -				((SelectionCriteria) m_criteria.get(i)).setAlias(alias);
  +			    SelectionCriteria sc = (SelectionCriteria) obj;
  +			    if (sc.getAttribute() instanceof String)
  +			    {
  +			        ua.addAttributePath((String)sc.getAttribute());
  +			    }    
   			}
   		}
  -		
  -        return this;
   	}
  -
  +	
   	/**
   	 * Sets the alias. Empty String is regarded as null.
   	 * @param alias The alias to set
  -	 * @param aliasPath The path segment(s) to which the alias applies
   	 */
  -	public Criterion setAlias(String alias, String aliasPath)
  +	public Criterion setAlias(String alias)
   	{
  -	    _setAlias(alias);
  -	    
  -		m_aliasPath = aliasPath;
  +	    setImplicitAlias(new ImplicitUserAlias(alias));
   
  -		// propagate to SelectionCriteria,not to Criteria
  -		for (int i = 0; i < m_criteria.size(); i++)
  -		{
  -			if ((m_criteria.get(i) instanceof SelectionCriteria))
  -			{
  -				((SelectionCriteria) m_criteria.get(i)).setAlias(alias, aliasPath);
  -			}
  -		}
  -        return this;
  +	    return this;
   	}
   
   	/**
  -	 * Sets the alias using a userAlias object. 
  -	 * @param userAlias The alias to set
  +	 * Sets the alias. Empty String is regarded as null.
  +	 * @param alias The alias to set
  +	 * @param aliasPath The path segment(s) to which the alias applies
   	 */
  -	public Criterion setAlias(UserAlias userAlias)
  +	public Criterion setAlias(String alias, String aliasPath)
   	{
  -	    super.setAlias(userAlias);
  -	    
  -	    if (userAlias != null)
  -	    {
  -	        _setAlias(userAlias.getName());
  -	    }
  -
  -		// propagate to SelectionCriteria,not to Criteria
  -		for (int i = 0; i < m_criteria.size(); i++)
  -		{
  -			if ((m_criteria.get(i) instanceof SelectionCriteria))
  -			{
  -				((SelectionCriteria) m_criteria.get(i)).setAlias(userAlias);
  -			}
  -		}
  +	    setImplicitAlias(new ImplicitUserAlias(alias, aliasPath));
  +		
           return this;
   	}
   
  +    /**
  +     * @see org.apache.ojb.broker.query.Criterion#getUserAlias()
  +     */
  +    public UserAlias getUserAlias()
  +    {
  +        return m_userAlias;
  +    }
  +
  +
  +    /**
  +     * Sets the alias using a userAlias object. 
  +     * @param userAlias   The alias to set
  +     */
  +    public Criteria setAlias(UserAlias userAlias)
  +    {
  +    	m_userAlias = userAlias;
  +    	return this;
  +    }	
   
       /**
        * @return the query containing the criteria
  @@ -1328,6 +1300,92 @@
               Criterion crit = (Criterion) iter.next();            
               crit.preprocess(aPb);
           }
  +    }
  +    
  +    /**
  +     * Inner class for an implicit UserAlias. This class is used for
  +     * Crieria.setAlias(String) or Criteria.setAlias(String, String).
  +     *   
  +     * @see Criteria#setAlias(String)
  +     * @see Criteria#setAlias(String, String)
  +     * 
  +     * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  +     */
  +    private static class ImplicitUserAlias extends UserAlias
  +    {
  +        private String m_aliasedPath;
  +        private List m_tokenizedAliasedPath;
  +        
  +        /**
  +         * Constructor.
  +         * @param name the name of the alias
  +         * @param aliasedPath the part of the path that is aliased
  +         */
  +        ImplicitUserAlias(String name, String aliasedPath)
  +        {
  +            this(name);
  +            m_aliasedPath = aliasedPath;
  +            
  +            if (aliasedPath != null)
  +            {
  +                m_tokenizedAliasedPath = pathToSegments(m_aliasedPath);
  +            }    
  +        }
  +        
  +        /**
  +         * Constructor.
  +         * @param name the name of the alias
  +         */
  +        ImplicitUserAlias(String name)
  +        {
  +            super(name);
  +        }
  +        
  +        /**
  +         * Creates the pathSegments based on attributePath and aliasPath. 
  +         * @param attributePath the attributePath
  +         */
  +        void addAttributePath(String attributePath)
  +        {
  +            if (m_tokenizedAliasedPath == null)
  +            {
  +                return;
  +            }
  +            
  +            Iterator itr = m_tokenizedAliasedPath.iterator();
  +            String currPath = "";
  +            String separator = "";
  +            while (itr.hasNext())
  +            {
  +                currPath = currPath + separator + (String) itr.next();
  +                int beginIndex = attributePath.indexOf(currPath);
  +                if (beginIndex == -1)
  +                {
  +                    break;
  +                }
  +                int endIndex = beginIndex + currPath.length();
  +                
  +                add(attributePath.substring(0, endIndex));
  +                separator = ".";
  +            }
  +        }
  +       
  +        /**
  +         * split the path into its segments
  +         */
  +        private List pathToSegments(String path)
  +        {           
  +            ArrayList segments = new ArrayList();
  +            StringTokenizer st = new StringTokenizer(path,".");
  +            
  +            while (st.hasMoreTokens())
  +            {
  +                segments.add(st.nextToken());
  +            }
  +            
  +            return segments;
  +        }
  +
       }
       
   }
  
  
  
  1.10      +3 -7      db-ojb/src/java/org/apache/ojb/broker/query/NullCriteria.java
  
  Index: NullCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/NullCriteria.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NullCriteria.java	22 May 2004 08:37:23 -0000	1.9
  +++ NullCriteria.java	24 Sep 2004 19:36:13 -0000	1.10
  @@ -23,15 +23,11 @@
    */
   public class NullCriteria extends ValueCriteria
   {
  -	NullCriteria(String anAttribute, String aClause, String anAlias)
  +	NullCriteria(String anAttribute, String aClause)
   	{
  -		super(anAttribute, null, aClause, anAlias);
  +		super(anAttribute, null, aClause);
   	}
   
  -	NullCriteria(String anAttribute, String aClause, UserAlias anAlias)
  -	{
  -		super(anAttribute, null, aClause, anAlias);
  -	}
   
       public String toString()
       {
  
  
  
  1.21      +13 -39    db-ojb/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
  
  Index: SelectionCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/SelectionCriteria.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SelectionCriteria.java	22 Sep 2004 20:18:54 -0000	1.20
  +++ SelectionCriteria.java	24 Sep 2004 19:36:13 -0000	1.21
  @@ -69,22 +69,9 @@
   	 *
   	 * @param anAttribute  column- or fieldName or a Query
   	 * @param aValue  the value to compare with
  -	 * @param alias  use alias to link anAttribute to
  -	 */
  -	SelectionCriteria(Object anAttribute, Object aValue, String alias)
  -	{
  -	    this (anAttribute, aValue, new UserAlias(alias, (String)anAttribute, true));
  -	}
  -
  -	/**
  -	 * Constructor declaration
  -	 *
  -	 * @param anAttribute  column- or fieldName or a Query
  -	 * @param aValue  the value to compare with
  -	 * @param aUserAlias  userAlias to link anAttribute to
   	 * parameters have an unambiguous signature
   	 */
  -	SelectionCriteria(Object anAttribute, Object aValue, UserAlias aUserAlias)
  +	SelectionCriteria(Object anAttribute, Object aValue)
   	{
   		if (!(anAttribute instanceof String || anAttribute instanceof Query))
   		{
  @@ -94,8 +81,6 @@
   		m_attribute = anAttribute;
   		m_value = aValue;
   		m_bound = !isBindable();
  -		
  -		setAlias(aUserAlias);
   	}
   
   	/**
  @@ -258,31 +243,20 @@
           }
   	}
    
  +   
       /**
  -     * Sets the alias. By default the entire attribute path participates in the alias
  -     * @param alias   The name of the alias to set
  -     */
  -    public Criterion setAlias(String alias)
  -    {
  -    	String attributePath = (String)getAttribute();
  -
  -    	setAlias(new UserAlias(alias, attributePath, true));
  -    	
  -    	return this;
  -    }
  -
  -    /**
  -     * Sets the alias. 
  -     * @param alias   The alias to set
  +     * @see org.apache.ojb.broker.query.Criterion#getUserAlias()
        */
  -    public Criterion setAlias(String alias, String aliasPath)
  +    public UserAlias getUserAlias()
       {
  -    	String attributePath = (String)getAttribute();
  -
  -    	setAlias(new UserAlias(alias, attributePath, aliasPath));
  -    	
  -    	return this;
  +        if (getParentCriterion() != null)
  +        {    
  +            return getParentCriterion().getUserAlias();
  +        }
  +        else
  +        {
  +            return null;
  +        }
       }
  -   
   
   }
  
  
  
  1.3       +28 -88    db-ojb/src/java/org/apache/ojb/broker/query/UserAlias.java
  
  Index: UserAlias.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/UserAlias.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UserAlias.java	19 Jun 2004 09:21:37 -0000	1.2
  +++ UserAlias.java	24 Sep 2004 19:36:13 -0000	1.3
  @@ -15,10 +15,10 @@
    * limitations under the License.
    */
   
  -import java.util.ArrayList;
   import java.util.HashMap;
  -import java.util.Iterator;
  +import java.util.HashSet;
   import java.util.Map;
  +import java.util.Set;
   
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  @@ -32,10 +32,9 @@
    */
   public class UserAlias
   {
  -    private Map m_mapping = new HashMap();
  +    private Set m_pathSegments = new HashSet();
       private String m_name = null;
  -    private String m_attributePath = null;
  -    private boolean m_allPathsAliased = false;
  +    private boolean m_allPathsAliased = true;
       private Logger m_logger = LoggerFactory.getLogger(UserAlias.class);
   
       /**
  @@ -49,79 +48,6 @@
       }
   
       /**
  -     * Constructor declaration
  -     *
  -     * @param name the name of the alias
  -     * @param attributePath the full path of the SelectionCriteria attribute
  -     * @param aliasPath the portion of the attributePath which should be aliased.
  -     * This should be unambiguous.  If ambiguous portions need aliasing (e.g.
  -     * B.C in allAs.B.C.B.C), use add() instead
  -     */
  -    public UserAlias(String name, String attributePath, String aliasPath)
  -    {
  -        m_name = name;
  -        m_attributePath = attributePath;
  -        if (attributePath.lastIndexOf(aliasPath) == -1)
  -        {
  -            m_logger.warn("aliasPath should be a substring of attributePath");
  -        }
  -        initMapping(attributePath, aliasPath);
  -    }
  -
  -    /**
  -     * Constructor declaration
  -     *
  -     * @param name the name of the alias
  -     * @param attributePath the full path of the SelectionCriteria attribute
  -     * @param allPathsAliased indicates that all path portions of attributePath
  -     * should be aliased (previously was the default)
  -     */
  -    public UserAlias(String name, String attributePath, boolean allPathsAliased)
  -    {
  -        m_name = name;
  -        m_attributePath = attributePath;
  -        m_allPathsAliased = allPathsAliased;
  -    }
  -
  -    /**
  -     * generates the mapping from the aliasPath
  -     * @param aliasPath the portion of attributePath which should be aliased
  -     *
  -     */
  -    private void initMapping(String attributePath, String aliasPath)
  -    {
  -        Iterator aliasSegmentItr = pathToSegments(aliasPath).iterator();
  -        String currPath = "";
  -        String separator = "";
  -        while (aliasSegmentItr.hasNext())
  -        {
  -            currPath = currPath + separator + (String) aliasSegmentItr.next();
  -            int beginIndex = attributePath.indexOf(currPath);
  -            if (beginIndex == -1)
  -            {
  -                break;
  -            }
  -            int endIndex = beginIndex + currPath.length();
  -            m_mapping.put(attributePath.substring(0, endIndex), m_name);
  -            separator = ".";
  -        }
  -    }
  -
  -    private ArrayList pathToSegments(String path)
  -    {
  -        ArrayList segments = new ArrayList();
  -        int sp = path.indexOf('.');
  -        while (sp != -1)
  -        {
  -            segments.add(path.substring(0, sp));
  -            path = path.substring(sp + 1);
  -            sp = path.indexOf('.');
  -        }
  -        segments.add(path);
  -        return segments;
  -    }
  -
  -    /**
        * Returns the name of this alias
        */
       public String getName()
  @@ -131,31 +57,45 @@
   
       /**
        * Returns the name of this alias if path has been added
  -     * to the aliased portions of attributePath
  +     * to the aliased portions of attributePath.
        *
        * @param path the path to test for inclusion in the alias
        */
       public String getAlias(String path)
       {
  -        if (m_allPathsAliased && m_attributePath.lastIndexOf(path) != -1)
  +        if (m_allPathsAliased)
           {
               return m_name;
           }
  -        Object retObj = m_mapping.get(path);
  -        if (retObj != null)
  +        else if (m_pathSegments.contains(path))
           {
  -            return (String) retObj;
  +            return m_name;
  +        }
  +        else
  +        {
  +            return null;
           }
  -        return null;
       }
   
       /**
  -     * Adds a path to the aliased paths
  -     *
  -     * @param path the path to add to the aliased paths
  +     * Adds a path segment to the aliased paths.
  +     * @param path the path to be added to the aliased paths
        */
       public void add(String path)
       {
  -        m_mapping.put(path, m_name);
  +        m_pathSegments.add(path);
  +        
  +        m_allPathsAliased = false;
       }
  +    
  +    /**
  +     * Creates the pathSegments based on attributePath and aliasPath. 
  +     * Do nothing here !
  +     * @param attributePath the attributePath
  +     */
  +    void addAttributePath(String attributePath)
  +    {
  +        // do nothing
  +    }
  +
   }
  
  
  
  1.3       +1 -23     db-ojb/src/java/org/apache/ojb/broker/query/AbstractCriterion.java
  
  Index: AbstractCriterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/AbstractCriterion.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractCriterion.java	22 Sep 2004 20:18:53 -0000	1.2
  +++ AbstractCriterion.java	24 Sep 2004 19:36:13 -0000	1.3
  @@ -24,9 +24,6 @@
    */
   public abstract class AbstractCriterion implements Criterion
   {
  -	// holds the path segment(s) to which the alias applies
  -	private UserAlias m_userAlias = null;
  -
   	private Criterion m_parentCriterion = null;
   
       /**
  @@ -53,23 +50,4 @@
   		m_parentCriterion = parent;
   	}
       
  -    /**
  -     * @see org.apache.ojb.broker.query.Criterion#getUserAlias()
  -     */
  -    public UserAlias getUserAlias()
  -    {
  -        return m_userAlias;
  -    }
  -
  -
  -    /**
  -     * Sets the alias using a userAlias object. 
  -     * @param userAlias   The alias to set
  -     */
  -    public Criterion setAlias(UserAlias userAlias)
  -    {
  -    	m_userAlias = userAlias;
  -    	return this;
  -    }	
  -
   }
  
  
  
  1.10      +15 -30    db-ojb/src/java/org/apache/ojb/broker/query/FieldCriteria.java
  
  Index: FieldCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/FieldCriteria.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FieldCriteria.java	22 May 2004 08:37:23 -0000	1.9
  +++ FieldCriteria.java	24 Sep 2004 19:36:13 -0000	1.10
  @@ -23,46 +23,34 @@
    */
   public class FieldCriteria extends SelectionCriteria
   {
  -	// PAW
  -//	static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue, EQUAL, anAlias);
  +        return new FieldCriteria(anAttribute, aValue, EQUAL);
       }
   
  -	// PAW
  -//	static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
  +        return new FieldCriteria(anAttribute, aValue, NOT_EQUAL);
       }
   
  -	// PAW
  -//	static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue,GREATER, anAlias);
  +        return new FieldCriteria(anAttribute, aValue,GREATER);
       }
   
  -	// PAW
  -//	static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
  +        return new FieldCriteria(anAttribute, aValue, NOT_GREATER);
       }
   
  -	// PAW
  -//	static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue, LESS, anAlias);
  +        return new FieldCriteria(anAttribute, aValue, LESS);
       }
   
  -	// PAW
  -//	static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
  -	static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue)
       {
  -        return new FieldCriteria(anAttribute, aValue, NOT_LESS, anAlias);
  +        return new FieldCriteria(anAttribute, aValue, NOT_LESS);
       }
   
   	// BRJ: indicate whether field name should be translated into column name
  @@ -75,13 +63,10 @@
   	 * @param anAttribute  column- or fieldName
   	 * @param aValue  the value to compare with
   	 * @param negative  criteria is negated (ie NOT LIKE instead of LIKE)
  -	 * @param alias  use alias to link anAttribute to
   	 */
  -	// PAW
  -//	FieldCriteria(Object anAttribute, Object aValue, String aClause, String alias)
  -	FieldCriteria(Object anAttribute, Object aValue, String aClause, UserAlias alias)
  +	FieldCriteria(Object anAttribute, Object aValue, String aClause)
   	{
  -		super(anAttribute, aValue, alias);
  +		super(anAttribute, aValue);
           m_clause = aClause;
   	}
   
  
  
  
  1.12      +3 -7      db-ojb/src/java/org/apache/ojb/broker/query/InCriteria.java
  
  Index: InCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/InCriteria.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- InCriteria.java	22 May 2004 08:37:23 -0000	1.11
  +++ InCriteria.java	24 Sep 2004 19:36:13 -0000	1.12
  @@ -25,15 +25,11 @@
    */
   public class InCriteria extends ValueCriteria
   {
  -	InCriteria(Object anAttribute, Object aValue, String aClause, String anAlias)
  +	InCriteria(Object anAttribute, Object aValue, String aClause)
   	{
  -		super(anAttribute, aValue, aClause, anAlias);
  +		super(anAttribute, aValue, aClause);
   	}
    
  -	InCriteria(Object anAttribute, Object aValue, String aClause, UserAlias anAlias)
  -	{
  -		super(anAttribute, aValue, aClause, anAlias);
  -	}
    
   	/**
   	 * @see org.apache.ojb.broker.query.SelectionCriteria#isBindable()
  
  
  
  1.3       +9 -30     db-ojb/src/java/org/apache/ojb/broker/query/IdentityCriterion.java
  
  Index: IdentityCriterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/IdentityCriterion.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IdentityCriterion.java	22 Sep 2004 20:18:54 -0000	1.2
  +++ IdentityCriterion.java	24 Sep 2004 19:36:13 -0000	1.3
  @@ -34,24 +34,14 @@
    */
   public class IdentityCriterion extends SelectionCriteria
   {
  -	static IdentityCriterion buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static IdentityCriterion buildEqualToCriteria(Object anAttribute, Object aValue)
   	{
  -		return new IdentityCriterion(anAttribute, aValue, EQUAL, anAlias);
  +		return new IdentityCriterion(anAttribute, aValue, EQUAL);
   	}
   
  -	static IdentityCriterion buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static IdentityCriterion buildNotEqualToCriteria(Object anAttribute, Object aValue)
   	{
  -		return new IdentityCriterion(anAttribute, aValue, NOT_EQUAL, anAlias);
  -	}
  -
  -	static IdentityCriterion buildEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new IdentityCriterion(anAttribute, aValue, EQUAL, anAlias);
  -	}
  -
  -	static IdentityCriterion buildNotEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new IdentityCriterion(anAttribute, aValue, NOT_EQUAL, anAlias);
  +		return new IdentityCriterion(anAttribute, aValue, NOT_EQUAL);
   	}
   	
       // the list of SelectionCriteria based on the identity
  @@ -61,26 +51,15 @@
       /**
        * @param anAttribute
        * @param aValue
  -     * @param alias
        */
  -    IdentityCriterion(Object anAttribute, Object aValue, String aClause, String alias)
  +    IdentityCriterion(Object anAttribute, Object aValue, String aClause)
       {
  -        super(anAttribute, aValue, alias);
  +        super(anAttribute, aValue);
  +        
           setCriteriaList(new ArrayList());
           setClause(aClause);
       }
       
  -    /**
  -     * @param anAttribute
  -     * @param aValue
  -     * @param aUserAlias
  -     */
  -    IdentityCriterion(Object anAttribute, Object aValue, String aClause, UserAlias aUserAlias)
  -    {
  -        super(anAttribute, aValue, aUserAlias);
  -        setCriteriaList(new ArrayList());
  -        setClause(aClause);
  -    }
       
       /**
        * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
  @@ -138,7 +117,7 @@
           for (int i = 0;i < pkFields.length; i++)
           {
               String pkAttribute = attribute + pkFields[i].getAttributeName();
  -    		ValueCriteria c = new ValueCriteria(pkAttribute, pkValues[i], getClause(), getUserAlias());
  +    		ValueCriteria c = new ValueCriteria(pkAttribute, pkValues[i], getClause());
       		
       		c.setParentCriterion(getParentCriterion()); // set the parent
       		crits.add(c);
  
  
  
  1.11      +32 -103   db-ojb/src/java/org/apache/ojb/broker/query/ValueCriteria.java
  
  Index: ValueCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/ValueCriteria.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ValueCriteria.java	15 Sep 2004 17:18:44 -0000	1.10
  +++ ValueCriteria.java	24 Sep 2004 19:36:13 -0000	1.11
  @@ -24,131 +24,74 @@
    */ 
   public class ValueCriteria extends SelectionCriteria
   {
  -	static ValueCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static ValueCriteria buildEqualToCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, EQUAL);
   	}
   
  -	static ValueCriteria buildEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static ValueCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, NOT_EQUAL);
   	}
   
  -	static ValueCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static ValueCriteria buildGreaterCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
  -	}
  -	static ValueCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
  +		return new ValueCriteria(anAttribute, aValue,GREATER);
   	}
   
  -	static ValueCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue,GREATER, anAlias);
  -	}
  -	static ValueCriteria buildGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static ValueCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue,GREATER, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, NOT_GREATER);
   	}
   
  -	static ValueCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
  -	}
  -	static ValueCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static ValueCriteria buildLessCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, LESS);
   	}
   
  -	static ValueCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static ValueCriteria buildNotLessCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
  -	}
  -	static ValueCriteria buildLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, NOT_LESS);
   	}
   
  -	static ValueCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static ValueCriteria buildLikeCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
  -	}
  -	static ValueCriteria buildNotLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
  +		return new LikeCriteria(anAttribute, aValue, LIKE);
   	}
   
  -	static ValueCriteria buildLikeCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static ValueCriteria buildNotLikeCriteria(Object anAttribute, Object aValue)
   	{
  -		return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
  -	}
  -	static ValueCriteria buildLikeCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
  +		return new ValueCriteria(anAttribute, aValue, NOT_LIKE);
   	}
   
  -	static ValueCriteria buildNotLikeCriteria(Object anAttribute, Object aValue, String anAlias)
  -	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
  -	}
  -	static ValueCriteria buildNotLikeCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static InCriteria buildInCriteria(Object anAttribute, Object aValue)
   	{
  -		return new ValueCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
  +		return new InCriteria(anAttribute, aValue, IN);
   	}
   
  -	static InCriteria buildInCriteria(Object anAttribute, Object aValue, String anAlias)
  -	{
  -		return new InCriteria(anAttribute, aValue, IN, anAlias);
  -	}
  -	static InCriteria buildInCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  +	static InCriteria buildNotInCriteria(Object anAttribute, Object aValue)
   	{
  -		return new InCriteria(anAttribute, aValue, IN, anAlias);
  +		return new InCriteria(anAttribute, aValue, NOT_IN);
   	}
   
  -	static InCriteria buildNotInCriteria(Object anAttribute, Object aValue, String anAlias)
  +	static NullCriteria buildNullCriteria(String anAttribute)
   	{
  -		return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
  -	}
  -	static InCriteria buildNotInCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
  -	{
  -		return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
  +		return new NullCriteria(anAttribute, IS_NULL);
   	}
   
  -	static NullCriteria buildNullCriteria(String anAttribute, String anAlias)
  +	static NullCriteria buildNotNullCriteria(String anAttribute)
   	{
  -		return new NullCriteria(anAttribute, IS_NULL, anAlias);
  -	}
  -	static NullCriteria buildNullCriteria(String anAttribute, UserAlias anAlias)
  -	{
  -		return new NullCriteria(anAttribute, IS_NULL, anAlias);
  -	}
  -
  -	static NullCriteria buildNotNullCriteria(String anAttribute, String anAlias)
  -	{
  -		return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
  -	}
  -	static NullCriteria buildNotNullCriteria(String anAttribute, UserAlias anAlias)
  -	{
  -		return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
  +		return new NullCriteria(anAttribute, NOT_IS_NULL);
   	}
      
  -	static BetweenCriteria buildBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String anAlias)
  -	{
  -		return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN, anAlias);
  -	}
  -	static BetweenCriteria buildBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, UserAlias anAlias)
  +	static BetweenCriteria buildBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2)
   	{
  -		return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN, anAlias);
  +		return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN);
   	}
   
  -	static BetweenCriteria buildNotBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String anAlias)
  -	{
  -		return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN, anAlias);
  -	}
  -	static BetweenCriteria buildNotBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, UserAlias anAlias)
  +	static BetweenCriteria buildNotBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2)
   	{
  -		return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN, anAlias);
  +		return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN);
   	}
   	
       private String m_clause;
  @@ -159,28 +102,14 @@
   	 * @param anAttribute  column- or fieldName
   	 * @param aValue  the value to compare with
   	 * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
  -	 * @param anAlias use alias to link anAttribute to
  -	 */
  -	ValueCriteria(Object anAttribute, Object aValue, String aClause, String anAlias)
  -	{
  -		super(anAttribute, aValue, anAlias);
  -		m_clause = aClause;
  -	}
  -    
  -	/**
  -	 * Constructor declaration
  -	 *
  -	 * @param anAttribute  column- or fieldName
  -	 * @param aValue  the value to compare with
  -	 * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
  -	 * @param aUserAlias userAlias to link anAttribute to
   	 */
  -	ValueCriteria(Object anAttribute, Object aValue, String aClause, UserAlias aUserAlias)
  +	ValueCriteria(Object anAttribute, Object aValue, String aClause)
   	{
  -		super(anAttribute, aValue, aUserAlias);
  +		super(anAttribute, aValue);
   		m_clause = aClause;
   	}
       
  +   
       /**
        * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
        */
  
  
  
  1.3       +1 -20     db-ojb/src/java/org/apache/ojb/broker/query/Criterion.java
  
  Index: Criterion.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/Criterion.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Criterion.java	22 Sep 2004 20:18:54 -0000	1.2
  +++ Criterion.java	24 Sep 2004 19:36:13 -0000	1.3
  @@ -73,24 +73,5 @@
   	 * @return UserAlias
   	 */
   	public UserAlias getUserAlias();
  -
  -	/**
  -	 * Sets the alias. Empty String is regarded as null.
  -	 * @param alias The alias to set
  -	 */
  -	public Criterion setAlias(String alias);
  -
  -	/**
  -	 * Sets the alias. Empty String is regarded as null.
  -	 * @param alias The alias to set
  -	 * @param aliasPath The path segment(s) to which the alias applies
  -	 */
  -	public Criterion setAlias(String alias, String aliasPath);
  -
  -	/**
  -	 * Sets the alias using a userAlias object. 
  -	 * @param userAlias The alias to set
  -	 */
  -	public Criterion setAlias(UserAlias userAlias);
   	
   }
  
  
  
  1.14      +3 -14     db-ojb/src/java/org/apache/ojb/broker/query/LikeCriteria.java
  
  Index: LikeCriteria.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/query/LikeCriteria.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LikeCriteria.java	23 Jul 2004 12:18:52 -0000	1.13
  +++ LikeCriteria.java	24 Sep 2004 19:36:13 -0000	1.14
  @@ -47,23 +47,12 @@
   	 * @param anAttribute
   	 * @param aValue
   	 * @param aClause
  -	 * @param anAlias
   	 */
  -	public LikeCriteria(Object anAttribute, Object aValue, String aClause, String anAlias)
  +	public LikeCriteria(Object anAttribute, Object aValue, String aClause)
   	{
  -		super(anAttribute, generateSQLSearchPattern(aValue), aClause, anAlias);
  +		super(anAttribute, generateSQLSearchPattern(aValue), aClause);
   	}
   
  -	/**
  -	 * @param anAttribute
  -	 * @param aValue
  -	 * @param aClause
  -	 * @param anAlias
  -	 */
  -	public LikeCriteria(Object anAttribute, Object aValue, String aClause, UserAlias anAlias)
  -	{
  -		super(anAttribute, generateSQLSearchPattern(aValue), aClause, anAlias);
  -	}
   
       /**
        * @see org.apache.ojb.broker.query.SelectionCriteria#bind(java.lang.Object)
  
  
  
  1.84      +3 -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.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- SqlQueryStatement.java	15 Sep 2004 19:10:36 -0000	1.83
  +++ SqlQueryStatement.java	24 Sep 2004 19:36:13 -0000	1.84
  @@ -191,10 +191,8 @@
   			 */
   			if ((tableAlias == null) && (colName.lastIndexOf(".") == -1))
   			{
  -				/**
  -				 * pathName might be an alias, so check this first
  -				 */
  -				tableAlias = getTableAlias(pathName, useOuterJoins, new UserAlias(pathName, pathName, pathName), null, pathClasses);
  +				// pathName might be an alias, so check this first
  +				tableAlias = getTableAlias(pathName, useOuterJoins, new UserAlias(pathName), null, pathClasses);
   			}
   
   			if (tableAlias != null)
  
  
  

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