Hi,
I'm having trouble formulating a query with criteria. I'd like users to enter a search term, and have it check the term against User.first_name, User.last_name, and User.company.company_name. (company is a many-to-one property of User that returns a Company object).
This works without the company name:
Code:
c.add(
Expression.or (
Expression.like( "first_name","%" + filter.getQuick_search() + "%"),
Expression.like( "last_name","%" + filter.getQuick_search() + "%")
)
);
but this gives an error.
Code:
c.add(
Expression.or (
Expression.like( "first_name","%" + filter.getQuick_search() + "%"),
Expression.or (
Expression.like( "last_name","%" + filter.getQuick_search() + "%"),
Expression.like( "company.company_name","%" + filter.getQuick_search() + "%")
)
)
);
Reading the docs, it looks like I need a "createCriteria" but I can't figure out where to put it.
Any suggestions? I'd like to use the Criteria object for querying since I have a filter with a number of properties that can all optionally be applied.
WILL