Re: Need to perform another fetch?
Re: Need to perform another fetch?
- Subject: Re: Need to perform another fetch?
- From: Jonathan Rochkind <email@hidden>
- Date: Mon, 12 Apr 2004 11:11:43 -0500
At 9:20 PM -0700 4/11/04, Bill Reynolds wrote:
I have a component that does a great deal of work and after the user has
made a bunch of choices I end up with a correctly fetched record. I perform
some actions on it, save it, etc.
After all that is said and done I'm left with my object, an enterprise
object, we'll call it "MyUserClass". I want to pass this into another
component for some further operation, but because of my design I don't keep
it in the Session (an obvious mistake on my part). So I've created a
variable in the new component for storing it, and I can easily pass it in
after I create the new component.
So far, so good. I think this is the right way to do it; you don't
want to put it in the Session, it's better to do it the way you are
doing it.
My question is this... Once I have "MyUserClass" object in my new component,
how do I update it and save changes? Do I need to pass along the
EditingContext with it somehow?
Well, what editing context is the object _in_? What editing context
did you fetch the object into? If you are only dealing with the
session.defaultEditingContext, and you fetched the object into the
session default editing context, then the object is... of course in
the session default editing context.
And to save all the changes tracked by that EC, the session default
editing context, including both changes to that object and any other
object. And you save them by calling saveChanges on the session
default editing context.
I did the obvious beginner stuff, that is to say I made some changes to the
object then I called the 'save' method of the new components default editing
context - but the update to the database doesn't happen.
Well, first of all the component doesn't have a default editing
context. The _session_ has a default editing context.
But that is unexpected, based on what we know of your situation.
You're going to have to debug what's going on. What EC is the object
in? (call someObject.editingContext() to find out). Is that the EC
you thought it was in? Is that object listed in ec.updatedObjects()?
Have you violated any of the "EOF Commandments":
http://wodev.spearway.com/cgi-bin/WebObjects/WODev.woa/wa/Main?wikiPage=EOFCommandments
Good luck,
--Jonathan
TIA for any guidance,
-Bill
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.