有没有类似bulkDelete_的bulkUpdate方法!!在映射器中以便我可以更新基础表中的记录?
问问题
217 次
2 回答
5
据我所知,不幸的是,为了执行批量更新(基于某些标准),我们只能使用 sql 查询。没有类似bulkDelete_的方法!!可用于批量更新。
例如:
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()
}
}
}
于 2011-11-09T04:20:52.053 回答
1
不,Mapper 中没有 bulkUpdate,您必须执行 findAll,编辑记录,然后对它们执行 .save。
于 2011-11-08T17:25:21.707 回答