Home How to obtain the Table A rows that are not present in Table B with GORM without using an inList closure?
Reply: 0

How to obtain the Table A rows that are not present in Table B with GORM without using an inList closure?

user1172
1#
user1172 Published in July 18, 2018, 4:58 am

I have a domain definition which generates the following example for database table:

I want to do the following query: Obtain all domain objects related to Table A that are not present in Table B

I was using the inList closure as follow:

    List<DMiembro> m = DMiembro.list()

    List<DUsuario> usuarios = DUsuario.createCriteria().list(params) {
        if (m) {
            not {
                m*.usuario.id.collate(1000).each { def lista ->
                    or {
                        inList("id", lista)
                    }
                }
            }
        }
        eq("enabled", true)
        order("nombre", "asc")
    } as List<DUsuario>

This works fine. However, data in DMiembro is growing to big. Now I am getting a database error related to the size of the query. And that's logical, because the number of parameters of the query is too large

So, is there another way to build a query for gathering Dusuario objects that are not present in DMiembro?

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO