I am trying to query with multiple criteria:
1. I would like to use the the parameter, statementNumber, that is passed in the getCaseByStatemetnNumber(String statementNumber) { ... } method call
2.
Using the "
statementNumber", I am searching for the "caseStatus" that is
either "open"
or "closed-unpaid".
I have the code below but have not yet managed to get the query correct. I am writing to seek help. Thank you.
Code:
.....
.....
public void populateCritieria(final Map<? extends Enum<?>, Object> searchCriteria,
final Criteria criteria)
{
if (searchCriteria.containsKey(CaseSearchType.statementNumber))
{
criteria.add(Restrictions.eq("statementNumber", searchCriteria.get(CaseSearchType.statementNumber)));
}
if (searchCriteria.containsKey(CaseSearchType.caseStatus))
{
criteria.add(Restrictions.eq("caseStatus", searchCriteria.get(CaseSearchType.caseStatus)));
}
}
public Case getCaseByStatementNumber(String statementNumber)
{
Map<CaseSearchType,Object> searchCriteria = new HashMap<CaseSearchType,Object>();
searchCriteria.put(CaseSearchType.statementNumber, statementNumber);
searchCriteria.put(CaseSearchType.caseStatus, "open");
searchCriteria.put(CaseSearchType.caseStatus, "closed-unpaid");
return search(searchCriteria,Case.class);
}
...
...