filter.toCreteia()
) and return List of results.
public interface IFilter {
Creteria toCriteria();
}
I want to make the DAO api to always as for filter + securityFilter in every method.
List getAll(IFilter filter, IFilter security); //each filter will be a creteria in the end
I end up inside the dao with 2 creterias: regular filter and security filter.
how can i render 2 creteias for returning one List of results?Or, do you think I should use only one filter and in the API layer add security content to it?
Unless you want to go with an interceptor approach (e.g., have a SecurityInterceptor/proxy class which transparently modifies the criteria) I think it would be nicer design to have two separate filters.
Note that I don't see that it is possible to join two DetachedCriteria
objects together. Although you can have a routine which based on two IFilter
objects returns a single DetachedCriteria
based e.g. on Restrictions.and(criterion1, criterion2)
.
精彩评论