FrancescoDS
FrancescoDS

Reputation: 995

Create dynamic finder between two classes in Grails

I have two domain classes (db tables) in my Grails project:

class Doctor {
String role;
String name;
String surname;
String address;
 ...


@NotNull
static belongsTo = [secUser:SecUser]
....
}



class SecUser {

transient springSecurityService

String username
String password
...

}

I would like to find all SecUser that have not a correspondent Doctor.

How can I do it?

Upvotes: 0

Views: 69

Answers (1)

David Chavez
David Chavez

Reputation: 617

I think you need something like this:

SecUser.executeQuery(" FROM SecUser secUser WHERE NOT EXISTS (SELECT doctor.SecUser FROM Doctor doctor")

Upvotes: 0

Related Questions