db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/query Criteria.java
Date Mon, 16 Dec 2002 18:19:38 GMT
brj         2002/12/16 10:19:38

  Modified:    src/java/org/apache/ojb/broker/singlevm
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/query Criteria.java
  Log:
  multiple orderby for CollectionDescriptor
  
  Revision  Changes    Path
  1.90      +10 -5     jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- PersistenceBrokerImpl.java	9 Dec 2002 20:05:19 -0000	1.89
  +++ PersistenceBrokerImpl.java	16 Dec 2002 18:19:38 -0000	1.90
  @@ -84,6 +84,7 @@
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  +import org.apache.ojb.broker.metadata.FieldHelper;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.broker.metadata.auto.AutoCreatorDb;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
  @@ -100,7 +101,6 @@
   import org.apache.ojb.broker.server.PersistenceBrokerClient;
   import org.apache.ojb.broker.server.ServerEntry;
   import org.apache.ojb.broker.server.ServerPool;
  -import org.apache.ojb.broker.singlevm.PersistenceBrokerThreadMapping;
   import org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory;
   import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
   import org.apache.ojb.broker.util.ArrayIterator;
  @@ -1065,10 +1065,15 @@
               }
   
               // check if collection must be ordered
  -            if (cds.getOrderBy() != null)
  +            if (!cds.getOrderBy().isEmpty())
               {
  -                fkQuery.getCriteria().addOrderBy(cds.getOrderBy(), cds.isAscending());
  -            }
  +                Iterator iter = cds.getOrderBy().iterator();
  +                while (iter.hasNext())
  +                {
  +                    fkQuery.getCriteria().addOrderBy((FieldHelper)iter.next());
  +                }
  +            }    
  +            
               if (collectionClass == null)
               {
                   Collection result = getCollectionByQuery(fkQuery, cds.isLazy());
  
  
  
  1.18      +34 -23    jakarta-ojb/src/java/org/apache/ojb/broker/query/Criteria.java
  
  Index: Criteria.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/query/Criteria.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Criteria.java	16 Nov 2002 19:13:03 -0000	1.17
  +++ Criteria.java	16 Dec 2002 18:19:38 -0000	1.18
  @@ -62,6 +62,7 @@
   import java.util.Vector;
   
   import org.apache.ojb.broker.PersistenceBrokerFactory;
  +import org.apache.ojb.broker.metadata.FieldHelper;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  @@ -82,21 +83,6 @@
    */
   public class Criteria implements java.io.Serializable
   {
  -	//
  -	// HelperClass for Fields
  -	//
  -	public class Field implements java.io.Serializable
  -	{
  -		public String name;
  -		public boolean isAscending;
  -
  -		Field(String fieldName, boolean orderAscending)
  -		{
  -			name = fieldName;
  -			isAscending = orderAscending;
  -		}
  -	}
  -
   	public final static int OR = 0;
   	public final static int AND = 1;
   	public final static int NONE = 9;
  @@ -595,10 +581,23 @@
   	{
   		if (fieldName != null)
   		{
  -			_getOrderby().add(new Field(fieldName, sortAscending));
  +			_getOrderby().add(new FieldHelper(fieldName, sortAscending));
   		}
   	}
   
  +
  +    /**
  +     * Adds a field for orderBy
  +     * @param aField
  +     */
  +    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
  @@ -641,7 +640,7 @@
   
   	/**
   	 * Answer the orderBy of all Criteria and Sub Criteria the elements are of
  -	 * class Criteria. Field
  +	 * class Criteria. FieldHelper
   	 * @return Collection
   	 */
   	public List getOrderby()
  @@ -664,7 +663,7 @@
   
       /**
        * Answer the Vector with all orderBy,
  -     * the elements are of class Criteria.Field
  +     * the elements are of class Criteria.FieldHelper
        * @return List
        */
       protected List _getOrderby()
  @@ -881,8 +880,8 @@
   
   	/**
   	 * Gets the groupby for ReportQueries of all Criteria and Sub Criteria
  -     * the elements are of class Criteria. Field
  -	 * @return List of Criteria.Field
  +     * the elements are of class Criteria. FieldHelper
  +	 * @return List of Criteria.FieldHelper
   	 */
   	public List getGroupby()
   	{
  @@ -904,8 +903,8 @@
   
       /**
        * Gets the groupby for ReportQueries,
  -     * the elements are of class Criteria.Field
  -     * @return List of Criteria.Field
  +     * the elements are of class Criteria.FieldHelper
  +     * @return List of Criteria.FieldHelper
        */
       protected List _getGroupby()
       {
  @@ -920,9 +919,21 @@
   	{
   		if (fieldName != null)
   		{
  -			_getGroupby().add(new Field(fieldName, false));
  +			_getGroupby().add(new FieldHelper(fieldName, false));
   		}
   	}
  +
  +    /**
  +     * Adds a field for groupby
  +     * @param aField
  +     */
  +    public void addGroupBy(FieldHelper aField)
  +    {
  +        if (aField != null)
  +        {
  +            _getGroupby().add(aField);
  +        }
  +    }
   
   	/**
   	 * Sets an array of groupby fieldNames for ReportQueries.
  
  
  

Mime
View raw message