NullPointerException only after first call to batchFetchRelationship

Lenny Marks <[email protected]> Sun, 17 Aug 2003 08:57:50 -0400 (EDT)
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <Pine.GSO.4.44.0308170830130.22965-100000@kirk>
I have a direct action to render all information for a specified
'Manuscript' in our database. The rendering of this page traces deep into
the manuscript's relationships and was slow so I was attempting to use
EODatabaseContext.batchFetchRelationship to limit the hits to the
database. I added a method batchFetchManuscriptEvents(the root of the deep
relationships) to my Manuscript EOEnterpriseObject class. I was hoping
that the application could call this in anticipation of its particular
display needs. The method would batchFetch all the relationships so that
by the time the WOComponent was generating its response, all the
relationships would have already been faulted. This actually worked, but
only the first time the method is invoked on a Manuscript instance within
a single EOF stack. The first time I access the direct action for a
manuscript, it works, but if I hit reload I get the exception below.

Any clues would be greatly appreciated!

-Lenny Marks

<ManView>[2003-08-17 07:49:16 EDT] <Thread-6>
java.lang.NullPointerException
        at
com.webobjects.eocontrol._EOMutableKnownKeyDictionary.<init>(_EOMutableKnownKeyDictionary.java:90)
        at
com.webobjects.eoaccess.EORelationship._foreignKeyForSourceRow(EORelationship.java:1094)
        at
com.webobjects.eoaccess.EODatabaseContext._followToManyRelationshipWithFetchSpecification(EODatabaseContext.java:2656)
        at
com.webobjects.eoaccess.EODatabaseContext._followFetchSpecification(EODatabaseContext.java:2781)
        at
com.webobjects.eoaccess.EODatabaseContext._batchFetchRelationshipForSourceObjectsEditingContext(EODatabaseContext.java:3878)
        at
com.webobjects.eoaccess.EODatabaseContext.batchFetchRelationship(EODatabaseContext.java:3962)
        at
org.aps.webproeof.manuscript.Manuscript.batchFetchRecipients(Manuscript.java:266)
        at
org.aps.webproeof.manuscript.Manuscript.batchFetchManuscriptEvents(Manuscript.java:167)
        at
org.aps.webprowo.view.ManuscriptView.<init>(ManuscriptView.java:43)
        at
org.aps.webprowo.view.ManuscriptView.findByAccode(ManuscriptView.java:62)
        at DirectAction.findByAccodeAction(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


code ex.

/** batch fetch CorrespondenceVersions for correspondences. */
private void
batchFetchCorrespondenceVersions(EOModel model,
                                 EODatabaseContext dbContext,
                                 NSArray correspondences)
{

        EOEditingContext ec = editingContext();

        if(correspondences.count() < 1) return;

        LOGGER.debug("batch fetching CorrespondenceVersions");

        Correspondence corr =
(Correspondence)correspondences.objectAtIndex(0);

        EOEntity corrEntity = model.entityForObject(corr);

        EORelationship versionsRelationship =
corrEntity.relationshipNamed("versions");

        dbContext.batchFetchRelationship(versionsRelationship,
correspondences, ec);

    }