• 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: EOModel - Cascading Delete Rule for relationship wich is not a class property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOModel - Cascading Delete Rule for relationship wich is not a class property


  • Subject: Re: EOModel - Cascading Delete Rule for relationship wich is not a class property
  • From: Denis Frolov <email@hidden>
  • Date: Tue, 13 Oct 2009 00:19:01 +0400

Hi,

I think willDelete() is a better place to do that...

On Mon, Oct 12, 2009 at 8:03 PM, Benoit Havret <email@hidden> wrote:
>
> Hi all,
>
> In my model I have Entities with to-many relationships that I choose not
> include as class properties. The problem is when I delete an eobject of such
> an entity the delete rules do not apply thus causing the delete operation to
> fail. I've overridden the delete method of my class for EObjects (wich
> extends ERXGenericRecord) to  this :
>
>     public void delete() {
>         for (EORelationship relation : entity().relationships()) {
>             // to-many relationship that is not in class properties with
>             // cascade as delete rule
>             if (relation.isToMany()
>                     && relation._stringFromDeleteRule(relation.deleteRule())
>                             .equals(EORelationship.DeleteRuleCascadeString)
>                     &&
> !entity().classPropertyNames().contains(relation.name())) {
>                 EOQualifier qualifier = relation.qualifierWithSourceRow(this
>                         .snapshot());
>                 EOFetchSpecification fetchSpecification = new
> EOFetchSpecification(
>                         relation.destinationEntity().name(), qualifier,
> null);
>                 // fetching objects for the relationship
>                 NSArray<ERXGenericRecord> objects = editingContext()
>                         .objectsWithFetchSpecification(fetchSpecification);
>                 // now delete them
>                 for (ERXGenericRecord eoGenericRecord : objects) {
>                     eoGenericRecord.delete();
>                 }
>             }
>         }
>         super.delete();
>     }
> This seems to work fine for me, but I was wondering if this is a good way of
> handling my problem?
>
> Benoit Havret
> email@hidden
> ALGO DATA
> +33 251 80 85 85
>
>  _______________________________________________
> 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
>
 _______________________________________________
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

References: 
 >EOModel - Cascading Delete Rule for relationship wich is not a class property (From: Benoit Havret <email@hidden>)

  • Prev by Date: Re: UnsupportedEncodingException - er.javamail
  • Next by Date: Re: JD update
  • Previous by thread: EOModel - Cascading Delete Rule for relationship wich is not a class property
  • Next by thread: Another odd ERExcelLook oddity: email
  • Index(es):
    • Date
    • Thread