persistenceService.setQuery("from inode in class com.dotmarketing.beans.Permission where inode_id = ? and roleid = ? and " +
"permission_type = ?");
persistenceService.setParam(p.getInode());
persistenceService.setParam(p.getRoleId());
persistenceService.setParam(p.getType());
Permission bitPermission = (Permission) persistenceService.load();
if (bitPermission != null) {
bitPermission.setPermission((bitPermission.getPermission() ^ p.getPermission()) & bitPermission.getPermission());
if (bitPermission.getPermission() == 0)
HibernateUtil.delete(bitPermission);
else