db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Malakov" <a...@transdecisions.com>
Subject Assertion in org.apache.ojb.broker.accesslayer.ReferencePrefetcher
Date Fri, 02 Jan 2004 15:44:22 GMT
Hello All,

Is it possible to add an assertion into the method 

ReferencePrefetcher.associateBatched(Collection owners, Collection children)

that will validate that all parent objects that have non-null children foreign keys found
their children?


        for (Iterator it = owners.iterator(); it.hasNext(); )
        {
            owner = it.next();
            fkValues = ord.getForeignKeyValues(owner,cld);
            if (isNull(fkValues))
            {
                field.set(owner, null);
                continue;
            }
            id = new Identity(null, topLevelClass, fkValues);
+           boolean childFound = false;
            for (Iterator it2 = children.iterator(); it2.hasNext(); )
            {
                relatedObject = it2.next();
                id2 = new Identity(relatedObject, pb);
                if (id.equals(id2))
                {
                    field.set(owner, relatedObject);
 +                  childFound = true;
                    break;
                }
            }

+          if ( ! childFound) 
+              throw new SomeKindOfException ("ReferencePrefetcher.associateBatched() Unresolved
reference: " + owner + "->" + id);
        }


I believe that there is some intermittent problem with batch loading that appears as lost
children.
(2Armin: this happens even with WeakIdentityHashMap)


Thanks,
Andy

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message