• 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
Deleting with Referential Integrities
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deleting with Referential Integrities


  • Subject: Deleting with Referential Integrities
  • From: Greg <email@hidden>
  • Date: Mon, 27 Jun 2005 14:18:23 +1000

I have an Entity Album that has a to-many relationship to Image. The album also has a relationship to Image as an Icon. When it comes time to delete the image that is the icon for the album, I get the operation failing as it would violate the referential integrity of the album. What I tried to do was intercept if the image about to be deleted was an icon and if so create a different editing context, and set the albums icon to null (something that is allowed), then save this context, force the other context to refault the album and then delete the image. This too fails. I'm at a loss as to what to do in this sort of circumstance.

Any help is greatly appreciated.

Regards,
Greg

public WOComponent deleteImage() {
if (theSession().isDemoMode())
{
if (theApplication().configuration().restrictDemoUser ().booleanValue() == true)
return context().page();
}


String thumb = context().request().stringFormValueForKey ("image");
if (thumb != null) {
ClientImageInterface i = clientImageForThumbnail(thumb);
//if selected remove
theSession().removeFromSelection(i);
if (i != null && theSession().user().allImages ().containsObject(i)) {
if (i.getClass().equals(ClientImage.class)) {
if (((ClientImage)i).isIcon()) {
EOEditingContext seo = ERXEC.newEditingContext();
Album a = (Album) EOUtilities.localInstanceOfObject(seo, ((ClientImage)i).album());
a.setIconRelationship(null);
try {
seo.saveChanges();
} catch (Exception seoX) {
log.error(seoX);
}
i.editingContext().refaultObject((Album) i.imageCollection());
}
}
i.imageCollection().removeFromImagesRelationship(i);
theSession().ec().deleteObject(i);
theSession().ec().saveChanges();
}
}
return pageWithName("NullComponent");
}
_______________________________________________
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: Deleting with Referential Integrities
      • From: Florijan Stamenkovic <email@hidden>
  • Prev by Date: Re: _obtainOpenChannel exception, yet connected
  • Next by Date: Re: java.net.SocketException: Broken pipe??
  • Previous by thread: Re: _obtainOpenChannel exception, yet connected
  • Next by thread: Re: Deleting with Referential Integrities
  • Index(es):
    • Date
    • Thread