playframework2.2.x anorm 批量插入
阿新 • • 發佈:2019-01-30
definsertBatch():Unit={ DB.withConnection { implicit connection => val batch = BatchSql( SQL("INSERT INTO books(title, author) VALUES({title}, {author})"), Seq( Seq[(String, ParameterValue[String])]("title" ->toParameterValue("Play 2 for Scala"), "author" -> toParameterValue("Peter Hilton")),Seq[(String, ParameterValue[String])]("title" -> toParameterValue("Learning Play! Framework 2"), "author" -> toParameterValue("Andy Petrella")) )) println(batch) val res: Array[Int] = batch.execute() } }