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 MtoNCollectionPrefetcher.java
Date Sat, 06 Mar 2004 13:02:29 GMT
brj         2004/03/06 05:02:29

  Modified:    src/java/org/apache/ojb/broker/query Criteria.java
               src/java/org/apache/ojb/broker/accesslayer
                        MtoNCollectionPrefetcher.java
  Log:
  use column-criteria (no need translation needed) for m-n-prefetching
  
  Revision  Changes    Path
  1.40      +850 -783  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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- Criteria.java	21 Feb 2004 21:41:45 -0000	1.39
  +++ Criteria.java	6 Mar 2004 13:02:29 -0000	1.40
  @@ -79,88 +79,94 @@
    * Copyright (C) 1997, 1998    DB Harvey-George
    * eMail: cobra@lowrent.org
    *
  - * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
  + * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
    * @version $Id$
    */
   public class Criteria implements java.io.Serializable
   {
  -	static final long serialVersionUID = 7384550404778187808L;	public final static int OR = 0;
  -	public final static int AND = 1;
  -	public final static int NONE = 9;
  -    
  -    // prefix to identify attributes referencing enclosing query
  -    public static String PARENT_QUERY_PREFIX = "parentQuery.";
  -    
  -	private Vector m_criteria;
  -	private int m_type;
  -	private boolean m_embraced;
  +    static final long serialVersionUID = 7384550404778187808L;
  +
  +    /** criteria is OR-ed with it's parent */
  +    public static final int OR = 0;
  +    /** criteria is AND-ed with it's parent */
  +    public static final int AND = 1;
  +    /** criteria has no parent */
  +    public static final int NONE = 9;
  +
  +    /** prefix to identify attributes referencing enclosing query */
  +    public static final String PARENT_QUERY_PREFIX = "parentQuery.";
  +
  +    private Vector m_criteria;
  +    private int m_type;
  +    private boolean m_embraced;
       private boolean m_negative = false;
   
  -	// holding CriteriaFields for orderBy and groupBy
  -	private List orderby = null;
  -	private List groupby = null;
  -	private List prefetchedRelationships = null;
  +    // holding CriteriaFields for orderBy and groupBy
  +    private List orderby = null;
  +    private List groupby = null;
  +    private List prefetchedRelationships = null;
   
  -	// an optional alias to be used for this criteria
  -	private String m_alias = null;
  +    // an optional alias to be used for this criteria
  +    private String m_alias = null;
   
  -	protected static final int IN_LIMIT = getSqlInLimit();
  +    /** the max. number of parameters in a IN-statement */
  +    protected static final int IN_LIMIT = getSqlInLimit();
   
       private QueryByCriteria m_query;
       private Criteria m_parentCriteria;
   
  -	/**
  -	 * Constructor declaration
  -	 */
  -	public Criteria()
  -	{
  -		m_criteria = new Vector();
  -		groupby = new ArrayList();
  -		orderby = new ArrayList();
  -		prefetchedRelationships = new ArrayList();
  -		m_type = NONE;
  -		m_embraced = false;
  -	}
  -
  -	/**
  -	 * Constructor with a SelectionCriteria
  -	 * @param aSelectionCriteria
  -	 */
  -	public Criteria(SelectionCriteria aSelectionCriteria)
  -	{
  -		this();
  -		addSelectionCriteria(aSelectionCriteria);
  -	}
  +    /**
  +     * Constructor declaration
  +     */
  +    public Criteria()
  +    {
  +        m_criteria = new Vector();
  +        groupby = new ArrayList();
  +        orderby = new ArrayList();
  +        prefetchedRelationships = new ArrayList();
  +        m_type = NONE;
  +        m_embraced = false;
  +    }
  +
  +    /**
  +     * Constructor with a SelectionCriteria
  +     * @param aSelectionCriteria SelectionCriteria
  +     */
  +    public Criteria(SelectionCriteria aSelectionCriteria)
  +    {
  +        this();
  +        addSelectionCriteria(aSelectionCriteria);
  +    }
   
       /**
        * make a copy of the criteria
  -     * @param includeGroupBy
  -     * @param includeOrderBy
  -     * @param includePrefetchedRelationships
  -     * @return
  +     * @param includeGroupBy if true
  +     * @param includeOrderBy if ture
  +     * @param includePrefetchedRelationships if true
  +     * @return a copy of the criteria
        */
  -	public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)
  -	{
  -		Criteria copy = new Criteria();
  +    public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)
  +    {
  +        Criteria copy = new Criteria();
   
  -		copy.m_criteria = this.m_criteria;
  +        copy.m_criteria = this.m_criteria;
           copy.m_negative = this.m_negative;
  -        
  -		if (includeGroupBy)
  -		{
  -			copy.groupby = this.groupby;
  -		}
  -		if (includeOrderBy)
  -		{
  -			copy.orderby = this.orderby;
  -		}
  -		if (includePrefetchedRelationships)
  -		{
  -			copy.prefetchedRelationships = this.prefetchedRelationships;
  -		}
   
  -		return copy;
  -	}
  +        if (includeGroupBy)
  +        {
  +            copy.groupby = this.groupby;
  +        }
  +        if (includeOrderBy)
  +        {
  +            copy.orderby = this.orderby;
  +        }
  +        if (includePrefetchedRelationships)
  +        {
  +            copy.prefetchedRelationships = this.prefetchedRelationships;
  +        }
  +
  +        return copy;
  +    }
   
       protected void addSelectionCriteria(SelectionCriteria selectionCrit)
       {
  @@ -183,51 +189,50 @@
               crit = criteria.elementAt(i);
               if (crit instanceof SelectionCriteria)
               {
  -                addSelectionCriteria((SelectionCriteria)crit);
  +                addSelectionCriteria((SelectionCriteria) crit);
               }
               else if (crit instanceof Criteria)
               {
  -                addCriteria((Criteria)crit);
  +                addCriteria((Criteria) crit);
               }
           }
       }
   
  -	/**
  -	 * Answer a List of InCriteria based on values, each InCriteria
  -	 * contains only inLimit values
  -	 * @param attribute
  -	 * @param values
  -	 * @param negative
  -	 * @param inLimit the maximum number of values for IN (-1 for no limit)
  -	 * @return
  -	 */
  -	protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
  -	{
  -		List result = new ArrayList();
  -		Collection inCollection = new ArrayList();
  -
  -		if (values == null || values.isEmpty())
  -		{
  -			// OQL creates empty Criteria for late binding
  -			result.add(buildInCriteria(attribute, negative, values));
  -		}
  -		else
  -		{
  -			Iterator iter = values.iterator();
  -
  -			while (iter.hasNext())
  -			{
  -				inCollection.add(iter.next());
  -				if (inCollection.size() == inLimit || !iter.hasNext())
  -				{
  -					result.add(buildInCriteria(attribute, negative, inCollection));
  -					inCollection = new ArrayList();
  -				}
  -			}
  -		}
  -		return result;
  -	}
  +    /**
  +     * Answer a List of InCriteria based on values, each InCriteria
  +     * contains only inLimit values
  +     * @param attribute
  +     * @param values
  +     * @param negative
  +     * @param inLimit the maximum number of values for IN (-1 for no limit)
  +     * @return
  +     */
  +    protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)
  +    {
  +        List result = new ArrayList();
  +        Collection inCollection = new ArrayList();
   
  +        if (values == null || values.isEmpty())
  +        {
  +            // OQL creates empty Criteria for late binding
  +            result.add(buildInCriteria(attribute, negative, values));
  +        }
  +        else
  +        {
  +            Iterator iter = values.iterator();
  +
  +            while (iter.hasNext())
  +            {
  +                inCollection.add(iter.next());
  +                if (inCollection.size() == inLimit || !iter.hasNext())
  +                {
  +                    result.add(buildInCriteria(attribute, negative, inCollection));
  +                    inCollection = new ArrayList();
  +                }
  +            }
  +        }
  +        return result;
  +    }
   
       private InCriteria buildInCriteria(Object attribute, boolean negative, Collection values)
       {
  @@ -237,76 +242,75 @@
           }
           else
           {
  -            return ValueCriteria.buildInCriteria(attribute, values, getAlias());           
  -        }    
  +            return ValueCriteria.buildInCriteria(attribute, values, getAlias());
  +        }
  +    }
  +
  +    /**
  +     * Get an Enumeration with all sub criteria
  +     * @return Enumeration
  +     */
  +    public Enumeration getElements()
  +    {
  +        return getCriteria().elements();
  +    }
  +
  +    /**
  +     * Get a Vector with all sub criteria
  +     * @return Vector
  +     */
  +    protected Vector getCriteria()
  +    {
  +        return m_criteria;
  +    }
  +
  +    /**
  +     * Answer the type
  +     * @return int
  +     */
  +    public int getType()
  +    {
  +        return m_type;
  +    }
  +
  +    /**
  +     * Set the type
  +     * @param type OR, AND, NONE
  +     */
  +    public void setType(int type)
  +    {
  +        m_type = type;
  +    }
  +
  +    /**
  +     * ANDed criteria are embraced
  +     * @return true if embraced,
  +     */
  +    public boolean isEmbraced()
  +    {
  +        return m_embraced;
       }
   
  -	/**
  -	 * Get an Enumeration with all sub criteria
  -	 * @return Enumaration
  -	 */
  -	public Enumeration getElements()
  -	{
  -		return getCriteria().elements();
  -	}
  -
  -	/**
  -	 * Get a Vector with all sub criteria
  -	 * @return Vector
  -	 */
  -	protected Vector getCriteria()
  -	{
  -		return m_criteria;
  -	}
  -
  -	/**
  -	 * Answer the type
  -	 * @return int
  -	 */
  -	public int getType()
  -	{
  -		return m_type;
  -	}
  -
  -	/**
  -	 * Set the type
  -	 * @param type
  -	 */
  -	public void setType(int type)
  -	{
  -		this.m_type = type;
  -	}
  -
  -	/**
  -	 * Answer true if embraced,
  -	 * ANDed criteria are embraced
  -	 */
  -	public boolean isEmbraced()
  -	{
  -		return m_embraced;
  -	}
  -
  -	/**
  -	 * Set embraced
  -	 * @param embraced
  -	 */
  -	public void setEmbraced(boolean embraced)
  -	{
  -		this.m_embraced = embraced;
  -	}
  -
  -	/**
  -	 * Adds and equals (=) criteria,
  -	 * customer_id = 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addEqualTo(String attribute, Object value)
  -	{
  -//		addSelectionCriteria(new EqualToCriteria(attribute, value, false, getAlias()));
  +    /**
  +     * Set embraced
  +     * @param embraced true if criteria is to be surrounded by braces
  +     */
  +    public void setEmbraced(boolean embraced)
  +    {
  +        m_embraced = embraced;
  +    }
  +
  +    /**
  +     * Adds and equals (=) criteria,
  +     * customer_id = 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addEqualTo(String attribute, Object value)
  +    {
           addSelectionCriteria(ValueCriteria.buildEqualToCriteria(attribute, value, getAlias()));
  -	}
  +    }
   
       /**
        * Adds and equals (=) criteria,
  @@ -338,617 +342,677 @@
           addSelectionCriteria(c);
       }
   
  -	/**
  -	 * Adds and equals (=) criteria for field comparison.
  -	 * The field name will be translated into the appropriate columnName by SqlStatement.
  -	 * <br>
  -	 * name = boss.name
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  fieldName   The field name to compare with
  -	 */
  -	public void addEqualToField(String attribute, String fieldName)
  -	{
  +    /**
  +     * Adds and equals (=) criteria for field comparison.
  +     * The field name will be translated into the appropriate columnName by SqlStatement.
  +     * <br>
  +     * name = boss.name
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  fieldName   The field name to compare with
  +     */
  +    public void addEqualToField(String attribute, String fieldName)
  +    {
           FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, fieldName, getAlias());
  -		addSelectionCriteria(c);
  -	}
  +        addSelectionCriteria(c);
  +    }
   
  -	/**
  -	 * Adds and equals (=) criteria for field comparison.
  -	 * The field name will be translated into the appropriate columnName by SqlStatement.
  -	 * <br>
  -	 * name <> boss.name
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  fieldName   The field name to compare with
  -	 */
  -	public void addNotEqualToField(String attribute, String fieldName)
  -	{
  -		SelectionCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, fieldName, getAlias());
  -		addSelectionCriteria(c);
  -	}
  -
  -	/**
  -	 * Adds and equals (<>) criteria for column comparison.
  -	 * The column Name will NOT be translated.
  -	 * <br>
  -	 * name <> T_BOSS.LASTNMAE
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  colName   	The name of the column to compare with
  -	 */
  -	public void addNotEqualToColumn(String attribute, String colName)
  -	{
  +    /**
  +     * Adds and equals (=) criteria for field comparison.
  +     * The field name will be translated into the appropriate columnName by SqlStatement.
  +     * <br>
  +     * name <> boss.name
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  fieldName   The field name to compare with
  +     */
  +    public void addNotEqualToField(String attribute, String fieldName)
  +    {
  +        SelectionCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, fieldName, getAlias());
  +        addSelectionCriteria(c);
  +    }
  +
  +    /**
  +     * Adds and equals (<>) criteria for column comparison.
  +     * The column Name will NOT be translated.
  +     * <br>
  +     * name <> T_BOSS.LASTNMAE
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  colName     The name of the column to compare with
  +     */
  +    public void addNotEqualToColumn(String attribute, String colName)
  +    {
           FieldCriteria c = FieldCriteria.buildNotEqualToCriteria(attribute, colName, getAlias());
           c.setTranslateField(false);
  -		addSelectionCriteria(c);
  -	}
  +        addSelectionCriteria(c);
  +    }
   
  -	/**
  -	 * Adds and equals (=) criteria for column comparison.
  -	 * The column Name will NOT be translated.
  -	 * <br>
  -	 * name = T_BOSS.LASTNMAE
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  colName   	The name of the column to compare with
  -	 */
  -	public void addEqualToColumn(String attribute, String colName)
  -	{
  -		FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getAlias());
  +    /**
  +     * Adds and equals (=) criteria for column comparison.
  +     * The column Name will NOT be translated.
  +     * <br>
  +     * name = T_BOSS.LASTNMAE
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  colName     The name of the column to compare with
  +     */
  +    public void addEqualToColumn(String attribute, String colName)
  +    {
  +        FieldCriteria c = FieldCriteria.buildEqualToCriteria(attribute, colName, getAlias());
           c.setTranslateField(false);
  -		addSelectionCriteria(c);
  -	}
  +        addSelectionCriteria(c);
  +    }
  +
  +    /**
  +     * Adds GreaterOrEqual Than (>=) criteria,
  +     * customer_id >= 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addGreaterOrEqualThan(Object attribute, Object value)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildNotLessCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds GreaterOrEqual Than (>=) criteria,
  +     * customer_id >= person_id
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       The field name to compare with
  +     */
  +    public void addGreaterOrEqualThanField(String attribute, Object value)
  +    {
  +        addSelectionCriteria(FieldCriteria.buildNotLessCriteria(attribute, value, getAlias()));
  +    }
   
  -	/**
  -	 * Adds GreaterOrEqual Than (>=) criteria,
  -	 * customer_id >= 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addGreaterOrEqualThan(Object attribute, Object value)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildNotLessCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds GreaterOrEqual Than (>=) criteria,
  -	 * customer_id >= person_id
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       The field name to compare with
  -	 */
  -	public void addGreaterOrEqualThanField(String attribute, Object value)
  -	{
  -		addSelectionCriteria(FieldCriteria.buildNotLessCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds LessOrEqual Than (<=) criteria,
  -	 * customer_id <= 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addLessOrEqualThan(Object attribute, Object value)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds LessOrEqual Than (<=) criteria,
  -	 * customer_id <= person_id
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       The field name to compare with
  -	 */
  -	public void addLessOrEqualThanField(String attribute, Object value)
  -	{
  -		addSelectionCriteria(FieldCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds Like (LIKE) criteria,
  -	 * customer_name LIKE "m%ller"
  -	 *
  +    /**
  +     * Adds LessOrEqual Than (<=) criteria,
  +     * customer_id <= 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addLessOrEqualThan(Object attribute, Object value)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds LessOrEqual Than (<=) criteria,
  +     * customer_id <= person_id
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       The field name to compare with
  +     */
  +    public void addLessOrEqualThanField(String attribute, Object value)
  +    {
  +        addSelectionCriteria(FieldCriteria.buildNotGreaterCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds Like (LIKE) criteria,
  +     * customer_name LIKE "m%ller"
  +     *
        * @see LikeCriteria
        * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addLike(Object attribute, Object value)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildLikeCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds Like (NOT LIKE) criteria,
  -	 * customer_id NOT LIKE 10034
  -	 *
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addLike(Object attribute, Object value)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildLikeCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds Like (NOT LIKE) criteria,
  +     * customer_id NOT LIKE 10034
  +     *
        * @see LikeCriteria
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addNotLike(String attribute, Object value)
  -	{
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addNotLike(String attribute, Object value)
  +    {
           addSelectionCriteria(ValueCriteria.buildNotLikeCriteria(attribute, value, getAlias()));
  -	}
  +    }
   
  -	/**
  -	 * Adds NotEqualTo (<>) criteria,
  -	 * customer_id <> 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addNotEqualTo(Object attribute, Object value)
  -	{
  +    /**
  +     * Adds NotEqualTo (<>) criteria,
  +     * customer_id <> 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addNotEqualTo(Object attribute, Object value)
  +    {
           addSelectionCriteria(ValueCriteria.buildNotEqualToCriteria(attribute, value, getAlias()));
  -	}
  +    }
   
  -	/**
  -	 * Adds Greater Than (>) criteria,
  -	 * customer_id > 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addGreaterThan(Object attribute, Object value)
  -	{
  +    /**
  +     * Adds Greater Than (>) criteria,
  +     * customer_id > 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addGreaterThan(Object attribute, Object value)
  +    {
           addSelectionCriteria(ValueCriteria.buildGreaterCriteria(attribute, value, getAlias()));
  -	}
  +    }
  +
  +    /**
  +     * Adds Greater Than (>) criteria,
  +     * customer_id > person_id
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       The field to compare with
  +     */
  +    public void addGreaterThanField(String attribute, Object value)
  +    {
  +        addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds Less Than (<) criteria,
  +     * customer_id < 10034
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       An object representing the value of the field
  +     */
  +    public void addLessThan(Object attribute, Object value)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildLessCriteria(attribute, value, getAlias()));
  +    }
  +
  +    /**
  +     * Adds Less Than (<) criteria,
  +     * customer_id < person_id
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value       The field to compare with
  +     */
  +    public void addLessThanField(String attribute, Object value)
  +    {
  +        addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value, getAlias()));
  +    }
   
  -	/**
  -	 * Adds Greater Than (>) criteria,
  -	 * customer_id > person_id
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       The field to compare with
  -	 */
  -	public void addGreaterThanField(String attribute, Object value)
  -	{
  -		addSelectionCriteria(FieldCriteria.buildGreaterCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds Less Than (<) criteria,
  -	 * customer_id < 10034
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       An object representing the value of the field
  -	 */
  -	public void addLessThan(Object attribute, Object value)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildLessCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds Less Than (<) criteria,
  -	 * customer_id < person_id
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value       The field to compare with
  -	 */
  -	public void addLessThanField(String attribute, Object value)
  -	{
  -		addSelectionCriteria(FieldCriteria.buildLessCriteria(attribute, value, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds a field for orderBy, order is ASCENDING
  -	 * @param  fieldName	The field name to be used
  -	 * @deprecated use #addOrderByAscending(String fieldName)
  -	 */
  -	public void addOrderBy(String fieldName)
  -	{
  -		addOrderBy(fieldName, true);
  -	}
  -
  -	/**
  -	 * Adds a field for orderBy
  -	 * @param  fieldName	The field name to be used
  -	 * @param  sortAscending	true for ASCENDING, false for DESCENDING
  -	 */
  -	public void addOrderBy(String fieldName, boolean sortAscending)
  -	{
  -		if (fieldName != null)
  -		{
  -			_getOrderby().add(new FieldHelper(fieldName, sortAscending));
  -		}
  -	}
  -
  -	/**
  -	 * Adds a field for orderBy
  -	 * @param aField
  +    /**
  +     * Adds a field for orderBy, order is ASCENDING
  +     * @param  fieldName The field name to be used
  +     * @deprecated use #addOrderByAscending(String fieldName)
  +     */
  +    public void addOrderBy(String fieldName)
  +    {
  +        addOrderBy(fieldName, true);
  +    }
  +
  +    /**
  +     * Adds a field for orderBy
  +     * @param  fieldName the field name to be used
  +     * @param  sortAscending true for ASCENDING, false for DESCENDING
  +     */
  +    public void addOrderBy(String fieldName, boolean sortAscending)
  +    {
  +        if (fieldName != null)
  +        {
  +            _getOrderby().add(new FieldHelper(fieldName, sortAscending));
  +        }
  +    }
  +
  +    /**
  +     * Adds a field for orderBy
  +     * @param aField the Field
        * @deprecated use QueryByCriteria#addOrderBy
  -	 */
  -	public void addOrderBy(FieldHelper aField)
  -	{
  -		if (aField != null)
  -		{
  -			_getOrderby().add(aField);
  -		}
  -	}
  -
  -	/**
  -	 * Adds a field for orderBy ASCENDING
  -	 * @param  fieldName	The field name to be used
  +     */
  +    public void addOrderBy(FieldHelper aField)
  +    {
  +        if (aField != null)
  +        {
  +            _getOrderby().add(aField);
  +        }
  +    }
  +
  +    /**
  +     * Adds a field for orderBy ASCENDING
  +     * @param  fieldName The field name to be used
        * @deprecated use QueryByCriteria#addOrderByAscending
  -	 */
  -	public void addOrderByAscending(String fieldName)
  -	{
  -		addOrderBy(fieldName, true);
  -	}
  -
  -	/**
  -	 * Adds a field for orderBy DESCENDING
  -	 * @param  fieldName	The field name to be used
  +     */
  +    public void addOrderByAscending(String fieldName)
  +    {
  +        addOrderBy(fieldName, true);
  +    }
  +
  +    /**
  +     * Adds a field for orderBy DESCENDING
  +     * @param  fieldName The field name to be used
        * @deprecated use QueryByCriteria#addOrderByDescending
  -	 */
  -	public void addOrderByDescending(String fieldName)
  -	{
  -		addOrderBy(fieldName, false);
  -	}
  +     */
  +    public void addOrderByDescending(String fieldName)
  +    {
  +        addOrderBy(fieldName, false);
  +    }
  +
  +    /**
  +     * Answer the orderBy of all Criteria and Sub Criteria
  +     * the elements are of class Criteria.FieldHelper
  +     * @return List
  +     */
  +    List getOrderby()
  +    {
  +        List result = _getOrderby();
  +        Iterator iter = getCriteria().iterator();
  +        Object crit;
   
  -	/**
  -	 * Answer the orderBy of all Criteria and Sub Criteria
  +        while (iter.hasNext())
  +        {
  +            crit = iter.next();
  +            if (crit instanceof Criteria)
  +            {
  +                result.addAll(((Criteria) crit).getOrderby());
  +            }
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Answer the Vector with all orderBy,
        * the elements are of class Criteria.FieldHelper
        * @return List
  -	 */
  -	List getOrderby()
  -	{
  -		List result = _getOrderby();
  -		Iterator iter = getCriteria().iterator();
  -		Object crit;
  -
  -		while (iter.hasNext())
  -		{
  -			crit = iter.next();
  -			if (crit instanceof Criteria)
  -			{
  -				result.addAll(((Criteria) crit).getOrderby());
  -			}
  -		}
  -
  -		return result;
  -	}
  -
  -	/**
  -	 * Answer the Vector with all orderBy,
  -	 * the elements are of class Criteria.FieldHelper
  -	 * @return List
  -	 */
  -	protected List _getOrderby()
  -	{
  -		return orderby;
  -	}
  -
  -	/**
  -	 * ORs two sets of criteria together:
  -	 * <pre>
  -	 * active = true AND balance < 0 OR active = true AND overdraft = 0
  -	 * </pre>
  -	 * @param pc criteria
  -	 */
  -	public void addOrCriteria(Criteria pc)
  -	{
  -		if (!m_criteria.isEmpty())
  -		{
  -			pc.setEmbraced(true);
  -			pc.setType(OR);
  -			addCriteria(pc);
  -		}
  -		else
  -		{
  -			setEmbraced(false);
  +     */
  +    protected List _getOrderby()
  +    {
  +        return orderby;
  +    }
  +
  +    /**
  +     * ORs two sets of criteria together:
  +     * <pre>
  +     * active = true AND balance < 0 OR active = true AND overdraft = 0
  +     * </pre>
  +     * @param pc criteria
  +     */
  +    public void addOrCriteria(Criteria pc)
  +    {
  +        if (!m_criteria.isEmpty())
  +        {
  +            pc.setEmbraced(true);
  +            pc.setType(OR);
  +            addCriteria(pc);
  +        }
  +        else
  +        {
  +            setEmbraced(false);
               pc.setType(OR);
               addCriteria(pc);
  -		}
  -	}
  +        }
  +    }
   
  -	/**
  -	 * Adds is Null criteria,
  -	 * customer_id is Null
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 */
  -	public void addIsNull(String attribute)
  -	{
  +    /**
  +     * Adds is Null criteria,
  +     * customer_id is Null
  +     *
  +     * @param  attribute   The field name to be used
  +     */
  +    public void addIsNull(String attribute)
  +    {
           addSelectionCriteria(ValueCriteria.buildNullCriteria(attribute, getAlias()));
  -	}
  +    }
   
  -	/**
  -	 * Adds not Null criteria,
  -	 * customer_id is not Null
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 */
  -	public void addNotNull(String attribute)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildNotNullCriteria(attribute, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds BETWEEN criteria,
  -	 * customer_id between 1 and 10
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value1   The lower boundary
  -	 * @param  value2   The upper boundary
  -	 */
  -	public void addBetween(Object attribute, Object value1, Object value2)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));
  -	}
  -
  -	/**
  -	 * Adds NOT BETWEEN criteria,
  -	 * customer_id not between 1 and 10
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  value1   The lower boundary
  -	 * @param  value2   The upper boundary
  -	 */
  -	public void addNotBetween(Object attribute, Object value1, Object value2)
  -	{
  +    /**
  +     * Adds is Null criteria,
  +     * customer_id is Null
  +     * The attribute will NOT be translated into column name
  +     *
  +     * @param  column   The column name to be used without translation
  +     */
  +    public void addColumnIsNull(String column)
  +    {
  +        SelectionCriteria c = ValueCriteria.buildNullCriteria(column, getAlias());
  +        c.setTranslateAttribute(false);
  +        addSelectionCriteria(c);
  +    }
  +
  +    /**
  +     * Adds not Null criteria,
  +     * customer_id is not Null
  +     *
  +     * @param  attribute   The field name to be used
  +     */
  +    public void addNotNull(String attribute)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildNotNullCriteria(attribute, getAlias()));
  +    }
  +
  +    /**
  +     * Adds not Null criteria,
  +     * customer_id is not Null
  +     * The attribute will NOT be translated into column name
  +     *
  +     * @param  column   The column name to be used without translation
  +     */
  +    public void addColumnNotNull(String column)
  +    {
  +        SelectionCriteria c = ValueCriteria.buildNotNullCriteria(column, getAlias());
  +        c.setTranslateAttribute(false);
  +        addSelectionCriteria(c);
  +    }
  +
  +    /**
  +     * Adds BETWEEN criteria,
  +     * customer_id between 1 and 10
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value1   The lower boundary
  +     * @param  value2   The upper boundary
  +     */
  +    public void addBetween(Object attribute, Object value1, Object value2)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildBeweenCriteria(attribute, value1, value2, getAlias()));
  +    }
  +
  +    /**
  +     * Adds NOT BETWEEN criteria,
  +     * customer_id not between 1 and 10
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  value1   The lower boundary
  +     * @param  value2   The upper boundary
  +     */
  +    public void addNotBetween(Object attribute, Object value1, Object value2)
  +    {
           addSelectionCriteria(ValueCriteria.buildNotBeweenCriteria(attribute, value1, value2, getAlias()));
  -	}
  +    }
  +
  +    /**
  +     * Adds IN criteria,
  +     * customer_id in(1,10,33,44)
  +     * large values are split into multiple InCriteria
  +     * IN (1,10) OR IN(33, 44)
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  values   The value Collection
  +     */
  +    public void addIn(String attribute, Collection values)
  +    {
  +        List list = splitInCriteria(attribute, values, false, IN_LIMIT);
  +        int index = 0;
  +        InCriteria inCrit;
  +        Criteria allInCritaria;
  +
  +        inCrit = (InCriteria) list.get(index);
  +        allInCritaria = new Criteria(inCrit);
  +
  +        for (index = 1; index < list.size(); index++)
  +        {
  +            inCrit = (InCriteria) list.get(index);
  +            allInCritaria.addOrCriteria(new Criteria(inCrit));
  +        }
   
  -	/**
  -	 * Adds IN criteria,
  -	 * customer_id in(1,10,33,44)
  -	 * large values are split into multiple InCriteria
  -	 * IN (1,10) OR IN(33, 44)
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  values   The value Collection
  -	 */
  -	public void addIn(String attribute, Collection values)
  -	{
  -		List list = splitInCriteria(attribute, values, false, IN_LIMIT);
  -		int index = 0;
  -		InCriteria inCrit;
  -		Criteria allInCritaria;
  -
  -		inCrit = (InCriteria) list.get(index);
  -		allInCritaria = new Criteria(inCrit);
  -
  -		for (index = 1; index < list.size(); index++)
  -		{
  -			inCrit = (InCriteria) list.get(index);
  -			allInCritaria.addOrCriteria(new Criteria(inCrit));
  -		}
  -
  -		addAndCriteria(allInCritaria);
  -	}
  -
  -	/**
  -	 * Adds NOT IN criteria,
  -	 * customer_id not in(1,10,33,44)
  -	 * large values are split into multiple InCriteria
  -	 * NOT IN (1,10) AND NOT IN(33, 44)
  -	 *
  -	 * @param  attribute   The field name to be used
  -	 * @param  values   The value Collection
  -	 */
  -	public void addNotIn(String attribute, Collection values)
  -	{
  -		List list = splitInCriteria(attribute, values, true, IN_LIMIT);
  -		int index = 0;
  -		InCriteria inCrit;
  -
  -		for (index = 0; index < list.size(); index++)
  -		{
  -			inCrit = (InCriteria) list.get(index);
  -			addSelectionCriteria(inCrit);
  -		}
  -	}
  -
  -	/**
  -	 * IN Criteria with SubQuery
  -	 * @param attribute
  -	 * @param subQuery
  -	 */
  -	public void addIn(Object attribute, Query subQuery)
  -	{
  -		addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getAlias()));
  -	}
  -
  -	/**
  -	 * NOT IN Criteria with SubQuery
  -	 * @param attribute
  -	 * @param subQuery
  -	 */
  -	public void addNotIn(String attribute, Query subQuery)
  -	{
  +        addAndCriteria(allInCritaria);
  +    }
  +
  +    /**
  +     * Adds IN criteria,
  +     * customer_id in(1,10,33,44)
  +     * large values are split into multiple InCriteria
  +     * IN (1,10) OR IN(33, 44) </br>
  +     * The attribute will NOT be translated into column name
  +     *
  +     * @param  column   The column name to be used without translation
  +     * @param  values   The value Collection
  +     */
  +    public void addColumnIn(String column, Collection values)
  +    {
  +        List list = splitInCriteria(column, values, false, IN_LIMIT);
  +        int index = 0;
  +        InCriteria inCrit;
  +        Criteria allInCritaria;
  +
  +        inCrit = (InCriteria) list.get(index);
  +        inCrit.setTranslateAttribute(false);
  +        allInCritaria = new Criteria(inCrit);
  +
  +        for (index = 1; index < list.size(); index++)
  +        {
  +            inCrit = (InCriteria) list.get(index);
  +            inCrit.setTranslateAttribute(false);
  +            allInCritaria.addOrCriteria(new Criteria(inCrit));
  +        }
  +
  +        addAndCriteria(allInCritaria);
  +    }
  +    
  +    /**
  +     * Adds NOT IN criteria,
  +     * customer_id not in(1,10,33,44)
  +     * large values are split into multiple InCriteria
  +     * NOT IN (1,10) AND NOT IN(33, 44)
  +     *
  +     * @param  attribute   The field name to be used
  +     * @param  values   The value Collection
  +     */
  +    public void addNotIn(String attribute, Collection values)
  +    {
  +        List list = splitInCriteria(attribute, values, true, IN_LIMIT);
  +        int index = 0;
  +        InCriteria inCrit;
  +
  +        for (index = 0; index < list.size(); index++)
  +        {
  +            inCrit = (InCriteria) list.get(index);
  +            addSelectionCriteria(inCrit);
  +        }
  +    }
  +
  +    /**
  +     * IN Criteria with SubQuery
  +     * @param attribute The field name to be used
  +     * @param subQuery  The subQuery
  +     */
  +    public void addIn(Object attribute, Query subQuery)
  +    {
  +        addSelectionCriteria(ValueCriteria.buildInCriteria(attribute, subQuery, getAlias()));
  +    }
  +
  +    /**
  +     * NOT IN Criteria with SubQuery
  +     * @param attribute The field name to be used
  +     * @param subQuery  The subQuery
  +     */
  +    public void addNotIn(String attribute, Query subQuery)
  +    {
           addSelectionCriteria(ValueCriteria.buildNotInCriteria(attribute, subQuery, getAlias()));
  -	}
  +    }
  +
  +    /**
  +     * Adds freeform SQL criteria,
  +     * REVERSE(name) like 're%'
  +     *
  +     * @param  anSqlStatment   The free form SQL-Statement
  +     */
  +    public void addSql(String anSqlStatment)
  +    {
  +        addSelectionCriteria(new SqlCriteria(anSqlStatment));
  +    }
   
  -	/**
  -	 * Adds freeform SQL criteria,
  -	 * REVERSE(name) like 're%'
  -	 *
  -	 * @param  anSqlStatment   The free form SQL-Statement
  -	 */
  -	public void addSql(String anSqlStatment)
  -	{
  -		addSelectionCriteria(new SqlCriteria(anSqlStatment));
  -	}
  -
  -	/**
  -	 * ANDs two sets of criteria together:
  -	 *
  -	 * @param  pc criteria
  -	 */
  -	public void addAndCriteria(Criteria pc)
  -	{
  +    /**
  +     * ANDs two sets of criteria together:
  +     *
  +     * @param  pc criteria
  +     */
  +    public void addAndCriteria(Criteria pc)
  +    {
           // by combining a second criteria by 'AND' the existing criteria needs to be enclosed
  -		// in parenthesis
  -		if (!m_criteria.isEmpty())
  -		{
  -			this.setEmbraced(true);
  -			pc.setEmbraced(true);
  -			pc.setType(AND);
  -			addCriteria(pc);
  -		}
  -		else
  -		{
  -			setEmbraced(false);
  +        // in parenthesis
  +        if (!m_criteria.isEmpty())
  +        {
  +            this.setEmbraced(true);
  +            pc.setEmbraced(true);
  +            pc.setType(AND);
  +            addCriteria(pc);
  +        }
  +        else
  +        {
  +            setEmbraced(false);
               pc.setType(AND);
               addCriteria(pc);
  -		}
  -   	}
  +        }
  +    }
  +
  +    /**
  +     * Adds an exists(sub query)
  +     *
  +     * @param subQuery sub-query
  +     */
  +    public void addExists(Query subQuery)
  +    {
  +        addSelectionCriteria(new ExistsCriteria(subQuery, false));
  +    }
  +
  +    /**
  +     * Adds a not exists(sub query)
  +     *
  +     * @param subQuery sub-query
  +     */
  +    public void addNotExists(Query subQuery)
  +    {
  +        addSelectionCriteria(new ExistsCriteria(subQuery, true));
  +    }
  +
  +    /**
  +     * Answer true if no sub criteria available
  +     * @return boolean
  +     */
  +    public boolean isEmpty()
  +    {
  +        return m_criteria.isEmpty();
  +    }
  +
  +    /**
  +     * Gets the groupby for ReportQueries of all Criteria and Sub Criteria
  +     * the elements are of class FieldHelper
  +     * @return List of FieldHelper
  +     */
  +    List getGroupby()
  +    {
  +        List result = _getGroupby();
  +        Iterator iter = getCriteria().iterator();
  +        Object crit;
  +
  +        while (iter.hasNext())
  +        {
  +            crit = iter.next();
  +            if (crit instanceof Criteria)
  +            {
  +                result.addAll(((Criteria) crit).getGroupby());
  +            }
  +        }
   
  -	/**
  -	 * Adds an exists(sub query)
  -	 *
  -	 * @param subQuery sub-query
  -	 */
  -	public void addExists(Query subQuery)
  -	{
  -		addSelectionCriteria(new ExistsCriteria(subQuery, false));
  -	}
  -
  -	/**
  -	 * Adds a not exists(sub query)
  -	 *
  -	 * @param subQuery sub-query
  -	 */
  -	public void addNotExists(Query subQuery)
  -	{
  -		addSelectionCriteria(new ExistsCriteria(subQuery, true));
  -	}
  -
  -	/**
  -	 * Answer true if no sub criteria available
  -	 * @return boolean
  -	 */
  -	public boolean isEmpty()
  -	{
  -		return m_criteria.isEmpty();
  -	}
  -
  -	/**
  -	 * Gets the groupby for ReportQueries of all Criteria and Sub Criteria
  -	 * the elements are of class FieldHelper
  -	 * @return List of FieldHelper
  -	 */
  -	List getGroupby()
  -	{
  -		List result = _getGroupby();
  -		Iterator iter = getCriteria().iterator();
  -		Object crit;
  -
  -		while (iter.hasNext())
  -		{
  -			crit = iter.next();
  -			if (crit instanceof Criteria)
  -			{
  -				result.addAll(((Criteria) crit).getGroupby());
  -			}
  -		}
  -
  -		return result;
  -	}
  -
  -	/**
  -	 * Gets the groupby for ReportQueries,
  -	 * the elements are of class Criteria.FieldHelper
  -	 * @return List of Criteria.FieldHelper
  -	 */
  -	protected List _getGroupby()
  -	{
  -		return groupby;
  -	}
  -
  -	/**
  -	 * Adds a groupby fieldName for ReportQueries.
  -	 * @param fieldName The groupby to set
  +        return result;
  +    }
  +
  +    /**
  +     * Gets the groupby for ReportQueries,
  +     * the elements are of class Criteria.FieldHelper
  +     * @return List of Criteria.FieldHelper
  +     */
  +    protected List _getGroupby()
  +    {
  +        return groupby;
  +    }
  +
  +    /**
  +     * Adds a groupby fieldName for ReportQueries.
  +     * @param fieldName The groupby to set
        * @deprecated use QueryByCriteria#addGroupBy
  -	 */
  -	public void addGroupBy(String fieldName)
  -	{
  -		if (fieldName != null)
  -		{
  -			_getGroupby().add(new FieldHelper(fieldName, false));
  -		}
  -	}
  -
  -	/**
  -	 * Adds a field for groupby
  -	 * @param aField
  +     */
  +    public void addGroupBy(String fieldName)
  +    {
  +        if (fieldName != null)
  +        {
  +            _getGroupby().add(new FieldHelper(fieldName, false));
  +        }
  +    }
  +
  +    /**
  +     * Adds a field for groupby
  +     * @param aField the Field
        * @deprecated use QueryByCriteria#addGroupBy
  -	 */
  -	public void addGroupBy(FieldHelper aField)
  -	{
  -		if (aField != null)
  -		{
  -			_getGroupby().add(aField);
  -		}
  -	}
  -
  -	/**
  -	 * Adds an array of groupby fieldNames for ReportQueries.
  -	 * @param fieldNames The groupby to set
  +     */
  +    public void addGroupBy(FieldHelper aField)
  +    {
  +        if (aField != null)
  +        {
  +            _getGroupby().add(aField);
  +        }
  +    }
  +
  +    /**
  +     * Adds an array of groupby fieldNames for ReportQueries.
  +     * @param fieldNames The groupby to set
        * @deprecated use QueryByCriteria#addGroupBy
  -	 */
  -	public void addGroupBy(String[] fieldNames)
  -	{
  -		for (int i = 0; i < fieldNames.length; i++)
  -		{
  -			addGroupBy(fieldNames[i]);
  -		}
  -	}
  -
  -	/**
  -	 * Returns the prefetchedRelationships.
  -	 * @return List
  -	 */
  -	List getPrefetchedRelationships()
  -	{
  -		return prefetchedRelationships;
  -	}
  +     */
  +    public void addGroupBy(String[] fieldNames)
  +    {
  +        for (int i = 0; i < fieldNames.length; i++)
  +        {
  +            addGroupBy(fieldNames[i]);
  +        }
  +    }
   
  -	/**
  -	 * add the name of aRelationship for prefetch read
  +    /**
  +     * Returns the prefetchedRelationships.
  +     * @return List
  +     */
  +    List getPrefetchedRelationships()
  +    {
  +        return prefetchedRelationships;
  +    }
  +
  +    /**
  +     * add the name of a Relationship for prefetch read
  +     * @param aName the name of the relationship
        * @deprecated use QueryByCriteria#addPrefetchedRelationship
  -	 */
  -	public void addPrefetchedRelationship(String aName)
  -	{
  -		getPrefetchedRelationships().add(aName);
  -	}
  -
  -	/**
  -	 * read the prefetchInLimit from Config based on OJB.properties
  -	 */
  -	private static int getSqlInLimit()
  -	{
  -		try
  -		{
  -			PersistenceBrokerConfiguration config =
  -				(PersistenceBrokerConfiguration) PersistenceBrokerFactory.getConfigurator().getConfigurationFor(null);
  -			return config.getSqlInLimit();
  -		}
  -		catch (ConfigurationException e)
  -		{
  -			return 200;
  -		}
  -	}
  -
  -	/**
  -	 * @return String
  -	 */
  -	public String getAlias()
  -	{
  -		return m_alias;
  -	}
  -
  -	/**
  -	 * Sets the alias. Empty String is regarded as null.
  -	 * @param alias The alias to set
  -	 */
  -	public void setAlias(String alias)
  -	{
  +     */
  +    public void addPrefetchedRelationship(String aName)
  +    {
  +        getPrefetchedRelationships().add(aName);
  +    }
  +
  +    /**
  +     * read the prefetchInLimit from Config based on OJB.properties
  +     */
  +    private static int getSqlInLimit()
  +    {
  +        try
  +        {
  +            PersistenceBrokerConfiguration config = (PersistenceBrokerConfiguration) PersistenceBrokerFactory
  +                    .getConfigurator().getConfigurationFor(null);
  +            return config.getSqlInLimit();
  +        }
  +        catch (ConfigurationException e)
  +        {
  +            return 200;
  +        }
  +    }
  +
  +    /**
  +     * @return String
  +     */
  +    public String getAlias()
  +    {
  +        return m_alias;
  +    }
  +
  +    /**
  +     * Sets the alias. Empty String is regarded as null.
  +     * @param alias The alias to set
  +     */
  +    public void setAlias(String alias)
  +    {
           if (alias == null || alias.trim().equals(""))
           {
               m_alias = null;
  @@ -958,21 +1022,21 @@
               m_alias = alias;
           }
   
  -		// propagate to SelectionCriteria,not to Criteria
  -		for (int i = 0; i < m_criteria.size(); i++)
  -		{
  -			if (!(m_criteria.elementAt(i) instanceof Criteria))
  -			{
  -				((SelectionCriteria) m_criteria.elementAt(i)).setAlias(m_alias);
  -			}
  -		}
  -	}
  -
  -	/**
  -	 * @return
  -	 */
  -	public QueryByCriteria getQuery()
  -	{
  +        // propagate to SelectionCriteria,not to Criteria
  +        for (int i = 0; i < m_criteria.size(); i++)
  +        {
  +            if (!(m_criteria.elementAt(i) instanceof Criteria))
  +            {
  +                ((SelectionCriteria) m_criteria.elementAt(i)).setAlias(m_alias);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * @return the query containing the criteria
  +     */
  +    public QueryByCriteria getQuery()
  +    {
           if (getParentCriteria() != null)
           {
               return getParentCriteria().getQuery();
  @@ -982,34 +1046,37 @@
               return m_query;
           }
   
  -	}
  +    }
  +
  +    /**
  +     * @param query
  +     */
  +    void setQuery(QueryByCriteria query)
  +    {
  +        m_query = query;
  +    }
  +
  +    /**
  +     * @return the parent criteria
  +     */
  +    public Criteria getParentCriteria()
  +    {
  +        return m_parentCriteria;
  +    }
  +
  +    /**
  +     * @param criteria
  +     */
  +    void setParentCriteria(Criteria criteria)
  +    {
  +        m_parentCriteria = criteria;
  +    }
   
  -	/**
  -	 * @param query
  -	 */
  -	void setQuery(QueryByCriteria query)
  -	{
  -		m_query = query;
  -	}
  -
  -	/**
  -	 * @return
  -	 */
  -	public Criteria getParentCriteria()
  -	{
  -		return m_parentCriteria;
  -	}
  -
  -	/**
  -	 * @param criteria
  -	 */
  -	void setParentCriteria(Criteria criteria)
  -	{
  -		m_parentCriteria = criteria;
  -	}
  -	
  -	public String toString()
  -	{
  +    /**
  +     * @see Object#toString()
  +     */
  +    public String toString()
  +    {
           if (isNegative())
           {
               return "-" + m_criteria.toString();
  @@ -1018,7 +1085,7 @@
           {
               return m_criteria.toString();
           }
  -	}
  +    }
   
       /**
        * @return Returns the negative.
  @@ -1029,7 +1096,7 @@
       }
   
       /**
  -     * Flags the whole Criteria as negative. 
  +     * Flags the whole Criteria as negative.
        * @param negative The negative to set.
        */
       public void setNegative(boolean negative)
  
  
  
  1.6       +85 -85    db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java
  
  Index: MtoNCollectionPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/MtoNCollectionPrefetcher.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MtoNCollectionPrefetcher.java	6 Feb 2004 20:49:21 -0000	1.5
  +++ MtoNCollectionPrefetcher.java	6 Mar 2004 13:02:29 -0000	1.6
  @@ -1,4 +1,3 @@
  -
   package org.apache.ojb.broker.accesslayer;
   
   /* ====================================================================
  @@ -87,8 +86,8 @@
   {
   
       /**
  -     * @param aBroker
  -     * @param anOrd
  +     * @param aBroker the PersistenceBroker
  +     * @param anOrd the CollectionDescriptor
        */
       public MtoNCollectionPrefetcher(PersistenceBroker aBroker, ObjectReferenceDescriptor anOrd)
       {
  @@ -100,8 +99,8 @@
        */
       public void prefetchRelationship(Collection owners)
       {
  -        Query queries[];
  -        Query mnQueries[];
  +        Query[] queries;
  +        Query[] mnQueries;
           Collection children = new ArrayList();
           Collection mnImplementors = new ArrayList();
   
  @@ -114,59 +113,58 @@
               while (iter.hasNext())
               {
                   Object aChild = iter.next();
  -                
  +
                   // BRJ: simulate the distinct removed from the query
                   if (!children.contains(aChild))
                   {
                       children.add(aChild);
  -                }    
  +                }
               }
  -            
  +
               Iterator mnIter = getBroker().getReportQueryIteratorByQuery(mnQueries[i]);
               while (mnIter.hasNext())
               {
                   mnImplementors.add(mnIter.next());
               }
           }
  -        
  +
           associateBatched(owners, children, mnImplementors);
       }
  -    
  +
       /**
        * Build the prefetch query for a M-N relationship, The query looks like the following sample :
        * <br>
        * <pre>
  -     *       crit = new Criteria(); 
  -     *       crit.addIn("PERSON_PROJECT.PROJECT_ID", ids); 
  -     *       crit.addEqualToField("id","PERSON_PROJECT.PERSON_ID"); 
  +     *       crit = new Criteria();
  +     *       crit.addIn("PERSON_PROJECT.PROJECT_ID", ids);
  +     *       crit.addEqualToField("id","PERSON_PROJECT.PERSON_ID");
        *       qry = new QueryByMtoNCriteria(Person.class, "PERSON_PROJECT", crit, true);
        * </pre>
  -     * 
  +     *
        * @param ids Collection containing all identities of objects of the M side
  -     * @return
  +     * @return the prefetch Query
        */
       protected Query buildPrefetchQuery(Collection ids)
       {
  -        CollectionDescriptor cds = getCollectionDescriptor(); 
  +        CollectionDescriptor cds = getCollectionDescriptor();
           String[] indFkCols = getFksToThisClass();
           String[] indItemFkCols = getFksToItemClass();
           FieldDescriptor[] itemPkFields = getItemClassDescriptor().getPkFields();
  -    
  +
           Criteria crit = buildPrefetchCriteria(ids, indFkCols, indItemFkCols, itemPkFields);
  -        
  +
           // BRJ: do not use distinct:
  -        // 
  +        //
           // ORA-22901 cannot compare nested table or VARRAY or LOB attributes of an object type
  -        // Cause: Comparison of nested table or VARRAY or LOB attributes of an 
  +        // Cause: Comparison of nested table or VARRAY or LOB attributes of an
           // object type was attempted in the absence of a MAP or ORDER method.
           // Action: Define a MAP or ORDER method for the object type.
           //
           // Without the distinct the resultset may contain duplicate rows
  -        
  +
           return new QueryByMtoNCriteria(cds.getItemClass(), cds.getIndirectionTable(), crit, false);
       }
   
  -    
       /**
        * Build a query to read the mn-implementors
        * @param ids
  @@ -197,8 +195,8 @@
               jdbcTypes[pkFields.length + i] = itemPkFields[i].getJdbcType().getType();
           }
   
  -        ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor()
  -                .getClassOfObject(), cols, crit, false);
  +        ReportQueryByMtoNCriteria q = new ReportQueryByMtoNCriteria(getItemClassDescriptor().getClassOfObject(), cols,
  +                crit, false);
           q.setIndirectionTable(getCollectionDescriptor().getIndirectionTable());
           q.setJdbcTypes(jdbcTypes);
   
  @@ -214,33 +212,33 @@
           String indTable = getCollectionDescriptor().getIndirectionTable();
           String[] fks = getCollectionDescriptor().getFksToThisClass();
           String[] result = new String[fks.length];
  -        
  +
           for (int i = 0; i < result.length; i++)
           {
               result[i] = indTable + "." + fks[i];
           }
  -        
  +
           return result;
       }
  -    
  +
       /**
        * prefix the item class fk columns with the indirection table
        * @return
        */
       private String[] getFksToItemClass()
  -    { 
  +    {
           String indTable = getCollectionDescriptor().getIndirectionTable();
           String[] fks = getCollectionDescriptor().getFksToItemClass();
           String[] result = new String[fks.length];
  -          
  +
           for (int i = 0; i < result.length; i++)
           {
               result[i] = indTable + "." + fks[i];
           }
  -        
  +
           return result;
  -    } 
  -    
  +    }
  +
       /**
        * Build the multiple queries for one relationship because of limitation of IN(...)
        * 
  @@ -277,37 +275,39 @@
           }
   
           return (Query[]) queries.toArray(new Query[queries.size()]);
  -    }    
  +    }
  +
       /**
        * Build the prefetch criteria
  -     * 
  +     *
        * @param ids Collection of identities of M side
        * @param fkCols indirection table fks to this class
        * @param itemFkCols indirection table fks to item class
        * @param itemPkFields
        * @return
        */
  -    private Criteria buildPrefetchCriteria(Collection ids, String[] fkCols, String[] itemFkCols, FieldDescriptor itemPkFields[])
  +    private Criteria buildPrefetchCriteria(Collection ids, String[] fkCols, String[] itemFkCols,
  +            FieldDescriptor[] itemPkFields)
       {
           if (fkCols.length == 1)
           {
  -            return buildPrefetchCriteriaSingleKey(ids, fkCols[0], itemFkCols[0], itemPkFields[0]);                
  +            return buildPrefetchCriteriaSingleKey(ids, fkCols[0], itemFkCols[0], itemPkFields[0]);
           }
           else
           {
               return buildPrefetchCriteriaMultipleKeys(ids, fkCols, itemFkCols, itemPkFields);
           }
  -    
  +
       }
   
       /**
        * Build the prefetch criteria
  -     * 
  +     *
        * @param ids Collection of identities of M side
        * @param fkCol indirection table fks to this class
        * @param itemFk indirection table fks to item class
        * @param itemPkField
  -     * @return
  +     * @return the Criteria 
        */
       private Criteria buildPrefetchCriteriaSingleKey(Collection ids, String fkCol, String itemFkCol,
               FieldDescriptor itemPkField)
  @@ -328,123 +328,124 @@
               case 0 :
                   break;
               case 1 :
  -                crit.addEqualTo(fkCol, values.get(0));
  +                crit.addColumnEqualTo(fkCol, values.get(0));
                   break;
               default :
                   // create IN (...) for the single key field
  -                crit.addIn(fkCol, values);
  +                crit.addColumnIn(fkCol, values);
                   break;
           }
   
  -        crit.addEqualToField(itemPkField.getAttributeName(), itemFkCol);
  +        crit.addEqualToColumn(itemPkField.getAttributeName(), itemFkCol);
   
           return crit;
       }
   
       /**
        * Build the prefetch criteria
  -     * 
  +     *
        * @param ids Collection of identities of M side
        * @param fkCols indirection table fks to this class
        * @param itemFkCols indirection table fks to item class
        * @param itemPkFields
  -     * @return
  +     * @return the Criteria
        */
  -    private Criteria buildPrefetchCriteriaMultipleKeys(Collection ids, String fkCols[], String itemFkCols[], FieldDescriptor itemPkFields[])
  +    private Criteria buildPrefetchCriteriaMultipleKeys(Collection ids, String[] fkCols, String[] itemFkCols,
  +            FieldDescriptor[] itemPkFields)
       {
           Criteria crit = new Criteria();
           Iterator iter = ids.iterator();
  -    
  +
           while (iter.hasNext())
           {
               Criteria c = new Criteria();
               Identity id = (Identity) iter.next();
               Object[] val = id.getPrimaryKeyValues();
  -    
  +
               for (int i = 0; i < val.length; i++)
               {
  -   
  +
                   if (val[i] == null)
                   {
  -                    c.addIsNull(fkCols[i]);
  +                    c.addColumnIsNull(fkCols[i]);
                   }
                   else
                   {
  -                    c.addEqualTo(fkCols[i], val[i]);
  +                    c.addColumnEqualTo(fkCols[i], val[i]);
                   }
  -    
  -                crit.addEqualToField(itemPkFields[i].getAttributeName(), itemFkCols[i]);
  +
  +                crit.addEqualToColumn(itemPkFields[i].getAttributeName(), itemFkCols[i]);
               }
               crit.addOrCriteria(c);
           }
  -    
  +
           return crit;
       }
  -    
  +
       /**
        * associate the batched Children with their owner object loop over children
  -     */   
  +     */
       protected void associateBatched(Collection owners, Collection children, Collection mToNImplementors)
       {
           CollectionDescriptor cds = getCollectionDescriptor();
           PersistentField field = cds.getPersistentField();
           PersistenceBroker pb = getBroker();
  -        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());        
  -        Class childTopLevelClass = pb.getTopLevelClass(getItemClassDescriptor().getClassOfObject());        
  +        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
  +        Class childTopLevelClass = pb.getTopLevelClass(getItemClassDescriptor().getClassOfObject());
           Class collectionClass = cds.getCollectionClass(); // this collection type will be used:
           HashMap childMap = new HashMap();
           HashMap ownerIdsToLists = new HashMap();
  -        
  +
           // initialize the owner list map
           for (Iterator it = owners.iterator(); it.hasNext();)
           {
               Object owner = it.next();
  -            ownerIdsToLists.put(new Identity(owner,pb), new ArrayList());
  +            ownerIdsToLists.put(new Identity(owner, pb), new ArrayList());
           }
  -        
  +
           // build the children map
           for (Iterator it = children.iterator(); it.hasNext();)
           {
               Object child = it.next();
  -            childMap.put(new Identity(child,pb), child);
  +            childMap.put(new Identity(child, pb), child);
           }
  -      
  +
           int ownerPkLen = getOwnerClassDescriptor().getPkFields().length;
           int childPkLen = getItemClassDescriptor().getPkFields().length;
           Object[] ownerPk = new Object[ownerPkLen];
           Object[] childPk = new Object[childPkLen];
   
  -        // build list of children based on m:n implementors 
  +        // build list of children based on m:n implementors
           for (Iterator it = mToNImplementors.iterator(); it.hasNext();)
           {
  -            Object[] mToN = (Object[])it.next();
  -            System.arraycopy(mToN,0,ownerPk,0,ownerPkLen);
  -            System.arraycopy(mToN,ownerPkLen,childPk,0,childPkLen);
  -            
  +            Object[] mToN = (Object[]) it.next();
  +            System.arraycopy(mToN, 0, ownerPk, 0, ownerPkLen);
  +            System.arraycopy(mToN, ownerPkLen, childPk, 0, childPkLen);
  +
               Identity ownerId = new Identity(null, ownerTopLevelClass, ownerPk);
               Identity childId = new Identity(null, childTopLevelClass, childPk);
  -            
  -            Collection list = (Collection) ownerIdsToLists.get(ownerId);     
  +
  +            Collection list = (Collection) ownerIdsToLists.get(ownerId);
               Object child = childMap.get(childId);
               list.add(child);
  -        }    
  -          
  -        // connect children list to owners  
  +        }
  +
  +        // connect children list to owners
           for (Iterator it = owners.iterator(); it.hasNext();)
           {
               Object result;
               Object owner = it.next();
  -            Identity ownerId = new Identity(owner,pb);
  -            
  -            List list = (List)ownerIdsToLists.get(ownerId);
  -            
  +            Identity ownerId = new Identity(owner, pb);
  +
  +            List list = (List) ownerIdsToLists.get(ownerId);
  +
               if ((collectionClass == null) && field.getType().isArray())
               {
                   int length = list.size();
                   Class itemtype = field.getType().getComponentType();
  -                
  +
                   result = Array.newInstance(itemtype, length);
  -                
  +
                   for (int j = 0; j < length; j++)
                   {
                       Array.set(result, j, list.get(j));
  @@ -453,14 +454,14 @@
               else
               {
                   ManageableCollection col = createCollection(collectionClass);
  -                
  +
                   for (Iterator it2 = list.iterator(); it2.hasNext();)
                   {
                       col.ojbAdd(it2.next());
                   }
                   result = col;
  -            }   
  -            
  +            }
  +
               Object value = field.get(owner);
               if ((value instanceof CollectionProxy) && (result instanceof Collection))
               {
  @@ -471,8 +472,7 @@
                   field.set(owner, result);
               }
           }
  -            
  -            
  +
       }
  -    
  +
   }
  
  
  

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