Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 703 Bytes

Delete.md

File metadata and controls

29 lines (23 loc) · 703 Bytes

MapperDao has a DSL to delete data which resembles delete SQL.

import Delete._
val pe = ProductEntity
val rowsAffected=(
	delete from pe 
	where pe.name === "cpu"
).run(queryDao).rowsAffected

println(rowsAffected) // number of deleted rows

Many to one and one to one related data can be used in the criteria as it would in a delete SQL:

import Delete._
val pe = PersonEntity
(
	delete from pe 
	where pe.company === c1
).run(queryDao)

Please note: MapperDao doesn't delete related entity data. Foreign key "on delete cascade" should be used.

Please also see DeleteSuite.