gorm批量删除
- 作者: 别撕了我脱还不行么
- 来源: 51数据库
- 2022-08-17
def batchDelete(Class entityClass,ids){
entityClass.executeUpdate("delete ${entityClass.name} where id in(:ids)",[ids:ids*.toLong()])
//还需清除sessionFactory缓存中数据
entityClass.withSession{ session ->
ids.each{ id ->
session.sessionFactory.evict(entityClass,id)
}
}
}
推荐阅读
