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/singlevm PersistenceBrokerImpl.java
Date Sat, 15 Mar 2003 16:59:07 GMT
brj         2003/03/15 08:59:07

  Modified:    src/java/org/apache/ojb/broker/singlevm
                        PersistenceBrokerImpl.java
  Log:
  Query refactoring
  
  Revision  Changes    Path
  1.143     +10 -16    db-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- PersistenceBrokerImpl.java	15 Mar 2003 08:51:19 -0000	1.142
  +++ PersistenceBrokerImpl.java	15 Mar 2003 16:59:06 -0000	1.143
  @@ -90,6 +90,7 @@
   import org.apache.ojb.broker.query.Criteria;
   import org.apache.ojb.broker.query.MtoNQuery;
   import org.apache.ojb.broker.query.Query;
  +import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.QueryByIdentity;
   import org.apache.ojb.broker.query.QueryBySQL;
   import org.apache.ojb.broker.query.QueryFactory;
  @@ -1043,9 +1044,6 @@
        */
       private void retrieveCollection(Object obj, ClassDescriptor cld, CollectionDescriptor
cds, boolean forced)
       {
  -//         logger.debug("Retrieving collection ["+cds.getCascadeRetrieve()
  -//                      +"] MtoN ["+cds.isMtoNRelation()
  -//                      +"] for "+obj.getClass().getName());
   
           if (forced || cds.getCascadeRetrieve())
           {
  @@ -1053,7 +1051,7 @@
               Class collectionClass = cds.getCollectionClass();
               PersistentField collectionField = cds.getPersistentField();
               Query fkQuery = null;
  -
  +            
               if (cds.isMtoNRelation())
               {
                   fkQuery = getMtoNQuery(obj, cld, cds);
  @@ -1069,7 +1067,7 @@
                   Iterator iter = cds.getOrderBy().iterator();
                   while (iter.hasNext())
                   {
  -                    fkQuery.getCriteria().addOrderBy((FieldHelper)iter.next());
  +                    ((QueryByCriteria)fkQuery).addOrderBy((FieldHelper)iter.next());
                   }
               }
   
  @@ -1964,12 +1962,12 @@
   
       /**
        * Get Foreign key query for 1:n
  -     * @return org.apache.ojb.broker.query.Query
  +     * @return org.apache.ojb.broker.query.QueryByCriteria
        * @param obj
        * @param cld
        * @param cod
        */
  -    private Query getForeignKeyQuery(Object obj, ClassDescriptor cld, CollectionDescriptor
cod)
  +    private QueryByCriteria getForeignKeyQuery(Object obj, ClassDescriptor cld, CollectionDescriptor
cod)
       {
           Object[] values = brokerHelper.getKeyValues(cld, obj);
           ClassDescriptor refCld = getClassDescriptor(cod.getItemClass());
  @@ -1982,27 +1980,24 @@
               criteria.addEqualTo(fld.getAttributeName(), values[i]);
           }
   
  -        Query result = QueryFactory.newQuery(refCld.getClassOfObject(), criteria);
  -
  -        return result;
  +        return QueryFactory.newQuery(refCld.getClassOfObject(), criteria);
       }
   
       /**
        * Get Foreign key query for m:n <br>
        * supports UNIDIRECTIONAL m:n using QueryByMtoNCriteria
  -     * @return org.apache.ojb.broker.query.Query
  +     * @return org.apache.ojb.broker.query.QueryByCriteria
        * @param obj the owner of the relationship
        * @param cld the ClassDescriptor for the owner
        * @param cod the CollectionDescriptor
        */
  -	private Query getMtoNQuery(Object obj, ClassDescriptor cld, CollectionDescriptor cod)
  +	private QueryByCriteria getMtoNQuery(Object obj, ClassDescriptor cld, CollectionDescriptor
cod)
   	{
   		Object[] values = brokerHelper.getKeyValues(cld, obj);
   		Object[] thisClassFks = cod.getFksToThisClass();
   		Object[] itemClassFks = cod.getFksToItemClass();
   		ClassDescriptor refCld = getClassDescriptor(cod.getItemClass());
   		Criteria criteria = new Criteria();
  -		Query query;
   
   		for (int i = 0; i < thisClassFks.length; i++)
   		{
  @@ -2015,8 +2010,7 @@
   				refCld.getPkFields()[i].getAttributeName());
   		}
   
  -		query = QueryFactory.newQuery(refCld.getClassOfObject(), cod.getIndirectionTable(), criteria);
  -		return query;
  +		return QueryFactory.newQuery(refCld.getClassOfObject(), cod.getIndirectionTable(), criteria);
   	}
   
       /**
  
  
  

Mime
View raw message