I've searched for something similar to DetachedCriteria for a query-by-example (QBE) that uses an instance of Example (to get the functionality of ignoreCase, enableLike, etc.). There does not appear to be a DetachedExample class, which would allow a third tier client to formulate a query using an Example.
The Example class is not easily extended... and there does not appear to be an interface for Example. The Example class leaves one without the ability to determine the QBE's entity class, since there are no accessors to the referenced example object or its class. Using vanilla Example, one would have to have an extra Class parameter to pass in a method.
A similar issue arises for Native SQL queries when detached. Is there a way to compose the query "off-line" and pass the query across tiers in a manner similar to DetachedCriteria?
Maybe I've missed these classes or an alternative approach to these problems. Any suggestions welcome.
P.S. For detached Example QBE, I am considering cloning Example into a DetachedExample class that is explicitly Serializable and can respond to getEntityClass().
|