开发者

hibernate design issue

开发者 https://www.devze.com 2023-02-11 07:20 出处:网络
I have a c开发者_如何学JAVAustom filter for querying the database. The API layer build the filter,send it to the dao layer and the dao execute the filter (filter.toCreteia()) and return List of resul

I have a c开发者_如何学JAVAustom filter for querying the database.

The API layer build the filter,send it to the dao layer and the dao execute the filter (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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号