@Override
@Transactional
public <T extends DomainEntity> List<T> find(Class<T> entityClass, int offset, int max) {
Assert.notNull(entityClass);
if (AbstractOwnedDomainEntity.class.isAssignableFrom(entityClass)) {
User user = getCurrentUser();
Map<String, Object> parameters = new HashMap<String, Object>(1);
parameters.put("owner", user != null && user.isAnonymous() ? null : user);
return findByQuery("SELECT e FROM " + entityClass.getSimpleName() + " e WHERE ( ( e.publicView = true ) OR ( :owner IN ELEMENTS(e.viewers) ) )", offset, max, parameters);
} else {
return super.find(entityClass, offset, max);
}
}