Support for Recursive Many to Many Relationships

I' curious if Mendix fully supports many to many recurisive relationships?  The data modeler allows creating a many to many association from Entity A to Entity A.  Let's call this association A_A. Let's say I've created two instances of A - A1 & A2. When I associate A2 to A1 the reference set for A1 seems to accurately reflect the member of A2 over the A_A association. However, when I go to look at A2, its A_A association reference set is empty.  It's as if system does not truly treat the A_A association  as a many to many. Is this an implementation short coming within Mx?  I've noted that on the A_A properties, the modeler complains if the Owner property is set to "Both".  The error message states:  Owner must be "Default" for self-referential associations. Am I missing something, or is this a limitation within Mx?  I could get around it with an old fashioned associative entity, but would rather not go that route unless I have to.        
2 answers

From my experience with mendix n:m self associations i'd say: don't do it; or have a really good reason.

  • retrieve by association only works one way (at least without java)
  • reversed() will give you headaches, and everyone else who is trying to bugfix your retrieves. too (and it still had issues 'till 7.3)
  • quite often you need some attribute on the association later on anyway.
  • A1 referencing A2 is not the same as A2 referencing A1. That's why owner:both is not possible here.



Mendix suppport this, but you may need to use the reversed() function in your XPath retrieves, as detailed here.