• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder


  • Subject: Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 7 Apr 2006 16:17:31 -0700


On Apr 7, 2006, at 4:10 PM, David Holt wrote:


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.


public NSArray meetingRepetition() {
ApplicationUser applicationUser = (ApplicationUser) valueForKeyPath("session.user");
EOEditingContext ec = applicationUser.editingContext();
return EOUtilities.objectsWithQualifierFormat(ec,
"Meeting",
"user = %@",
new NSArray (applicationUser));
}



'scuse the formatting. :-)

Got lost in the forest on the first answer. I answered "How do I set the qualifier for the user that is logged in?" rather than the question you were really wanting an answer to.

Is perhaps what you are after? This assumes that Meeting has a user () relationship to ApplicationUser.


Chuck


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'

--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
      • From: David Holt <email@hidden>
    • Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
      • From: David Holt <email@hidden>
References: 
 >Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder (From: David Holt <email@hidden>)
 >Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder (From: Chuck Hill <email@hidden>)
 >Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder (From: David Holt <email@hidden>)

  • Prev by Date: Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
  • Next by Date: Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
  • Previous by thread: Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
  • Next by thread: Re: Creating a fetch that returns the same results as using "session.user.meetings" in WOBuilder
  • Index(es):
    • Date
    • Thread