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/jdori/org/apache/ojb/tutorial5 Application.java
Date Sat, 13 Sep 2003 14:33:58 GMT
brj         2003/09/13 07:33:58

  Modified:    src/java/org/apache/ojb/broker/query SqlCriteria.java
                        BetweenCriteria.java ExistsCriteria.java
                        NullCriteria.java InCriteria.java Criteria.java
                        SelectionCriteria.java FieldCriteria.java
                        ValueCriteria.java
               src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlGeneratorDefaultImpl.java SqlQueryStatement.java
               src/test/org/apache/ojb repository_database.xml
               .        build.properties
               profile  sapdb.profile mysql.profile
               src/test/org/apache/ojb/broker QueryTest.java
               src/java/org/apache/ojb/broker/accesslayer
                        StatementManager.java
               src/test/org/apache/ojb/odmg
                        ContractVersionEffectivenessOQLTest.java
               src/jdori/org/apache/ojb/tutorial5 Application.java
  Removed:     src/java/org/apache/ojb/broker/query
                        EqualToFieldCriteria.java GreaterThanCriteria.java
                        GreaterThanFieldCriteria.java LessThanCriteria.java
                        LikeCriteria.java EqualToCriteria.java
                        LessThanFieldCriteria.java
  Log:
  enhanced support for subqueries. 
  subqueries can be used like attributes
  ie. select count(*) from tab where x like 'bla%' > 20
  
  Revision  Changes    Path
  1.5       +3 -3      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SqlCriteria.java	1 Mar 2003 20:19:13 -0000	1.4
  +++ SqlCriteria.java	13 Sep 2003 14:33:57 -0000	1.5
  @@ -69,7 +69,7 @@
        */
       SqlCriteria(String anSqlStatement)
       {
  -        super(anSqlStatement, null, false, null);
  +        super(anSqlStatement, null, null);
       }
   
       /*
  @@ -77,7 +77,7 @@
   	 */
       public String getClause()
       {
  -        return getAttribute();
  +        return (String)getAttribute();
       }
   
   	/**
  
  
  
  1.6       +4 -40     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BetweenCriteria.java	1 Mar 2003 20:19:13 -0000	1.5
  +++ BetweenCriteria.java	13 Sep 2003 14:33:57 -0000	1.6
  @@ -65,30 +65,10 @@
   {
       private Object value2;
   
  -    /**
  -     * Constructor for BetweenCriteria.
  -     * @param fieldName the name of the field
  -     * @param anArg1 lower boundary
  -     * @param anArg2 upper boundary
  -     * @param negative  use negative form
  -     * @param alias  use alias to link anAttribute to
  -     */
  -    BetweenCriteria(String fieldName, Object anArg1, Object anArg2, boolean negative, String alias)
  +    BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause, String anAlias)
       {
  -        super(fieldName, anArg1, negative, alias);
  -        setValue2(anArg2);
  -    }
  -
  -    /**
  -     * Constructor for BetweenCriteria.
  -     * @param fieldName the name of the field
  -     * @param anArg1 lower boundary
  -     * @param anArg2 upper boundary
  -     * @param alias  use alias to link anAttribute to
  -     */
  -    BetweenCriteria(String fieldName, Object anArg1, Object anArg2, String alias)
  -    {
  -        this (fieldName, anArg1, anArg2, false, alias);
  +        super(anAttribute, aValue1, aClause, anAlias);
  +        setValue2(aValue2);
       }
   
       /**
  @@ -107,22 +87,6 @@
       		setValue2(newValue);
       		setBound(true); 		
       	}
  -    }
  -
  -
  -    /*
  -	 * @see SelectionCriteria#getClause()
  -	 */
  -    public String getClause()
  -    {
  -        if (isNegative())
  -        {
  -            return " NOT BETWEEN ";
  -        }    
  -        else
  -        {
  -            return " BETWEEN ";
  -        }    
       }
   
   
  
  
  
  1.4       +5 -3      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExistsCriteria.java	1 Mar 2003 20:19:13 -0000	1.3
  +++ ExistsCriteria.java	13 Sep 2003 14:33:57 -0000	1.4
  @@ -62,6 +62,7 @@
    */
   public class ExistsCriteria extends SelectionCriteria
   {
  +    private boolean m_negative = false;
       /**
        * Constructor for ExistsCriteria.
        * @param subQuery
  @@ -69,7 +70,8 @@
        */
       ExistsCriteria(Query subQuery, boolean negative)
       {
  -        super("", subQuery, negative, null);
  +        super("", subQuery, null);
  +        m_negative = negative;
       }
   
       /*
  @@ -77,7 +79,7 @@
   	 */
       public String getClause()
       {
  -        if (isNegative())
  +        if (m_negative)
           {
               return " NOT EXISTS";
           }    
  
  
  
  1.6       +5 -27     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NullCriteria.java	20 Mar 2003 20:48:20 -0000	1.5
  +++ NullCriteria.java	13 Sep 2003 14:33:57 -0000	1.6
  @@ -62,36 +62,14 @@
    */
   public class NullCriteria extends ValueCriteria
   {
  -    /**
  -     * Constructor declaration
  -     *
  -     * @param anAttribute  column- or fieldName
  -     * @param negative  criteria is negated (ie NOT LIKE instead of LIKE)
  -     * @param alias  use alias to link anAttribute to
  -     */
  -	NullCriteria(String anAttribute, boolean negative, String alias)
  -	{
  -		super(anAttribute, null, negative, alias);
  -	}
  -
  -    public String toString()
  +    NullCriteria(String anAttribute, String aClause, String anAlias)
       {
  -        return getAttribute() + getClause();
  +        super(anAttribute, null, aClause, anAlias);
       }
   
  -    /*
  -     * @see SelectionCriteria#getClause()
  -     */
  -    public String getClause()
  +    public String toString()
       {
  -        if (isNegative())
  -        {
  -            return " IS NOT NULL ";
  -        }
  -        else
  -        {
  -            return " IS NULL ";
  -        }
  +        return getAttribute() + getClause();
       }
   
       /*
  
  
  
  1.8       +4 -27     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InCriteria.java	1 Mar 2003 20:19:13 -0000	1.7
  +++ InCriteria.java	13 Sep 2003 14:33:57 -0000	1.8
  @@ -64,34 +64,11 @@
    */
   public class InCriteria extends ValueCriteria
   {
  -    /**
  -     * Constructor declaration
  -     *
  -     * @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
  -     */
  -	InCriteria(String anAttribute, Object aValue, boolean negative, String alias)
  -	{
  -		super(anAttribute, aValue, negative, alias);
  -	}
  -
  -    /*
  -	 * @see SelectionCriteria#getClause()
  -	 */
  -    public String getClause()
  +    InCriteria(Object anAttribute, Object aValue, String aClause, String anAlias)
       {
  -        if (isNegative())
  -        {
  -            return " NOT IN ";
  -        }    
  -        else
  -        {
  -            return " IN ";
  -        }    
  +        super(anAttribute, aValue, aClause, anAlias);
       }
  -
  + 
   	/**
   	 * @see org.apache.ojb.broker.query.SelectionCriteria#isBindable()
   	 * BRJ: empty Collection is bindable
  
  
  
  1.32      +51 -37    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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Criteria.java	22 May 2003 18:50:23 -0000	1.31
  +++ Criteria.java	13 Sep 2003 14:33:57 -0000	1.32
  @@ -190,7 +190,7 @@
   	 * @param inLimit the maximum number of values for IN (-1 for no limit)
   	 * @return
   	 */
  -	protected List splitInCriteria(String attribute, Collection values, boolean negative, int inLimit)
  +	protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
   	{
   		List result = new ArrayList();
   		Collection inCollection = new ArrayList();
  @@ -198,7 +198,7 @@
   		if (values == null || values.isEmpty())
   		{
   			// OQL creates empty Criteria for late binding
  -			result.add(new InCriteria(attribute, values, negative, getAlias()));
  +			result.add(buildInCriteria(attribute, negative, values));
   		}
   		else
   		{
  @@ -209,7 +209,7 @@
   				inCollection.add(iter.next());
   				if (inCollection.size() == inLimit || !iter.hasNext())
   				{
  -					result.add(new InCriteria(attribute, inCollection, negative, getAlias()));
  +					result.add(buildInCriteria(attribute, negative, inCollection));
   					inCollection = new ArrayList();
   				}
   			}
  @@ -217,6 +217,19 @@
   		return result;
   	}
   
  +
  +    private InCriteria buildInCriteria(Object attribute, boolean negative, Collection values)
  +    {
  +        if (negative)
  +        {
  +            return ValueCriteria.buildNotInCriteria(attribute, values, getAlias());
  +        }
  +        else
  +        {
  +            return ValueCriteria.buildInCriteria(attribute, values, getAlias());           
  +        }    
  +    }
  +
   	/**
   	 * Get an Enumeration with all sub criteria
   	 * @return Enumaration
  @@ -280,7 +293,8 @@
   	 */
   	public void addEqualTo(String attribute, Object value)
   	{
  -		addSelectionCriteria(new EqualToCriteria(attribute, value, false, getAlias()));
  +//		addSelectionCriteria(new EqualToCriteria(attribute, value, false, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildEqualToCriteria(attribute, value, getAlias()));
   	}
   
       /**
  @@ -293,7 +307,7 @@
        */
       public void addColumnEqualTo(String column, Object value)
       {
  -        SelectionCriteria c = new EqualToCriteria(column, value, false, getAlias());
  +        SelectionCriteria c = ValueCriteria.buildEqualToCriteria(column, value, getAlias());
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
       }
  @@ -308,7 +322,7 @@
        */
       public void addColumnEqualToField(String column, Object fieldName)
       {
  -        SelectionCriteria c = new EqualToFieldCriteria(column, fieldName, false, getAlias());
  +        SelectionCriteria c = FieldCriteria.buildEqualToCriteria(column, fieldName, getAlias());
           c.setTranslateAttribute(false);
           addSelectionCriteria(c);
       }
  @@ -367,7 +381,7 @@
   	 */
   	public void addEqualToField(String attribute, String fieldName)
   	{
  -		SelectionCriteria c = new EqualToFieldCriteria(attribute, fieldName, false, getAlias());
  +        FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, fieldName, getAlias());
   		addSelectionCriteria(c);
   	}
   
  @@ -382,7 +396,7 @@
   	 */
   	public void addNotEqualToField(String attribute, String fieldName)
   	{
  -		SelectionCriteria c = new EqualToFieldCriteria(attribute, fieldName, true, getAlias());
  +		SelectionCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, fieldName, getAlias());
   		addSelectionCriteria(c);
   	}
   
  @@ -397,7 +411,7 @@
   	 */
   	public void addNotEqualToColumn(String attribute, String colName)
   	{
  -        FieldCriteria c = new EqualToFieldCriteria(attribute, colName, true, getAlias());
  +        FieldCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, colName, getAlias());
           c.setTranslateField(false);
   		addSelectionCriteria(c);
   	}
  @@ -413,7 +427,7 @@
   	 */
   	public void addEqualToColumn(String attribute, String colName)
   	{
  -		FieldCriteria c = new EqualToFieldCriteria(attribute, colName, false, getAlias());
  +		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getAlias());
           c.setTranslateField(false);
   		addSelectionCriteria(c);
   	}
  @@ -425,9 +439,9 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addGreaterOrEqualThan(String attribute, Object value)
  +	public void addGreaterOrEqualThan(Object attribute, Object value)
   	{
  -		addSelectionCriteria(new LessThanCriteria(attribute, value, true, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildNotLessCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -439,7 +453,7 @@
   	 */
   	public void addGreaterOrEqualThanField(String attribute, Object value)
   	{
  -		addSelectionCriteria(new LessThanFieldCriteria(attribute, value, true, getAlias()));
  +		addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -449,9 +463,9 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addLessOrEqualThan(String attribute, Object value)
  +	public void addLessOrEqualThan(Object attribute, Object value)
   	{
  -		addSelectionCriteria(new GreaterThanCriteria(attribute, value, true, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -463,7 +477,7 @@
   	 */
   	public void addLessOrEqualThanField(String attribute, Object value)
   	{
  -		addSelectionCriteria(new GreaterThanFieldCriteria(attribute, value, true, getAlias()));
  +		addSelectionCriteria(FieldCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -483,7 +497,7 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addLike(String attribute, Object value)
  +	public void addLike(Object attribute, Object value)
   	{
   		String pattern;
   
  @@ -497,7 +511,7 @@
   			pattern = null;
   		}
   
  -		addSelectionCriteria(new LikeCriteria(attribute, pattern, false, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildLikeCriteria(attribute, pattern, getAlias()));
   	}
   
   	/**
  @@ -521,7 +535,7 @@
   			pattern = null;
   		}
   
  -		addSelectionCriteria(new LikeCriteria(attribute, pattern, true, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildNotLikeCriteria(attribute, pattern, getAlias()));
   	}
   
   	/**
  @@ -531,9 +545,9 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addNotEqualTo(String attribute, Object value)
  +	public void addNotEqualTo(Object attribute, Object value)
   	{
  -		addSelectionCriteria(new EqualToCriteria(attribute, value, true, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildNotEqualToCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -543,9 +557,9 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addGreaterThan(String attribute, Object value)
  +	public void addGreaterThan(Object attribute, Object value)
   	{
  -		addSelectionCriteria(new GreaterThanCriteria(attribute, value, false, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildGreaterCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -557,7 +571,7 @@
   	 */
   	public void addGreaterThanField(String attribute, Object value)
   	{
  -		addSelectionCriteria(new GreaterThanFieldCriteria(attribute, value, false, getAlias()));
  +		addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -567,9 +581,9 @@
   	 * @param  attribute   The field name to be used
   	 * @param  value       An object representing the value of the field
   	 */
  -	public void addLessThan(String attribute, Object value)
  +	public void addLessThan(Object attribute, Object value)
   	{
  -		addSelectionCriteria(new LessThanCriteria(attribute, value, false, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildLessCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -581,7 +595,7 @@
   	 */
   	public void addLessThanField(String attribute, Object value)
   	{
  -		addSelectionCriteria(new LessThanFieldCriteria(attribute, value, false, getAlias()));
  +		addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value, getAlias()));
   	}
   
   	/**
  @@ -707,7 +721,7 @@
   	 */
   	public void addIsNull(String attribute)
   	{
  -		addSelectionCriteria(new NullCriteria(attribute, false, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildNullCriteria(attribute, getAlias()));
   	}
   
   	/**
  @@ -718,7 +732,7 @@
   	 */
   	public void addNotNull(String attribute)
   	{
  -		addSelectionCriteria(new NullCriteria(attribute, true, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildNotNullCriteria(attribute, getAlias()));
   	}
   
   	/**
  @@ -729,9 +743,9 @@
   	 * @param  value1   The lower boundary
   	 * @param  value2   The upper boundary
   	 */
  -	public void addBetween(String attribute, Object value1, Object value2)
  +	public void addBetween(Object attribute, Object value1, Object value2)
   	{
  -		addSelectionCriteria(new BetweenCriteria(attribute, value1, value2, false, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));
   	}
   
   	/**
  @@ -742,9 +756,9 @@
   	 * @param  value1   The lower boundary
   	 * @param  value2   The upper boundary
   	 */
  -	public void addNotBetween(String attribute, Object value1, Object value2)
  +	public void addNotBetween(Object attribute, Object value1, Object value2)
   	{
  -		addSelectionCriteria(new BetweenCriteria(attribute, value1, value2, true, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2, getAlias()));
   	}
   
   	/**
  @@ -802,9 +816,9 @@
   	 * @param attribute
   	 * @param subQuery
   	 */
  -	public void addIn(String attribute, Query subQuery)
  +	public void addIn(Object attribute, Query subQuery)
   	{
  -		addSelectionCriteria(new InCriteria(attribute, subQuery, false, getAlias()));
  +		addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getAlias()));
   	}
   
   	/**
  @@ -814,7 +828,7 @@
   	 */
   	public void addNotIn(String attribute, Query subQuery)
   	{
  -		addSelectionCriteria(new InCriteria(attribute, subQuery, true, getAlias()));
  +        addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery, getAlias()));
   	}
   
   	/**
  
  
  
  1.12      +26 -17    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SelectionCriteria.java	24 Mar 2003 20:11:55 -0000	1.11
  +++ SelectionCriteria.java	13 Sep 2003 14:33:57 -0000	1.12
  @@ -69,11 +69,24 @@
    */
   public abstract class SelectionCriteria implements java.io.Serializable
   {
  -	private String m_attribute;
  +    protected static final String EQUAL = " = ";
  +    protected static final String NOT_EQUAL = " <> ";
  +    protected static final String GREATER = " > ";
  +    protected static final String NOT_GREATER = " <= ";
  +    protected static final String LESS = " < ";
  +    protected static final String NOT_LESS = " >= ";
  +    protected static final String LIKE = " LIKE ";
  +    protected static final String NOT_LIKE = " NOT LIKE ";
  +    protected static final String IS_NULL = " IS NULL ";
  +    protected static final String NOT_IS_NULL = " IS NOT NULL ";
  +    protected static final String BETWEEN = " BETWEEN ";
  +    protected static final String NOT_BETWEEN = " NOT BETWEEN ";
  +    protected static final String IN = " IN ";
  +    protected static final String NOT_IN = " NOT IN ";
  +
  +	private Object m_attribute;
   	private Object m_value;
   
  -	//  true if criterion is negated
  -	private boolean m_negative = false;
   
   	// BRJ: true if criterion is bound
   	private boolean m_bound = false;
  @@ -91,16 +104,20 @@
   	/**
   	 * Constructor declaration
   	 *
  -	 * @param anAttribute  column- or fieldName
  +	 * @param anAttribute  column- or fieldName or a Query
   	 * @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
   	 */
  -	SelectionCriteria(String anAttribute, Object aValue, boolean negative, String alias)
  +	SelectionCriteria(Object anAttribute, Object aValue, String alias)
   	{
  +        if (!(anAttribute instanceof String || anAttribute instanceof Query))
  +        {
  +            throw new IllegalArgumentException("An attribute must be a String or a Query !");
  +        }    
  +            
   		m_attribute = anAttribute;
   		m_value = aValue;
  -		this.m_negative = negative;
   		this.m_bound = !isBindable();
   		this.m_alias = alias;
   	}
  @@ -130,7 +147,7 @@
   	/**
   	 * Answer the attribute
   	 */
  -	public String getAttribute()
  +	public Object getAttribute()
   	{
   		return m_attribute;
   	}
  @@ -144,15 +161,6 @@
   	}
   
   	/**
  -	 * Gets the negative.
  -	 * @return Returns a boolean
  -	 */
  -	public boolean isNegative()
  -	{
  -		return m_negative;
  -	}
  -
  -	/**
   	 * BRJ : Used by the ODMG OQLQuery.bind() operation
   	 * @return Returns a boolean indicator
   	 */
  @@ -265,4 +273,5 @@
               return null;
           }
       }
  +
   }
  
  
  
  1.6       +51 -4     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FieldCriteria.java	20 Mar 2003 20:52:09 -0000	1.5
  +++ FieldCriteria.java	13 Sep 2003 14:33:57 -0000	1.6
  @@ -60,10 +60,41 @@
    * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
    * @version $Id$
    */
  -public abstract class FieldCriteria extends SelectionCriteria
  +public class FieldCriteria extends SelectionCriteria
   {
  +    static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue, EQUAL, anAlias);
  +    }
  +
  +    static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
  +    }
  +
  +    static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue,GREATER, anAlias);
  +    }
  +
  +    static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
  +    }
  +
  +    static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue, LESS, anAlias);
  +    }
  +
  +    static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new FieldCriteria(anAttribute, aValue, NOT_LESS, anAlias);
  +    }
  +
   	// BRJ: indicate whether field name should be translated into column name
   	private boolean m_translateField = true;
  +    private String m_clause;
   
   	/**
   	 * Constructor declaration
  @@ -73,11 +104,20 @@
   	 * @param negative  criteria is negated (ie NOT LIKE instead of LIKE)
   	 * @param alias  use alias to link anAttribute to
   	 */
  -	FieldCriteria(String anAttribute, Object aValue, boolean negative, String alias)
  +	FieldCriteria(Object anAttribute, Object aValue, String aClause, String alias)
   	{
  -		super(anAttribute, aValue, negative, alias);
  +		super(anAttribute, aValue, alias);
  +        m_clause = aClause;
   	}
   
  +    /**
  +     * @see SelectionCriteria#isBindable()
  +     */
  +    protected boolean isBindable()
  +    {
  +        return false;
  +    }
  +
   	/**
   	 * @return true if field name should be translated into column name
   	 */
  @@ -94,4 +134,11 @@
   		m_translateField = b;
   	}
   
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
  +     */
  +    public String getClause()
  +    {
  +        return m_clause;
  +    }
   }
  
  
  
  1.4       +93 -10    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValueCriteria.java	1 Mar 2003 20:19:13 -0000	1.3
  +++ ValueCriteria.java	13 Sep 2003 14:33:57 -0000	1.4
  @@ -55,24 +55,107 @@
    */
   
   /**
  - * Abstract superclass for Criteria using a value to compare with
  + * Models a Criteria comparing an attribute to a value
  + * <br>ie: name = 'Mark' , name like 'M%'
    * 
  - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
  + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
    * @version $Id$
    */ 
  -public abstract class ValueCriteria extends SelectionCriteria
  +public class ValueCriteria extends SelectionCriteria
   {
  +    static ValueCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
  +    }
  +
  +    static ValueCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
  +    }
  +
  +    static ValueCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue,GREATER, anAlias);
  +    }
  +
  +    static ValueCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
  +    }
  +
  +    static ValueCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
  +    }
  +
  +    static ValueCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
  +    }
  +
  +    static ValueCriteria buildLikeCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, LIKE, anAlias);
  +    }
  +
  +    static ValueCriteria buildNotLikeCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new ValueCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
  +    }
  +
  +    static InCriteria buildInCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new InCriteria(anAttribute, aValue, IN, anAlias);
  +    }
  +
  +    static InCriteria buildNotInCriteria(Object anAttribute, Object aValue, String anAlias)
  +    {
  +        return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
  +    }
  +
  +    static NullCriteria buildNullCriteria(String anAttribute, String anAlias)
  +    {
  +        return new NullCriteria(anAttribute, IS_NULL, anAlias);
  +    }
  +
  +    static NullCriteria buildNotNullCriteria(String anAttribute, String anAlias)
  +    {
  +        return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
  +    }
  +   
  +    static BetweenCriteria buildBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String anAlias)
  +    {
  +        return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN, anAlias);
  +    }
  +
  +    static BetweenCriteria buildNotBeweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String anAlias)
  +    {
  +        return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN, anAlias);
  +    }
  +    
  +    private String m_clause;
  +
       /**
        * Constructor declaration
        *
        * @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
  +     * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
  +     * @param anAlias use alias to link anAttribute to
        */
  -	ValueCriteria(String anAttribute, Object aValue, boolean negative, String alias)
  -	{
  -		super(anAttribute, aValue, negative, alias);
  -	}
  +    ValueCriteria(Object anAttribute, Object aValue, String aClause, String anAlias)
  +    {
  +        super(anAttribute, aValue, anAlias);
  +        m_clause = aClause;
  +    }
  +    
  +
  +    /* (non-Javadoc)
  +     * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
  +     */
  +    public String getClause()
  +    {
  +        return m_clause;
  +    }
   
   }
  
  
  
  1.19      +22 -5     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SqlGeneratorDefaultImpl.java	9 Sep 2003 19:02:31 -0000	1.18
  +++ SqlGeneratorDefaultImpl.java	13 Sep 2003 14:33:57 -0000	1.19
  @@ -443,6 +443,23 @@
           return toSQLClause(c, cld);
       }
   
  +    private String toSqlClause(Object attributeOrQuery, ClassDescriptor cld)
  +    {
  +        String result;
  +        
  +        if (attributeOrQuery instanceof Query)
  +        {
  +            Query q = (Query)attributeOrQuery;
  +            result = getPreparedSelectStatement(q,cld.getRepository().getDescriptorFor(q.getSearchClass()));
  +        }   
  +        else
  +        {
  +           result = (String)attributeOrQuery; 
  +        } 
  +
  +        return result;
  +    } 
  +    
       /**
        * Answer the SQL-Clause for a NullCriteria
        *
  @@ -451,7 +468,7 @@
        */
       private String toSQLClause(NullCriteria c, ClassDescriptor cld)
       {
  -        String colName = c.getAttribute();
  +        String colName = (String)c.getAttribute();
           return colName + c.getClause();
       }
   
  @@ -463,7 +480,7 @@
        */
       private String toSQLClause(FieldCriteria c, ClassDescriptor cld)
       {
  -        String colName = c.getAttribute();
  +        String colName = toSqlClause(c.getAttribute(), cld);
           return colName + c.getClause() + c.getValue();
       }
   
  @@ -475,7 +492,7 @@
        */
       private String toSQLClause(BetweenCriteria c, ClassDescriptor cld)
       {
  -        String colName = c.getAttribute();
  +        String colName = toSqlClause(c.getAttribute(), cld);
           return colName + c.getClause() + " ? AND ? ";
       }
   
  @@ -510,7 +527,7 @@
        */
       private String toSQLClause(SelectionCriteria c, ClassDescriptor cld)
       {
  -        String colName = c.getAttribute();
  +        String colName = toSqlClause(c.getAttribute(), cld);
           return colName + c.getClause() + " ? ";
       }
   
  
  
  
  1.55      +45 -33    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.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- SqlQueryStatement.java	5 Sep 2003 22:02:55 -0000	1.54
  +++ SqlQueryStatement.java	13 Sep 2003 14:33:57 -0000	1.55
  @@ -101,6 +101,10 @@
       private ClassDescriptor m_searchCld;
   
       private int m_aliasCount = 0;
  +    
  +    // prefix to identify attributes referencing enclosing query
  +    private static String PARENT_QUERY_PREFIX = "parentQuery.";
  +    
   
   
       /**
  @@ -186,40 +190,25 @@
           String colName = pathInfo.column;
           int sp;
   
  -        sp = colName.lastIndexOf(".");
  +        // BRJ:
  +        // check if we refer to an attribute in the parent query
  +        // this prefix is temporary !
  +        if (colName.startsWith(PARENT_QUERY_PREFIX) && m_parentStatement != null)
  +        {
  +            String[] fieldNameRef = { colName.substring(PARENT_QUERY_PREFIX.length())};
  +            return m_parentStatement.getAttributeInfo(fieldNameRef[0], useOuterJoins, aUserAlias);
  +        }
   
  +        sp = colName.lastIndexOf(".");
           if (sp == -1)
           {
               tableAlias = getRoot();
  -            // BRJ : ignore alias for simple attributes ??
  -            /*
  -            if (aUserAlias == null)
  -            {
  -                tableAlias = getRoot();
  -            }
  -            else
  -            {
  -                tableAlias = getTableAlias(colName, useOuterJoins, aUserAlias);
  -                if (tableAlias == null)
  -                {
  -                    tableAlias = getRoot();
  -                }
  -            }
  -            */
           }
           else
           {
               String pathName = colName.substring(0, sp);
               String[] fieldNameRef = { colName.substring(sp + 1)};
   
  -            // BRJ:
  -            // check if we refer to an attribute in the parent query
  -            // this prefix is temporary !
  -            if (pathName.equals("parentQuery") && m_parentStatement != null)
  -            {
  -                return m_parentStatement.getAttributeInfo(fieldNameRef[0], useOuterJoins, aUserAlias);
  -            }
  -
               tableAlias = getTableAlias(pathName, useOuterJoins, aUserAlias, fieldNameRef);
               /**
                * if we have not found an alias by the pathName or
  @@ -769,7 +758,20 @@
        */
       protected void appendSQLClause(SelectionCriteria c, StringBuffer buf)
       {
  -        AttributeInfo attrInfo = getAttributeInfo(c.getAttribute(), false, c.getAlias());
  +        // BRJ : criteria attribute is a query
  +        if (c.getAttribute() instanceof Query)
  +        {
  +            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());
           TableAlias alias = attrInfo.tableAlias;
   
           if (alias != null)
  @@ -830,6 +832,18 @@
        */
       private void appendSubQuery(Query subQuery, StringBuffer buf)
       {
  +        buf.append(" (");
  +        buf.append(getSubQuerySQL(subQuery));
  +        buf.append(") ");
  +    }
  +
  +
  +    /**
  +     * Convert subQuery to SQL
  +     * @param subQuery the subQuery value of SelectionCriteria
  +     */
  +    private String getSubQuerySQL(Query subQuery)
  +    {
           ClassDescriptor cld = getRoot().cld.getRepository().getDescriptorFor(subQuery.getSearchClass());
           String sql;
   
  @@ -847,12 +861,9 @@
               sql = new SqlSelectStatement(this ,m_platform, cld, columns, subQuery, m_logger).getStatement();
           }
   
  -        buf.append(" (");
  -        buf.append(sql);
  -        buf.append(") ");
  +        return sql;
       }
   
  -
       /**
        * Get TableAlias by the path from the target table of the query.
        * @param aPath the path from the target table of the query to this TableAlias.
  @@ -1462,12 +1473,13 @@
               else
               {
                   SelectionCriteria c = (SelectionCriteria) o;
  -                // BRJ : Outer join for OR
  +                // BRJ: Outer join for OR
                   boolean useOuterJoin = (crit.getType() == Criteria.OR);
   
  -                if (c.getAttribute() != null)
  +                // BRJ: do not build join tree for subQuery attribute                  
  +                if (c.getAttribute() != null && c.getAttribute() instanceof String)
                   {
  -                    buildJoinTreeForColumn(c.getAttribute(), useOuterJoin, c.getAlias());
  +                    buildJoinTreeForColumn((String)c.getAttribute(), useOuterJoin, c.getAlias());
                   }
                   if (c instanceof FieldCriteria)
                   {
  
  
  
  1.13      +71 -18    db-ojb/src/test/org/apache/ojb/repository_database.xml
  
  Index: repository_database.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_database.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- repository_database.xml	9 Jun 2003 12:11:24 -0000	1.12
  +++ repository_database.xml	13 Sep 2003 14:33:57 -0000	1.13
  @@ -1,4 +1,4 @@
  -<!-- @version $Id$ -->
  +
   <!--
   Define here all used connections.
   One defined connection should be defined as the default one,
  @@ -13,36 +13,89 @@
   using the MetadataManager.
   -->
   
  -
  -    <!-- this connection was used as the default one within OJB -->
  +    <!-- P6Spy for HSQLDB -->
       <jdbc-connection-descriptor
  -   		jcd-alias="@JCD_ALIAS@"
  +   		jcd-alias="default"
      		default-connection="true"
  -   		platform="@DBMS_NAME@"
  -   		jdbc-level="@JDBC_LEVEL@"
  -   		driver="@DRIVER_NAME@"
  -   		protocol="@URL_PROTOCOL@"
  -   		subprotocol="@URL_SUBPROTOCOL@"
  -   		dbalias="@URL_DBALIAS@"
  -   		username="@USER_NAME@"
  -   		password="@USER_PASSWD@"
  +   		platform="Hsqldb"
  +   		jdbc-level="2.0"
  +   		driver="com.p6spy.engine.spy.P6SpyDriver"
  +   		protocol="jdbc"
  +   		subprotocol="hsqldb"
  +   		dbalias="e:/java/jdbc/hsql/OJB"
  +   		username="sa"
  +   		password=""
           eager-release="false"
      		batch-mode="false"
           useAutoCommit="1"
           ignoreAutoCommitExceptions="false"
        >
  +        <connection-pool
  +            maxActive="10"
  +            validationQuery="" />
  +        <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
  +            <attribute attribute-name="grabSize" attribute-value="20"/>
  +            <attribute attribute-name="autoNaming" attribute-value="true"/>
  +            <attribute attribute-name="globalSequenceId" attribute-value="false"/>
  +            <attribute attribute-name="globalSequenceStart" attribute-value="10000"/>
  +        </sequence-manager>
  +   </jdbc-connection-descriptor>
   
  +    <!-- P6Spy for MySQL -->
  +    <!--jdbc-connection-descriptor
  +   		jcd-alias="default"
  +   		default-connection="true"
  +   		platform="MySQL"
  +   		jdbc-level="2.0"
  +   		driver="com.p6spy.engine.spy.P6SpyDriver"
  +   		protocol="jdbc"
  +   		subprotocol="mysql"
  +   		dbalias="//localhost:3306/ojb"
  +   		username="sa"
  +   		password=""
  +        eager-release="false"
  +   		batch-mode="false"
  +        useAutoCommit="1"
  +        ignoreAutoCommitExceptions="false"
  +     >
           <connection-pool
  -            maxActive="21"
  +            maxActive="10"
               validationQuery="" />
  +        <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
  +            <attribute attribute-name="grabSize" attribute-value="20"/>
  +            <attribute attribute-name="autoNaming" attribute-value="true"/>
  +            <attribute attribute-name="globalSequenceId" attribute-value="false"/>
  +            <attribute attribute-name="globalSequenceStart" attribute-value="10000"/>
  +        </sequence-manager>
  +   </jdbc-connection-descriptor-->
   
  +    <!-- P6Spy for SAPDB -->
  +    <!--jdbc-connection-descriptor
  +   		jcd-alias="default"
  +   		default-connection="true"
  +   		platform="Sapdb"
  +   		jdbc-level="2.0"
  +   		driver="com.p6spy.engine.spy.P6SpyDriver"
  +   		protocol="jdbc"
  +   		subprotocol="sapdb"
  +   		dbalias="//localhost/ojb"
  +   		username="ojb_adm"
  +   		password="ojb_adm"
  +        eager-release="false"
  +   		batch-mode="false"
  +        useAutoCommit="1"
  +        ignoreAutoCommitExceptions="false"
  +     >
  +        <connection-pool
  +            maxActive="10"
  +            validationQuery="" />
           <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
               <attribute attribute-name="grabSize" attribute-value="20"/>
               <attribute attribute-name="autoNaming" attribute-value="true"/>
               <attribute attribute-name="globalSequenceId" attribute-value="false"/>
               <attribute attribute-name="globalSequenceStart" attribute-value="10000"/>
           </sequence-manager>
  -   </jdbc-connection-descriptor>
  +   </jdbc-connection-descriptor-->
   
      <!-- Datasource example -->
       <!-- jdbc-connection-descriptor
  @@ -83,13 +136,13 @@
           driver="org.hsqldb.jdbcDriver"
           protocol="jdbc"
           subprotocol="hsqldb"
  -        dbalias="../OJB_FarAway"
  +        dbalias="e:/java/jdbc/hsql/OJB_FarAway"
           username="sa"
           password=""
           batch-mode="false"
       >
  -        <connection-pool
  -            maxActive="6"
  +       <connection-pool
  +            maxActive="5"
               whenExhaustedAction="0"
               validationQuery="select count(*) from OJB_HL_SEQ"
           />
  @@ -145,4 +198,4 @@
               <attribute attribute-name="key1" attribute-value="value1"/>
               <attribute attribute-name="key2" attribute-value="value2"/>
           </sequence-manager>
  -    </jdbc-connection-descriptor>
  +    </jdbc-connection-descriptor>
  \ No newline at end of file
  
  
  
  1.41      +2 -2      db-ojb/build.properties
  
  Index: build.properties
  ===================================================================
  RCS file: /home/cvs/db-ojb/build.properties,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- build.properties	27 Jul 2003 11:18:15 -0000	1.40
  +++ build.properties	13 Sep 2003 14:33:57 -0000	1.41
  @@ -43,7 +43,7 @@
   ###
   #
   # non-redistributable jars
  -# Certain jar files required for a full OJB build may not be shipped 
  +# Certain jar files required for a full OJB build may not be shipped
   # as part of the OJB distribution.
   #
   j2ee.jars=j2ee.jar
  @@ -131,4 +131,4 @@
   
   
   #
  -### Preprocessor flags end here
  +### Preprocessor flags end here
  \ No newline at end of file
  
  
  
  1.7       +2 -2      db-ojb/profile/sapdb.profile
  
  Index: sapdb.profile
  ===================================================================
  RCS file: /home/cvs/db-ojb/profile/sapdb.profile,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- sapdb.profile	1 Sep 2002 21:20:03 -0000	1.6
  +++ sapdb.profile	13 Sep 2003 14:33:57 -0000	1.7
  @@ -73,8 +73,8 @@
   buildDatabaseUrl = ${urlProtocol}:${urlSubprotocol}:${urlDbalias}
   databaseUrl = ${urlProtocol}:${urlSubprotocol}:${urlDbalias}
   databaseDriver = com.sap.dbtech.jdbc.DriverSapDB
  -databaseUser = user
  -databasePassword = password
  +databaseUser = ojb_adm
  +databasePassword = ojb_adm
   databaseHost = 127.0.0.1
   
   
  
  
  
  1.5       +1 -1      db-ojb/profile/mysql.profile
  
  Index: mysql.profile
  ===================================================================
  RCS file: /home/cvs/db-ojb/profile/mysql.profile,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mysql.profile	13 Oct 2002 10:11:40 -0000	1.4
  +++ mysql.profile	13 Sep 2003 14:33:57 -0000	1.5
  @@ -70,7 +70,7 @@
   buildDatabaseUrl = ${urlProtocol}:${urlSubprotocol}:${urlDbalias}
   databaseUrl = ${urlProtocol}:${urlSubprotocol}:${urlDbalias}
   databaseDriver = org.gjt.mm.mysql.Driver
  -databaseUser = root
  +databaseUser = 
   databasePassword =
   databaseHost = 127.0.0.1
   
  
  
  
  1.36      +30 -3     db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- QueryTest.java	17 Aug 2003 08:49:31 -0000	1.35
  +++ QueryTest.java	13 Sep 2003 14:33:58 -0000	1.36
  @@ -148,7 +148,8 @@
   
       /**
        * test Subquery
  -     * get all product groups with more than 10 articles
  +     * get all product groups with more than 10 articles, uses attribute as value !
  +     * see testSubQuery4 for a better way
        *
        * test may fail if db does not support sub queries
        */
  @@ -163,14 +164,41 @@
           subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
           subQuery.setColumns(new String[]{"count(productGroupId)"});
   
  -        crit.addLessThan("10", subQuery);    // MORE than 10 articles
  +        crit.addLessThan("10", subQuery);    // MORE than 10 articles, uses attribute as value !
  +        crit.addLessThan("groupId",new Integer(987654));
           Query q = QueryFactory.newQuery(ProductGroup.class, crit);
   
           Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
           assertTrue(results.size() == 4);
  +    }
  +
  +    /**
  +     * test Subquery
  +     * get all product groups with more than 10 articles
  +     *
  +     * test may fail if db does not support sub queries
  +     */
  +    public void testSubQuery4()
  +    {
  +
  +        ReportQueryByCriteria subQuery;
  +        Criteria subCrit = new Criteria();
  +        Criteria crit = new Criteria();
   
  +        subCrit.addEqualToField("productGroupId","parentQuery.groupId");
  +        subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  +        subQuery.setColumns(new String[]{"count(productGroupId)"});
  +
  +        crit.addGreaterThan(subQuery,"10");    // MORE than 10 articles
  +        crit.addLessThan("groupId",new Integer(987654));
  +        Query q = QueryFactory.newQuery(ProductGroup.class, crit);
  +
  +        Collection results = broker.getCollectionByQuery(q);
  +        assertNotNull(results);
  +        assertTrue(results.size() == 4);
       }
  +
   	/**
   	 * test Like Criteria
   	 */
  @@ -184,7 +212,6 @@
   		Collection results = broker.getCollectionByQuery(q);
   		assertNotNull(results);
   		assertTrue(results.size() > 0);
  -
   	}
   
   	/**
  
  
  
  1.41      +75 -203   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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- StatementManager.java	9 Sep 2003 19:02:31 -0000	1.40
  +++ StatementManager.java	13 Sep 2003 14:33:58 -0000	1.41
  @@ -127,8 +127,7 @@
        * Note; not important to synchronize completely as a threading issue in this code
        * will only result in a little extra code being executed
        */
  -    protected StatementsForClassIF getStatementsForClass(ClassDescriptor cds)
  -        throws PersistenceBrokerException
  +    protected StatementsForClassIF getStatementsForClass(ClassDescriptor cds) throws PersistenceBrokerException
       {
           StatementsForClassIF sfc = (StatementsForClassIF) m_statementTable.get(cds);
           if (sfc == null)
  @@ -137,10 +136,7 @@
               {
                   // 07.17.2003 - RB: StatementsForClassImpl is now configurable
                   //sfc = (StatementsForClassIF) new StatementsForClassImpl(m_conMan.getConnectionDescriptor(), cds);
  -                sfc =
  -                    StatementsForClassFactory.getInstance().getStatementsForClass(
  -                        m_conMan.getConnectionDescriptor(),
  -                        cds);
  +                sfc = StatementsForClassFactory.getInstance().getStatementsForClass(m_conMan.getConnectionDescriptor(), cds);
                   m_statementTable.put(cds, sfc);
               }
           }
  @@ -187,8 +183,7 @@
       /**
        * binds the Identities Primary key values to the statement
        */
  -    public void bindDelete(PreparedStatement stmt, Identity oid, ClassDescriptor cld)
  -        throws SQLException
  +    public void bindDelete(PreparedStatement stmt, Identity oid, ClassDescriptor cld) throws SQLException
       {
           Object[] values = null;
           int i = 0;
  @@ -204,22 +199,12 @@
           {
               for (i = 0; i < values.length; i++)
               {
  -                m_platform.setObjectForStatement(
  -                    stmt,
  -                    i + 1,
  -                    values[i],
  -                    SqlHelper.getSqlTypePk(cld, i));
  +                m_platform.setObjectForStatement(stmt, i + 1, values[i], SqlHelper.getSqlTypePk(cld, i));
               }
           }
           catch (SQLException e)
           {
  -            m_log.error(
  -                "bindDelete failed for: "
  -                    + oid.toString()
  -                    + ", PK: "
  -                    + i
  -                    + ", value: "
  -                    + values[i]);
  +            m_log.error("bindDelete failed for: " + oid.toString() + ", PK: " + i + ", value: " + values[i]);
               throw e;
           }
       }
  @@ -227,8 +212,7 @@
       /**
        * binds the objects primary key and locking values to the statement, BRJ
        */
  -    public void bindDelete(PreparedStatement stmt, ClassDescriptor cld, Object obj)
  -        throws SQLException
  +    public void bindDelete(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws SQLException
       {
           if (cld.getDeleteProcedure() != null)
           {
  @@ -245,11 +229,7 @@
               values = getKeyValues(m_broker, cld, obj);
               for (int i = 0; i < values.length; i++)
               {
  -                m_platform.setObjectForStatement(
  -                    stmt,
  -                    index,
  -                    values[i],
  -                    SqlHelper.getSqlTypePk(cld, i));
  +                m_platform.setObjectForStatement(stmt, index, values[i], SqlHelper.getSqlTypePk(cld, i));
                   index++;
               }
   
  @@ -257,57 +237,51 @@
               values = currentLockingValues;
               for (int i = 0; i < values.length; i++)
               {
  -                m_platform.setObjectForStatement(
  -                    stmt,
  -                    index,
  -                    values[i],
  -                    SqlHelper.getSqlTypeLocking(cld, i));
  +                m_platform.setObjectForStatement(stmt, index, values[i], SqlHelper.getSqlTypeLocking(cld, i));
                   index++;
               }
           }
       }
   
       /**
  -     * bind a value
  -     * @param stmt the PreparedStatement
  -     * @param index the position of the parameter to bind
  -     * @param value the value to bind
  -     * @param cld the ClassDescriptor
  -     * @param fld the FielsDescriptor
  -     * @return next index for PreparedStatement
  +     * bind attribute and value
  +     * @param stmt
  +     * @param index
  +     * @param attributeOrQuery
  +     * @param value
  +     * @param cld
  +     * @return
  +     * @throws SQLException
        */
  -    private int bindStatementValue(
  -        PreparedStatement stmt,
  -        int index,
  -        Object value,
  -        ClassDescriptor cld,
  -        FieldDescriptor fld)
  +    private int bindStatementValue(PreparedStatement stmt, int index, Object attributeOrQuery, Object value, ClassDescriptor cld)
           throws SQLException
       {
  +        FieldDescriptor fld = null;
  +
           // if value is a subQuery bind it
           if (value instanceof Query)
           {
               Query subQuery = (Query) value;
  +            return bindStatement(stmt, subQuery, cld.getRepository().getDescriptorFor(subQuery.getSearchClass()), index);
  +        }
   
  -            // BRJ: simply bind the whole subQuery
  -            return bindStatement(
  -                stmt,
  -                subQuery,
  -                cld.getRepository().getDescriptorFor(subQuery.getSearchClass()),
  -                index);
  +        // if attribute is a subQuery bind it
  +        if (attributeOrQuery instanceof Query)
  +        {
  +            Query subQuery = (Query) attributeOrQuery;
  +            bindStatement(stmt, subQuery, cld.getRepository().getDescriptorFor(subQuery.getSearchClass()), index);
  +        }
  +        else
  +        {
  +            fld = cld.getFieldDescriptorForPath((String) attributeOrQuery);
           }
   
  -        // if query has criteria, bind them
           if (fld != null)
           {
               // BRJ: use field conversions and platform
               if (value != null)
               {
  -                m_platform.setObjectForStatement(
  -                    stmt,
  -                    index,
  -                    fld.getFieldConversion().javaToSql(value),
  -                    fld.getColumnJdbcType());
  +                m_platform.setObjectForStatement(stmt, index, fld.getFieldConversion().javaToSql(value), fld.getColumnJdbcType());
               }
               else
               {
  @@ -316,7 +290,6 @@
           }
           else
           {
  -            // BRJ: No FieldDescriptor found
               if (value != null)
               {
                   stmt.setObject(index, value);
  @@ -338,15 +311,9 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(
  -        PreparedStatement stmt,
  -        int index,
  -        SelectionCriteria crit,
  -        ClassDescriptor cld)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, SelectionCriteria crit, ClassDescriptor cld) throws SQLException
       {
  -        FieldDescriptor fld = cld.getFieldDescriptorForPath(crit.getAttribute());
  -        return bindStatementValue(stmt, index, crit.getValue(), cld, fld);
  +        return bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue(), cld);
       }
   
       /**
  @@ -356,8 +323,7 @@
        * @param crit the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, NullCriteria crit)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, NullCriteria crit) throws SQLException
       {
           return index;
       }
  @@ -369,8 +335,7 @@
        * @param crit , the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, FieldCriteria crit)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, FieldCriteria crit) throws SQLException
       {
           return index;
       }
  @@ -382,8 +347,7 @@
        * @param crit the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, SqlCriteria crit)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, SqlCriteria crit) throws SQLException
       {
           return index;
       }
  @@ -396,17 +360,11 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(
  -        PreparedStatement stmt,
  -        int index,
  -        BetweenCriteria crit,
  -        ClassDescriptor cld)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, BetweenCriteria crit, ClassDescriptor cld) throws SQLException
       {
  -        FieldDescriptor fld = cld.getFieldDescriptorForPath(crit.getAttribute());
  -        index = bindStatementValue(stmt, index, crit.getValue(), cld, fld);
  +        index = bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue(), cld);
   
  -        return bindStatementValue(stmt, index, crit.getValue2(), cld, fld);
  +        return bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue2(), cld);
       }
   
       /**
  @@ -417,14 +375,8 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(
  -        PreparedStatement stmt,
  -        int index,
  -        InCriteria crit,
  -        ClassDescriptor cld)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, InCriteria crit, ClassDescriptor cld) throws SQLException
       {
  -        FieldDescriptor fld = cld.getFieldDescriptorForPath(crit.getAttribute());
           if (crit.getValue() instanceof Collection)
           {
               Collection values = (Collection) crit.getValue();
  @@ -432,12 +384,12 @@
   
               while (iter.hasNext())
               {
  -                index = bindStatementValue(stmt, index, iter.next(), cld, fld);
  +                index = bindStatementValue(stmt, index, crit.getAttribute(), iter.next(), cld);
               }
           }
           else
           {
  -            index = bindStatementValue(stmt, index, crit.getValue(), cld, fld);
  +            index = bindStatementValue(stmt, index, crit.getAttribute(), crit.getValue(), cld);
           }
           return index;
       }
  @@ -450,23 +402,14 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(
  -        PreparedStatement stmt,
  -        int index,
  -        ExistsCriteria crit,
  -        ClassDescriptor cld)
  -        throws SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, ExistsCriteria crit, ClassDescriptor cld) throws SQLException
       {
           Query subQuery = (Query) crit.getValue();
   
           // if query has criteria, bind them
           if (subQuery.getCriteria() != null && !subQuery.getCriteria().isEmpty())
           {
  -            return bindStatement(
  -                stmt,
  -                subQuery.getCriteria(),
  -                cld.getRepository().getDescriptorFor(subQuery.getSearchClass()),
  -                index);
  +            return bindStatement(stmt, subQuery.getCriteria(), cld.getRepository().getDescriptorFor(subQuery.getSearchClass()), index);
   
               // otherwise, just ignore it
           }
  @@ -479,8 +422,7 @@
       /**
        * bind a Query based Select Statement
        */
  -    public int bindStatement(PreparedStatement stmt, Query query, ClassDescriptor cld, int param)
  -        throws SQLException
  +    public int bindStatement(PreparedStatement stmt, Query query, ClassDescriptor cld, int param) throws SQLException
       {
           int result;
   
  @@ -493,12 +435,7 @@
       /**
        * bind a Query based Select Statement
        */
  -    protected int bindStatement(
  -        PreparedStatement stmt,
  -        Criteria crit,
  -        ClassDescriptor cld,
  -        int param)
  -        throws SQLException
  +    protected int bindStatement(PreparedStatement stmt, Criteria crit, ClassDescriptor cld, int param) throws SQLException
       {
           if (crit != null)
           {
  @@ -538,12 +475,7 @@
        * @param cld the ClassDescriptor
        * @return next index for PreparedStatement
        */
  -    private int bindSelectionCriteria(
  -        PreparedStatement stmt,
  -        int index,
  -        SelectionCriteria crit,
  -        ClassDescriptor cld)
  -        throws SQLException
  +    private int bindSelectionCriteria(PreparedStatement stmt, int index, SelectionCriteria crit, ClassDescriptor cld) throws SQLException
       {
           if (crit instanceof NullCriteria)
               index = bindStatement(stmt, index, (NullCriteria) crit);
  @@ -566,8 +498,7 @@
       /**
        * binds the values of the object obj to the statements parameters
        */
  -    public void bindInsert(PreparedStatement stmt, ClassDescriptor cld, Object obj)
  -        throws java.sql.SQLException
  +    public void bindInsert(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws java.sql.SQLException
       {
           Object[] values;
           cld.updateLockingValues(obj); // BRJ : provide useful defaults for locking fields
  @@ -584,11 +515,7 @@
                   Object val = values[i];
                   if (val != null)
                   {
  -                    m_platform.setObjectForStatement(
  -                        stmt,
  -                        i + 1,
  -                        val,
  -                        SqlHelper.getSqlTypeRwAll(cld, i));
  +                    m_platform.setObjectForStatement(stmt, i + 1, val, SqlHelper.getSqlTypeRwAll(cld, i));
                   }
                   else
                   {
  @@ -601,8 +528,7 @@
       /**
        * binds the Identities Primary key values to the statement
        */
  -    public void bindSelect(PreparedStatement stmt, Identity oid, ClassDescriptor cld)
  -        throws SQLException
  +    public void bindSelect(PreparedStatement stmt, Identity oid, ClassDescriptor cld) throws SQLException
       {
           Object[] values = null;
           int i = 0;
  @@ -619,11 +545,7 @@
                   Object val = values[i];
                   if (val != null)
                   {
  -                    m_platform.setObjectForStatement(
  -                        stmt,
  -                        i + 1,
  -                        val,
  -                        SqlHelper.getSqlTypePk(cld, i));
  +                    m_platform.setObjectForStatement(stmt, i + 1, val, SqlHelper.getSqlTypePk(cld, i));
                   }
                   else
                   {
  @@ -633,13 +555,7 @@
           }
           catch (SQLException e)
           {
  -            m_log.error(
  -                "bindSelect failed for: "
  -                    + oid.toString()
  -                    + ", PK: "
  -                    + i
  -                    + ", value: "
  -                    + values[i]);
  +            m_log.error("bindSelect failed for: " + oid.toString() + ", PK: " + i + ", value: " + values[i]);
               throw e;
           }
       }
  @@ -647,8 +563,7 @@
       /**
        * binds the values of the object obj to the statements parameters
        */
  -    public void bindUpdate(PreparedStatement stmt, ClassDescriptor cld, Object obj)
  -        throws java.sql.SQLException
  +    public void bindUpdate(PreparedStatement stmt, ClassDescriptor cld, Object obj) throws java.sql.SQLException
       {
           if (cld.getUpdateProcedure() != null)
           {
  @@ -669,18 +584,11 @@
                   Object val = values[i];
                   if (val != null)
                   {
  -                    m_platform.setObjectForStatement(
  -                        stmt,
  -                        index,
  -                        val,
  -                        SqlHelper.getSqlTypeRwNonPk(cld, i));
  +                    m_platform.setObjectForStatement(stmt, index, val, SqlHelper.getSqlTypeRwNonPk(cld, i));
                   }
                   else
                   {
  -                    m_platform.setNullForStatement(
  -                        stmt,
  -                        index,
  -                        SqlHelper.getSqlTypeRwNonPk(cld, i));
  +                    m_platform.setNullForStatement(stmt, index, SqlHelper.getSqlTypeRwNonPk(cld, i));
                   }
   
                   index++;
  @@ -731,11 +639,7 @@
           {
               for (int i = 0; i < values.length; i++)
               {
  -                m_platform.setObjectForStatement(
  -                    stmt,
  -                    index,
  -                    values[i],
  -                    SqlHelper.getSqlTypeByValue(values[i]));
  +                m_platform.setObjectForStatement(stmt, index, values[i], SqlHelper.getSqlTypeByValue(values[i]));
                   index++;
               }
           }
  @@ -745,8 +649,7 @@
       /**
        * return a prepared DELETE Statement fitting for the given ClassDescriptor
        */
  -    public PreparedStatement getDeleteStatement(ClassDescriptor cld)
  -        throws PersistenceBrokerSQLException, PersistenceBrokerException
  +    public PreparedStatement getDeleteStatement(ClassDescriptor cld) throws PersistenceBrokerSQLException, PersistenceBrokerException
       {
           try
           {
  @@ -758,9 +661,7 @@
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
  @@ -768,8 +669,7 @@
        * return a generic Statement for the given ClassDescriptor.
        * Never use this method for UPDATE/INSERT/DELETE if you want to use the batch mode.
        */
  -    public Statement getGenericStatement(ClassDescriptor cds, boolean scrollable)
  -        throws PersistenceBrokerException
  +    public Statement getGenericStatement(ClassDescriptor cds, boolean scrollable) throws PersistenceBrokerException
       {
           try
           {
  @@ -777,17 +677,14 @@
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
       /**
        * return a prepared Insert Statement fitting for the given ClassDescriptor
        */
  -    public PreparedStatement getInsertStatement(ClassDescriptor cds)
  -        throws PersistenceBrokerSQLException, PersistenceBrokerException
  +    public PreparedStatement getInsertStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException
       {
           try
           {
  @@ -799,41 +696,29 @@
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
       /**
        * return a generic Statement for the given ClassDescriptor
        */
  -    public PreparedStatement getPreparedStatement(
  -        ClassDescriptor cds,
  -        String sql,
  -        boolean scrollable)
  -        throws PersistenceBrokerException
  +    public PreparedStatement getPreparedStatement(ClassDescriptor cds, String sql, boolean scrollable) throws PersistenceBrokerException
       {
           try
           {
  -            return getStatementsForClass(cds).getPreparedStmt(
  -                m_conMan.getConnection(),
  -                sql,
  -                scrollable);
  +            return getStatementsForClass(cds).getPreparedStmt(m_conMan.getConnection(), sql, scrollable);
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
       /**
        * return a prepared Select Statement for the given ClassDescriptor
        */
  -    public PreparedStatement getSelectByPKStatement(ClassDescriptor cds)
  -        throws PersistenceBrokerSQLException, PersistenceBrokerException
  +    public PreparedStatement getSelectByPKStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException
       {
           try
           {
  @@ -845,17 +730,14 @@
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
       /**
        * return a prepared Update Statement fitting to the given ClassDescriptor
        */
  -    public PreparedStatement getUpdateStatement(ClassDescriptor cds)
  -        throws PersistenceBrokerSQLException, PersistenceBrokerException
  +    public PreparedStatement getUpdateStatement(ClassDescriptor cds) throws PersistenceBrokerSQLException, PersistenceBrokerException
       {
           try
           {
  @@ -867,9 +749,7 @@
           }
           catch (LookupException e)
           {
  -            throw new PersistenceBrokerException(
  -                "Used ConnectionManager instance could not obtain a connection",
  -                e);
  +            throw new PersistenceBrokerException("Used ConnectionManager instance could not obtain a connection", e);
           }
       }
   
  @@ -877,8 +757,7 @@
        * returns an array containing values for all the Objects attribute
        * @throws PersistenceBrokerException if there is an erros accessing obj field values
        */
  -    protected Object[] getAllValues(ClassDescriptor cld, Object obj)
  -        throws PersistenceBrokerException
  +    protected Object[] getAllValues(ClassDescriptor cld, Object obj) throws PersistenceBrokerException
       {
           return m_broker.serviceBrokerHelper().getAllRwValues(cld, obj);
       }
  @@ -887,8 +766,7 @@
        * returns an Array with an Objects PK VALUES
        * @throws PersistenceBrokerException if there is an erros accessing o field values
        */
  -    protected Object[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj)
  -        throws PersistenceBrokerException
  +    protected Object[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj) throws PersistenceBrokerException
       {
           return broker.serviceBrokerHelper().getKeyValues(cld, obj);
       }
  @@ -897,8 +775,7 @@
        * returns an Array with an Identities PK VALUES
        * @throws PersistenceBrokerException if there is an erros accessing o field values
        */
  -    protected Object[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Identity oid)
  -        throws PersistenceBrokerException
  +    protected Object[] getKeyValues(PersistenceBroker broker, ClassDescriptor cld, Identity oid) throws PersistenceBrokerException
       {
           return broker.serviceBrokerHelper().getKeyValues(cld, oid);
       }
  @@ -907,8 +784,7 @@
        * returns an Array with an Objects NON-PK VALUES
        * @throws PersistenceBrokerException if there is an erros accessing o field values
        */
  -    protected Object[] getNonKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj)
  -        throws PersistenceBrokerException
  +    protected Object[] getNonKeyValues(PersistenceBroker broker, ClassDescriptor cld, Object obj) throws PersistenceBrokerException
       {
           return broker.serviceBrokerHelper().getNonKeyRwValues(cld, obj);
       }
  @@ -926,11 +802,7 @@
        *        the arguments that shoudl be passed to the procedure or
        *        user-defined function
        */
  -    private void bindProcedure(
  -        PreparedStatement stmt,
  -        ClassDescriptor cld,
  -        Object obj,
  -        ProcedureDescriptor proc)
  +    private void bindProcedure(PreparedStatement stmt, ClassDescriptor cld, Object obj, ProcedureDescriptor proc)
           throws java.sql.SQLException
       {
           int valueSub = 0;
  
  
  
  1.14      +8 -0      db-ojb/src/test/org/apache/ojb/odmg/ContractVersionEffectivenessOQLTest.java
  
  Index: ContractVersionEffectivenessOQLTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/ContractVersionEffectivenessOQLTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ContractVersionEffectivenessOQLTest.java	2 Aug 2003 08:27:22 -0000	1.13
  +++ ContractVersionEffectivenessOQLTest.java	13 Sep 2003 14:33:58 -0000	1.14
  @@ -17,6 +17,8 @@
   import org.apache.ojb.broker.RelatedToContract;
   import org.apache.ojb.broker.TestHelper;
   import org.apache.ojb.broker.Version;
  +import org.apache.ojb.broker.query.QueryByCriteria;
  +import org.apache.ojb.odmg.oql.OQLQueryImpl;
   import org.odmg.Database;
   import org.odmg.Implementation;
   import org.odmg.OQLQuery;
  @@ -165,6 +167,9 @@
           query.bind(new Timestamp(System.currentTimeMillis() + 5000)); // a while from now (effValue3<$5)
           query.bind(new Integer(5)); // version.contract.relatedToContract.relatedValue2=$6
   
  +        QueryByCriteria cbc = (QueryByCriteria)((OQLQueryImpl)query).getQuery();
  +        cbc.setPathOuterJoin("relatedToContract");
  +        
           ManageableCollection all = (ManageableCollection) query.execute();
           java.util.Iterator it = all.ojbIterator();
           /**
  @@ -236,6 +241,9 @@
           query.bind(new Timestamp(System.currentTimeMillis() - 5000)); // a while ago (effValue3 > $3)
           query.bind(new Integer(20)); // effValue2 <= $4
           query.bind(new Timestamp(System.currentTimeMillis() + 5000)); // a while from now (effValue3<$5)
  +
  +        QueryByCriteria cbc = (QueryByCriteria)((OQLQueryImpl)query).getQuery();
  +        cbc.setPathOuterJoin("relatedToContract");
   
           ManageableCollection all = (ManageableCollection) query.execute();
           java.util.Iterator it = all.ojbIterator();
  
  
  
  1.4       +3 -0      db-ojb/src/jdori/org/apache/ojb/tutorial5/Application.java
  
  Index: Application.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/jdori/org/apache/ojb/tutorial5/Application.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Application.java	8 Apr 2003 20:19:27 -0000	1.3
  +++ Application.java	13 Sep 2003 14:33:58 -0000	1.4
  @@ -115,10 +115,13 @@
        */
       public UseCase selectUseCase()
       {
  +        return  (UseCase)useCases.get(0);
  +        /*
           displayUseCases();
           System.out.println("type in number to select a use case");
           String in = readLine();
           int index = Integer.parseInt(in);
           return (UseCase) useCases.get(index);
  +        */
       }
   }
  
  
  

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