Create your search object: to make it distinct from DetachedCriteria, I'll call it SearchObject. It extends DetachedCriteria, or at least includes a private DetachedCriteria instance. Importantly, it includes all your application-specific methods like "compareName(String first, String last)", or "beforeDate(Date date)". These methods know about hibernate property names, when to use Restrictions.eq versus Restrictions.ilike, etc. And if you ever abandon Hibernate, you still have your SearchObject with its application-specific methods: you can convert it to whatever new technology you're using instead of Hibernate.
_________________ Code tags are your friend. Know them and use them.
|