Criteria criteria = session.createCriteria(Permission.class);
if(right != null) {
criteria.add(Restrictions.eq("right", right));
}
if(resource != null) {
DefaultPermisibleResource defaultResource = new DefaultPermisibleResource(resource);
criteria.add(Restrictions.eq("resource", defaultResource));
}
if(entity != null) {
DefaultPermissionEntity defaultEntity = new DefaultPermissionEntity(entity);
criteria.add(Restrictions.eq("entity", defaultEntity));