利用dataManger 实现物理删除请给demo案例!

利用dataManger 实现物理删除请给demo案例,谢谢!

多参考文档:
https://doc.cuba-platform.cn/manual-7.1-chs/dataManager.html

        List<Role> deletedRoles = dataManager.load(Role.class)
                .softDeletion(false)
                .query("select p from sec$Role p where p.deleteTs is not null")
                .list();
        List<Permission> deletedPermissions = dataManager.load(Permission.class)
                .softDeletion(false)
                .query("select p from sec$Permission p where p.deleteTs is not null")
                .list();
        List<Entity> entitiesToRemove = new ArrayList<>();
        entitiesToRemove.addAll(deletedRoles);
        entitiesToRemove.addAll(deletedPermissions);
        CommitContext ctx = new CommitContext();
        ctx.setSoftDeletion(false);
        ctx.setRemoveInstances(entitiesToRemove);
        dataManager.commit(ctx);
2赞

我试试!非常感谢!