有没有类似于bulkDelete_的bulkUpdate方法!!这样我就可以更新基础表中的记录了吗?
发布于 2011-11-09 12:20:52
据我所知,不幸的是,为了执行批量更新(基于某些标准),我们只能使用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-09 01:25:22
不,Mapper中没有bulkUpdate,您必须执行findAll,编辑记录,然后对其执行.save。
https://stackoverflow.com/questions/8047110
复制相似问题