private void deleteIdentityVoAndEntries(AclObjectIdentity aclObjectIdentityVO) {
    String statement1 = this.getStatement("deleteIdentityVoAndEntries1");
    this.getSqlSessionTemplate().delete(statement1, aclObjectIdentityVO.getId());

    String statement2 = this.getStatement("deleteIdentityVoAndEntries2");
    this.getSqlSessionTemplate().delete(statement2, aclObjectIdentityVO.getId());
  }
  @Override
  public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren)
      throws ChildrenExistException {
    if (deleteChildren) {
      List<ObjectIdentity> list = this.findChildren(objectIdentity);
      if (list != null) {
        for (int i = 0; i < list.size(); i++) {
          deleteAcl(list.get(i), deleteChildren);
        }
      }
    }

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("className", objectIdentity.getType());
    map.put("objectIdIdentity", objectIdentity.getIdentifier());

    String statement = this.getStatement("deleteAcl");
    List<AclObjectIdentity> selectList = this.getSqlSessionTemplate().selectList(statement, map);
    List<Object[]> list = new ArrayList<Object[]>();

    for (AclObjectIdentity vo : selectList) {
      AclClass aclClassVO = vo.getAclClassVO();
      Object[] objArray = {aclClassVO, vo};
      list.add(objArray);
    }

    if (list == null || list.isEmpty()) {
      log.error("数据不存在....");
      return;
    }
    AclObjectIdentity aclObjectIdentityVO = (AclObjectIdentity) list.get(0)[1];

    deleteIdentityVoAndEntries(aclObjectIdentityVO);

    this.aclCache.evictFromCache(objectIdentity);
  }
  @Override
  public MutableAcl createAcl(ObjectIdentity objectIdentity) throws AlreadyExistsException {
    if (isExit(objectIdentity)) {
      return (MutableAcl) super.readAclById(objectIdentity);
    }

    List<AclClass> list = this.findBy("className", objectIdentity.getType());
    AclClass aclClassVo = null;

    AclSid sidVo = null;

    if (list != null && !list.isEmpty()) {
      aclClassVo = list.get(0);
    } else {
      aclClassVo = new AclClass();
      aclClassVo.setClassName(objectIdentity.getType());
      aclClassVo.setId(this.getKeyGen().getUUIDKey());
      this.create(aclClassVo);
    }
    PrincipalSid sid = null;

    List<Role> roles = new ArrayList<Role>();

    roles.addAll(this.getUser().getRoleList());

    sid = new PrincipalSid(roles.get(0).getId());

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("sid", sid.getPrincipal());
    map.put("principal", 0L);

    String statement = this.getStatement("createAcl");
    List<AclSid> listsid = this.getSqlSessionTemplate().selectList(statement, map);

    if (listsid != null && !listsid.isEmpty()) {
      sidVo = listsid.get(0);
    } else {
      sidVo = new AclSid();
      sidVo.setId(this.getKeyGen().getUUIDKey());
      sidVo.setSid(sid.getPrincipal());
      sidVo.setPrincipal(0L);
      this.getSqlSessionTemplate().insert(this.getStatement("insert2"), sidVo);
    }
    if (!StringUtil.isStrEmpty(objectIdentity.getIdentifier().toString())) {
      AclObjectIdentity aclObjectIdentityVO = new AclObjectIdentity();
      aclObjectIdentityVO.setId(this.getKeyGen().getUUIDKey());
      aclObjectIdentityVO.setObjectIdClass(aclClassVo.getId());
      aclObjectIdentityVO.setOwnerSid(sidVo.getId());
      aclObjectIdentityVO.setEntriesInheriting(0L);
      aclObjectIdentityVO.setObjectIdIdentity(objectIdentity.getIdentifier().toString());
      String statement2 = this.getStatement("insert");
      this.getSqlSessionTemplate().insert(statement2, aclObjectIdentityVO);
    }
    return (MutableAcl) super.readAclById(objectIdentity);
  }