use of org.jaffa.transaction.apis.data.TransactionCriteria in project jaffa-framework by jaffa-projects.
the class JaffaTransactionMessageService method findByFieldValueOrderByCreatedOnDesc.
/**
* Gets all Transactions with the input field-value and returns them ordered descending by the createdOn parameter.
*
* @param field the field to check the value of
* @param value the input value of the field we are looking for
* @return all Transactions with the input field-value and returns them ordered by the createdOn parameter
* @throws FrameworkException
*/
@Override
public List<Transaction> findByFieldValueOrderByCreatedOnDesc(String field, String value) throws FrameworkException {
UOW uow = null;
List<Transaction> transactions = new ArrayList<Transaction>();
try {
uow = new UOW();
Criteria transactionCriteria = new Criteria();
transactionCriteria.setTable(TransactionMeta.getName());
Criteria joinCriteria = new Criteria();
joinCriteria.setTable(TransactionFieldMeta.getName());
joinCriteria.addInnerCriteria(TransactionFieldMeta.TRANSACTION_ID, TransactionMeta.ID);
joinCriteria.addCriteria(TransactionFieldMeta.FIELD_NAME, field);
joinCriteria.addCriteria(TransactionFieldMeta.VALUE, value);
transactionCriteria.addAggregate(joinCriteria);
transactionCriteria.addOrderBy(TransactionMeta.CREATED_ON);
for (Object result : uow.query(transactionCriteria)) {
if (!(result instanceof Transaction)) {
continue;
}
transactions.add((Transaction) result);
}
} finally {
if (uow != null) {
uow.close();
}
}
return transactions;
}
Aggregations