Announcement Announcement Module
Collapse
No announcement yet.
Many-to-many relation on single class forward and reverse Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Many-to-many relation on single class forward and reverse

    Hi,

    how do I get the reverse relation of this many-to-many single class relation?
    Code:
    class MyObject {
        static hasMany = [ dependsOn : MyObject ]
        static mappedBy = [ dependsOn : 'dependsOn' ]
    
        def addDependency(MyObject obj) {
            this.addToDependsOn(obj)
        }
    
        def getDependencies() {
            return dependsOn
        }
    
        def getDependants() {
            return //???
        }
    }
    I have objects which have dependencies on each other. I get the dependencies of one object via the getDependencies() method. But how do I get the dependants of an object?

    Thank you!

    Best regards,
    Malte
Working...
X