Domanda

Is there a bulkUpdate method similar to bulkDelete_!! in mapper so that i can update records in underlying table ?

È stato utile?

Soluzione

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()
        }
    }
}

Altri suggerimenti

No, there is no bulkUpdate in Mapper, you would have to do a findAll, edit the records and then do a .save on them.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top