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

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


  • Subject: EOModel - Cascading Delete Rule for relationship wich is not a class property
  • From: Benoit Havret <email@hidden>
  • Date: Mon, 12 Oct 2009 18:03:35 +0200


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

  • Follow-Ups:
    • Re: EOModel - Cascading Delete Rule for relationship wich is not a class property
      • From: Denis Frolov <email@hidden>
  • Prev by Date: Re: JD update
  • Next by Date: Re: JD update
  • Previous by thread: Re: using the keys to navigate on an AjaxSelectionList
  • Next by thread: Re: EOModel - Cascading Delete Rule for relationship wich is not a class property
  • Index(es):
    • Date
    • Thread