Hi all
So we are constructing a query based on a user profile; for each attribute in the profile, we add criteria used to filter a search on another table.
the method that does this looks like
Code:
DetachedCriteria dc = new ...
addFooCriteria(dc, profile)
addBarCriteria(dc, profile)
where each add method contains
Code:
if (profile.foo) // or bar, or baz...
{
dc.add...
}
everything was going splendid until I noticed under certain conditions, we want our where clause to look like
WHERE (overriding profile condition) OR (foo condition AND bar condition ...) ...
of course disjuction will put an OR on the WHERE clause, however, since we construct the query as we go thru the profile attributes, criteria added in the different methods are put at the "root" level of the where clause, not in the elements of the disjuction.
is there any way to overcome this?
edit
Ive made progress; the add methods now add to a conjuction.
the remaining problem is adding a DetachedCriteria to the conjunction.
sometimes we have to do a 3 way join because certain fields on which we search are normalized out of the main searchable table. before adding the disjunction we were
Code:
criteria.createCriteria("subTable").createCriteria("subSubTable")
.add(
Restrictions.not(Property.forName("accessStatus").in(
accessStatusExclude)));
doesnt seem like anything like that is addable to a junction.
Help Please!!!