• 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
Qualifier involving many-to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Qualifier involving many-to-many relationship


  • Subject: Qualifier involving many-to-many relationship
  • From: Paul Hoadley <email@hidden>
  • Date: Thu, 29 Jan 2015 12:24:15 +1030

Hello,

I have two entities in a model: Teacher and School.  There is a many-to-many relationship between Teacher and School, represented as Connection, a join entity.  So, Teacher and School both have a 'connections' relationship, and Connection has both 'teacher' and 'school'.  There are no flattened relationships.  The Connection entity is modelled as a first class EO, as it contains other useful metadata.

Say I have a School S.  I want a list of "unconnected Teachers" for S such that any Teacher T in that list has no Connection C in T.connections() such that C.school() returns S.  This method in School produces the result I'm after:

public NSArray<Teacher> unconnectedTeachers() {
NSArray<Teacher> connectedTeachers = (NSArray<Teacher>) connections()
.valueForKey(Connection.TEACHER_KEY);
NSArray<Teacher> allTeachers = Teacher
.fetchAllTeachers(editingContext());
return ERXArrayUtilities
.arrayMinusArray(allTeachers, connectedTeachers);
}

But surely this is achievable with a single qualifier on Teacher?  I tried this:

ERXQ.not(Teacher.CONNECTIONS.dot(Connection.SCHOOL).containsObject(this))

This looked promising in WOUnit testing, but fails to return the "unconnected Teachers" against an actual database.  Does anyone have any suggestions?  (Looking at you Dave A and Aaron!)


-- 
Paul Hoadley
http://logicsquad.net/


 _______________________________________________
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: Qualifier involving many-to-many relationship
      • From: Aaron Rosenzweig <email@hidden>
  • Prev by Date: Re: Getting Selected Values from Subcomponents
  • Next by Date: Re: Qualifier involving many-to-many relationship
  • Previous by thread: Re: Webobjects-dev Digest, Vol 12, Issue 41
  • Next by thread: Re: Qualifier involving many-to-many relationship
  • Index(es):
    • Date
    • Thread