Is there any bulkUpdate (similar to bulkDelete_!!) in Mapper?
题
Is there a bulkUpdate method similar to bulkDelete_!! in mapper so that i can update records in underlying table ?
解决方案
As per my knowledge , Unfortunately in order to perform bulk update ( based on some criteria ) we have to use sql query only. No method similar to bulkDelete_!! available for bulk Update.
For example:
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()
}
}
}
其他提示
No, there is no bulkUpdate in Mapper, you would have to do a findAll, edit the records and then do a .save on them.
不隶属于 StackOverflow