0

Registration domain has a collection of discounts.

static hasMany = [ discounts: Discount]

I want to extract all Registrations that have a particular discount applied.

In the following code i want to get all registrations whose collection has the discount of id disid. How can i achieve that? I appreciate any help!

def disid = Discount.get(1).id

def regs = Registration.createCriteria().list(){

            eq('compositeEvent', cod.compositeEvent)

}
kofhearts
  • 3,607
  • 8
  • 46
  • 79

1 Answers1

1

Try this:

def disid = Discount.get(1).id

def regs = Registration.withCriteria() {
    discounts  {
        eq 'id', disid
    }
}

See http://emmanuelrosa.com/articles/gorm-for-sqladdicts-where-clause/

Emmanuel Rosa
  • 9,697
  • 2
  • 14
  • 20