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 ReferencePrefetcher.java CollectionPrefetcher.java
Date Sun, 07 Sep 2003 15:15:01 GMT
brj         2003/09/07 08:15:01

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ReferencePrefetcher.java CollectionPrefetcher.java
  Log:
  fixed creation of Identity (real class is null)
  
  Revision  Changes    Path
  1.8       +11 -11    db-ojb/src/java/org/apache/ojb/broker/accesslayer/ReferencePrefetcher.java
  
  Index: ReferencePrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ReferencePrefetcher.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ReferencePrefetcher.java	31 Aug 2003 00:15:03 -0000	1.7
  +++ ReferencePrefetcher.java	7 Sep 2003 15:15:01 -0000	1.8
  @@ -95,21 +95,22 @@
   	 */
   	protected void associateBatched(Collection owners, Collection children)
   	{
  +        ObjectReferenceDescriptor ord = getObjectReferenceDescriptor();
   		ClassDescriptor cld = getOwnerClassDescriptor();
  -		Iterator iter = owners.iterator();
   		Object owner, relatedObject;
   		Object fkValues[];
   		Identity id;
  -		PersistentField field = getObjectReferenceDescriptor().getPersistentField();
  -        Class topLevelClass = getBroker().getTopLevelClass(getObjectReferenceDescriptor().getItemClass());
  -        Class realClass = getObjectReferenceDescriptor().getItemClass();
  +        PersistenceBroker pb = getBroker();
  +		PersistentField field = ord.getPersistentField();
  +        Class topLevelClass = pb.getTopLevelClass(ord.getItemClass());
  +        Iterator iter = owners.iterator();
  +
   		while (iter.hasNext())
   		{
   			owner = iter.next();
  -			fkValues = getObjectReferenceDescriptor().getForeignKeyValues(owner,cld);
  -			// id = new Identity(getItemClassDescriptor().getClassOfObject(), fkValues);
  -            id = new Identity(realClass, topLevelClass, fkValues);
  -			relatedObject = getBroker().getObjectByIdentity(id);
  +			fkValues = ord.getForeignKeyValues(owner,cld);
  +            id = new Identity(null, topLevelClass, fkValues);
  +			relatedObject = pb.getObjectByIdentity(id);
   			field.set(owner, relatedObject);
   		}
   	}
  @@ -126,7 +127,6 @@
           Collection idsSubset = new HashSet();
           Iterator iter = owners.iterator();
           Class topLevelClass = getBroker().getTopLevelClass(ord.getItemClass());
  -        Class realClass = ord.getItemClass();
           Object[] fkValues;
           Object owner;
           Identity id;
  @@ -136,7 +136,7 @@
           {
               owner = iter.next();
               fkValues = ord.getForeignKeyValues(owner,cld);
  -            id = new Identity(realClass, topLevelClass, fkValues);
  +            id = new Identity(null, topLevelClass, fkValues);
               if (cache.lookup(id) == null)
               {
                   idsSubset.add(id);
  
  
  
  1.16      +5 -7      db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java
  
  Index: CollectionPrefetcher.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/CollectionPrefetcher.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CollectionPrefetcher.java	29 Aug 2003 15:11:02 -0000	1.15
  +++ CollectionPrefetcher.java	7 Sep 2003 15:15:01 -0000	1.16
  @@ -237,11 +237,9 @@
       {
           CollectionDescriptor cds = getCollectionDescriptor();
           ClassDescriptor cld = getItemClassDescriptor();
  -        Iterator iter = children.iterator();
           PersistentField field = cds.getPersistentField();
           PersistenceBroker pb = getBroker();
  -        ClassDescriptor ownerCld = getOwnerClassDescriptor();
  -        Class ownerClass = pb.getTopLevelClass(ownerCld.getClassOfObject());
  +        Class ownerTopLevelClass = pb.getTopLevelClass(getOwnerClassDescriptor().getClassOfObject());
           // this collection type will be used:
           Class collectionClass = cds.getCollectionClass();
           Object owner, relatedObject;
  @@ -250,6 +248,7 @@
           HashMap ownerIdsToLists = new HashMap();
           ArrayList list;
           Object result;
  +        Iterator iter;
   
           // ensure that all owners will get non-null collections
           iter = owners.iterator();
  @@ -264,7 +263,7 @@
           {
               relatedObject = iter.next();
               fkValues = cds.getForeignKeyValues(relatedObject, cld);
  -            id = new Identity(ownerCld.getClassOfObject(), ownerClass, fkValues);
  +            id = new Identity(null, ownerTopLevelClass, fkValues);
               list = (ArrayList) ownerIdsToLists.get(id);
   
               // BRJ: do not add object if it's already in the list
  @@ -279,8 +278,7 @@
               id = (Identity) it.next();
               list = (ArrayList) ownerIdsToLists.get(id);
               owner = pb.getObjectByIdentity(id);
  -            if ((collectionClass == null)
  -                && field.getType().isArray())
  +            if ((collectionClass == null) && field.getType().isArray())
               {
                   int length = list.size();
                   Class itemtype = field.getType().getComponentType();
  
  
  

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