You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Andy Malakov <an...@transdecisions.com> on 2004/01/02 16:44:22 UTC
Assertion in org.apache.ojb.broker.accesslayer.ReferencePrefetcher
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
Re: Assertion in org.apache.ojb.broker.accesslayer.ReferencePrefetcher
Posted by Andy Malakov <an...@transdecisions.com>.
I haven't yet started but I will. After briefly looking at ReferenceMap I realized that much code still have to be duplicated unless
we request API change.
----- Original Message -----
From: "Armin Waibel" <ar...@code-au-lait.de>
To: "OJB Developers List" <oj...@db.apache.org>
Sent: Friday, January 02, 2004 10:52 AM
Subject: Re: Assertion in org.apache.ojb.broker.accesslayer.ReferencePrefetcher
> Hi Andy,
>
> by the way, are you working on a IdentityWeakHashMap implementation
> based on commons-collection ReferenceMap?
> I'm too busy to write this code.
> I will check in a workaround for the AnomymousField-Identity problem
> using an Identity wrapper today.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: Assertion in org.apache.ojb.broker.accesslayer.ReferencePrefetcher
Posted by Armin Waibel <ar...@code-au-lait.de>.
Hi Andy,
by the way, are you working on a IdentityWeakHashMap implementation
based on commons-collection ReferenceMap?
I'm too busy to write this code.
I will check in a workaround for the AnomymousField-Identity problem
using an Identity wrapper today.
regards,
Armin
Andy Malakov wrote:
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org