gorm批量删除

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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