Search in sources :

Example 31 with OrderByField

use of org.jaffa.components.finder.OrderByField in project jaffa-framework by jaffa-projects.

the class GraphCriteria method returnQueryClause.

/**
 * Return the real retrieve clause that will be executed for this query.
 * <p>
 * When this is used for a sub-query, a nestedClause will be passed in that
 * will already have the table name set, and have criteria that will limit
 * the query to only retrive child records of the already retrieved parent record.
 * <p>
 * THIS MUST BE OVERRIDDEN BY THE SUPERCLASS
 * <p>
 * The abstract implementation can be used to initially create a Criteria object
 * populated with the default fields on the base class (start, limit, orderBy)
 * <p>
 * If you are having issues with flexCriteriaBean results missing from the generated criteria,
 * then you may need redirect the caller to invoke buildQueryCriteria as opposed to this method.
 * See the notes for buildQueryCriteria for more information!
 *
 * @param nestedClause Minimal criteria used to retrieve the nested object. Will be null for the root query.
 * @return return the generated clause
 */
public Criteria returnQueryClause(Criteria nestedClause) {
    Criteria c = new Criteria();
    // append an orderBy clause to the criteria
    if (getOrderByFields() != null) {
        for (OrderByField orderByField : getOrderByFields()) {
            int sort = Criteria.ORDER_BY_ASC;
            if (orderByField.getSortAscending() != null && !orderByField.getSortAscending())
                sort = Criteria.ORDER_BY_DESC;
            c.addOrderBy(orderByField.getFieldName(), sort);
        }
    }
    c.setFirstResult(getObjectStart());
    c.setMaxResults(getObjectLimit());
    return c;
}
Also used : OrderByField(org.jaffa.components.finder.OrderByField) Criteria(org.jaffa.persistence.Criteria)

Aggregations

OrderByField (org.jaffa.components.finder.OrderByField)31 Criteria (org.jaffa.persistence.Criteria)28 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)27 StringCriteriaField (org.jaffa.components.finder.StringCriteriaField)2 BusinessEventLogFinderInDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderInDto)2 BusinessEventLogFinderTx (org.jaffa.modules.messaging.components.businesseventlogfinder.tx.BusinessEventLogFinderTx)2 BusinessEventLogFinderOutDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutDto)1