Can I use IN and findBy together in Groovy and Grails?

I was trying to figure out how to do something like

SELECT * FROM domain WHERE config_id IN (1, 2, 3)

using the good findByGrails method . In fact, did not understand how this is possible? I was hoping for something like

Domain.findByConfigIn(configList)

but that will not work. Does anyone know how to do this, or even if it is possible?

+3
source share
1 answer

Assuming your domain class has a field called configId , the following should do what you want:

Domain.findAllByConfigIdInList(configList)
+10
source

Source: https://habr.com/ru/post/1773181/


All Articles