• 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: How to delete an EO?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete an EO?


  • Subject: Re: How to delete an EO?
  • From: Jonathan Rochkind <email@hidden>
  • Date: Mon, 19 Apr 2004 10:52:16 -0500

You don't tell us why what you are doing doens't work.

It's important to keep track of what EC a given EO is in. But assuming you have the right EC, there's nothing tricky about deleting an object:

ec.deleteObject( eo );
ec.saveChanges();

What happens when you do that? Do you get an exception? Is the object simply not deleted? Are you sure? Have you tried turning on SQL logging for your app, to see if 'delete' SQL is sent to the database? (Add a launch argument -"-DEOAdaptorDebugEnabled=true" to turn on SQL trace). Are you doing anything complex with ECs: are you just using the session default, or are you creating your own ECs? If you are creating your own ECs, are you sure you are deleting the object from the right EC? If you are creating your own ECs, are you creating 'peer' ECs ("new EOEditingContext();") or 'child' ECs? ("new EOEditingContext( someOtherEC );"). Child ECs do not save directly to the db, but only save changes to their 'parent', and then the parent needs saveChanges() called on it too, to commit to the database (that's assuming the parent isn't a child itself!).

--Jonathan

At 9:49 PM -0700 4/16/04, Bill Reynolds wrote:
This has got to be one of those "so simple it will make me feel stupid"
questions (but I'll ask anyway).

Below is the code from a component.  It's pretty simple, there's a single
variable that contains an EO ("userRecord").  I can use it's editingContext
to update it and that all works great.

I've created a function for 'deleting' the object and I can't seem to find
the right way to go about it.  As you can see in my deleteRecord() function
below I've tried just about every combination, but I can't delete my
'userRecord' object from the database.

What the heck am I doing?

Much appreciation,

-Bill



public class AdminEditRegUser extends WOComponent {

    protected RegUsers userRecord;

public AdminEditRegUser(WOContext context) {
super(context);
} public WOComponent deleteRecord()
{ //userRecord().editingContext().deleteObject(userRecord);
userRecord().editingContext().deleteObject(userRecord());
userRecord().editingContext().saveChanges();
//EOEditingContext ec = session().defaultEditingContext();
//EOEditingContext ec = userRecord().editingContext();
//ec.deleteObject(userRecord());
//ec.saveChanges();
return null;
}


public WOComponent updateRecord()
{
if(onMailingsChecked == 0)
{
userRecord.setON_MAILINGS("0");
}else{
userRecord.setON_MAILINGS("1");
}
if(needsFollowupChecked == 0)
{
userRecord.setFOLLOW_UP("0");
}else{
userRecord.setFOLLOW_UP("1");
}
userRecord().editingContext().saveChanges();
return null;
}


}
_______________________________________________
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.


References: 
 >How to delete an EO? (From: Bill Reynolds <email@hidden>)

  • Prev by Date: Re: EO error on saveChanges for deleted object
  • Next by Date: Re: making associations between eomodeler files
  • Previous by thread: Re: How to delete an EO?
  • Next by thread: backtracking and Mac browsers
  • Index(es):
    • Date
    • Thread