This message was deleted.
# questions
s
This message was deleted.
g
Can you do batching in Grails yes... should you maybe maybe not. I find that ORMs are great for CRUD and limiting how much you have to dip into direct SQL. If you want more control or are doing complex queries then direct SQL is the way to go. There are several ways you can do this without dropping down all the way to straight JDBC, like Groovy SQL, session.createQuery, and jdbctemplate: https://stackoverflow.com/questions/6282374/grails-sql-queries https://blog.mrhaki.com/2014/03/grails-goodness-using-hibernate-native.html https://www.oodlestechnologies.com/blogs/spring-jdbc-template-in-grails-application/ each has its own quirks and trade-offs. If you are bound and determined to do batch in Gorm there are a few tricks you might gleam from these sights, but you could still run into similar errors: https://krixisolutions.com/bulk-insert-grails-gorm/ https://www.tothenew.com/blog/batch-processing-in-grails/ https://www.naleid.com/2009/10/01/batch-import-performance-with-grails-and-mysql.html in general, I would not use
Domain.withNewTransaction
unless I had to and instead use the `@Transactional`(package varies between Grails versions) annotation from Grails, not Spring.
@Transactional
can be applied to the class level or the method level and does provide you some options that
withNewTransaction
doesn't: https://docs.grails.org/latest/guide/services.html#declarativeTransactions https://grails.github.io/grails2-doc/2.5.6/api/grails/transaction/Transactional.html https://www.infoq.com/presentations/grails-transaction-2gx/ That being said you really shouldn't be writing new functionality on top of Grails 2.5.6, it's been EOL for over two years now, so you are putting yourself at risk for security issues. Upgrading from Grails 2.x to 3.x+ can be difficult depending on the size of your code base and how many bad practices you follow that are no longer supported. Some plugins are no longer valid and have become either gradle plugins, Grails features, or are just not supported because the original author stopped supporting it. Once past the Grails 3.x mark upgrades become a lot easier. At this point, I would upgrade to at least Grails 5.3.3 with a plan to upgrade to 6.0.x in the not-too-distant future. Good luck.