Is there any bulkUpdate file (similar to bulkDelete_ !!) in Mapper?

Is there a bulkUpdate method similar to bulkDelete_ !! in mapper so that I can update the records in the base table?

+4
source share
2 answers

According to my information, unfortunately, to perform a bulk update (based on some criteria), we should use only the sql query. No method like bulkDelete_ !! available for bulk update.

For instance:

def updateNameById (newName : String, id : Long) = { val updateString = "update MyModel set name = ? where id = ?" DB.use(DefaultConnectionIdentifier) { conn => DB.prepareStatement(updateString, conn) { stmt => stmt.setString(1, newName) stmt.setLong(2, id) stmt.executeUpdate() } } } 
+4
source

No, there is no bulk update in Mapper, you will need to do findAll, edit the entries and then make .save on them.

+1
source

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


All Articles