Home Grails GORM - return count of objects who's array property > 0
Reply: 0

Grails GORM - return count of objects who's array property > 0

user638
1#
user638 Published in July 22, 2018, 8:04 pm

I'm even struggling to write a title that describes my problem, so probably best to do with code;

Consider the following;

class Person {
    int id
    String name

    static hasMany = [cars : Car]
}

class Car {
   int id
   String brand

   static belongsTo = Person
   static hasMany = [owners: Person]
}

The above will result in a person_cars join table. All I'm trying to find out is if there are any entries in that table, in words;

Do any Persons currently exist who own a car.

Happy to use any mechanism available (finders/criteria/HQL etc)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.307037 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO