Grails Bulk updates

if you have a bulk operation: delete or update you can set the flush so it will occur every 1000 records updated.

def commitEvery = 1000
Domain.list().eachWithIndex{ obj, index ->
   obj.property = value
   obj.save flush:0 == index % commitEvery
}
session = sessionFactory.getCurrentSession()
session.clear()

Leave a Reply

Your email address will not be published. Required fields are marked *