I have a class A, mapped with a recursive has many relationship. (A has many A). The A class has a boolean attribute "islocked". If I have an instance of class A, how can I find all of A's descendants that have islocked == 1.
static hasMany = [children:A]
This would give me all the A that have islocked == true
A.findAll(islocked== true);
I want the same functionality given an instantiated A as such:
def instantiated_A = A.get(1); //Grab an instance
def descendants = instantiated_A.what_should_I_call_here(); // What should I do here?
Are you looking to find out children with isLocked
true? If yes, you can use where
query as below:
A.where { id == 1 && children.isLocked }.children.list()