I have a domain repository IRestaurantRepository, which is being used for all query purposes on the Restaurant domain entity. Now the implementation of the repository is based on Hibernate and JPA - I am fine with that. But, if I want to give the users a flexibility to compose his own query criteria (which is often the case with rich query screens), I have to expose Hibernate Criteria object to the client in the interface IRestaurantRepository. e.g.
I don't like this idea of exposing Hibernate classes in my domain interface. I tried with Hibernate Example class, passing the POJO Restaurant in the contract and cooking up the query with the help of Example (Query By Example) in the implementation. But again, Example is messy when we deal with nested properties being set in the POJO.Code:interface IRestaurantRepository { // finders List<Restaurant> find(final DetachedCriteria cri); // other finders }
Any solutions, best practices ?
Thanks.
- Debasish


Reply With Quote
