On 7 Apr 2006, at 11:48 AM, Chuck Hill wrote:


    /** @TypeInfo Meeting */
    public NSArray meetingsRepetition()
    {
        return meetingsRepetition;
    }
    public void setMeetingsRepetition(NSArray newMeetingsRepetition)
    {
        EOFetchSpecification fetchSpec = new EOFetchSpecification();
ApplicationUser user = ((Session)session()).user();

EOFetchSpecification fetchSpec = new EOFetchSpecification("ApplicationUser",
qualifierForEnterpriseObject(user.editingContext(), user),
NSArray.EmptyArray);


fetchSpec.setRefreshesRefetchedObjects(true);
fetchSpec.setPrefetchingRelationshipKeyPaths(new NSArray("meetings"));
meetingsRepetition = editingContext().objectsWithFetchSpecification(fetchSpec);
// meetingsRepetition = newMeetingsRepetition;
    }


Thanks Chuck,

I have updated the code using your suggestion as a starting base. I have separated all the steps of the fetch specification as I was learning what each thing meant. The code above is returning ApplicationUsers and I am pretty sure I need to replace that with "Meeting". I think this makes the prefetching unnecessary. Here is the changed code:

    public NSArray meetingRepetition()
    {
        EOQualifier myQualifier;
NSArray mySortOrderings;
ApplicationUser applicationUser = (ApplicationUser) valueForKeyPath("session.user");
EOEditingContext ec = applicationUser.editingContext();
EOFetchSpecification fetchSpec = new EOFetchSpecification();
fetchSpec.setEntityName("Meeting");
myQualifier = EOUtilities.qualifierForEnterpriseObject(ec, applicationUser);
fetchSpec.setQualifier(myQualifier);
mySortOrderings = NSArray.EmptyArray;
fetchSpec.setSortOrderings(mySortOrderings);
fetchSpec.setRefreshesRefetchedObjects(true);
// fetchSpec.setPrefetchingRelationshipKeyPaths(new NSArray("meetings"));
Session sess = (Session)session();
EOEditingContext myEC = sess.defaultEditingContext();
meetingRepetition = myEC.objectsWithFetchSpecification(fetchSpec);
return meetingRepetition;
    }

This gives an application error (see below) on the many to many relationship. How do I set the qualifier for the user that is logged in?

Application:
WOMeeting
Error:
java.lang.IllegalStateException: sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (applicationUserID = 1) failed because attribute identified by key 'applicationUserID' was not reachable from from entity 'Meeting'
Reason:
sqlStringForKeyValueQualifier: attempt to generate SQL for com.webobjects.eocontrol.EOKeyValueQualifier (applicationUserID = 1) failed because attribute identified by key 'applicationUserID' was not reachable from from entity 'Meeting'
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to