Richard Wallace wrote: > > Alright, it sounds like there are a couple of approaches that I can > explore. > 1) Passing a list of parameters to the DAOs and let them build the > criteria or query to be executed. One interesting thing here is that I > could actually use some query by example kind of thing and then just use > Hibernates query by example capabilities. Otherwise, this is probably > going to be something like a list of some kind of object that > encapsulates the property, the operation and the value to do the > filtering with. This would limit me to doing only disjunctions and > conjunctions, but it does put all the data access specific logic in the > DAOs where they should be. > > 2) Expose a Search component that is specific to the underlying data > access method being used. This would be separate from all the other > service and DAO components. Then a set of search functionality in JSF > would just use that Search component to do whatever it needs. In the > case of a Hibernate search component it would need to pass > DetachedCriteria. This probably isn't the cleanest solution but it is > probably the most flexible and it does centralize where changes need to > be made in order to perform searches. One plus is that this Search > component would be easy to use across projects. > > I think I'm going to try out the 2nd approach first because it does give > me the most flexibility and will be the quickest to implement. What do > you think? > Well from a pure academic standpoint #2 would be a no go, but heck give it a try, in the end getting the expected results is what counts and the customer does not appreciate the extra work you have to do for a clean isolation of concern in many cases. I sometimes break the clean BO/DAO structure in some cases to get the results as fast as possible, the key is not to do it too often you might end up in a huge mess that way.
I still probably would try approach #1 however if moving from one orm solution to the other is a huge concern, but you cannot cover every situation like that in a clean way.

