if (dateEndContract != null) { criteria.addLessOrEqualThan("contractRegimes.dateEndContract", dateEndContract); }
    public List readAllContractsByCriteria(String orderBy, Boolean justActiveContracts,            Boolean justDesactiveContracts, Date dateBeginContract, Date dateEndContract,            Integer spanNumber, Integer numberOfElementsInSpan, Integer grantTypeId) {        Criteria criteria = new Criteria();        criteria.addEqualTo("contractRegimes.state", new Integer(1));        if (justActiveContracts != null && justActiveContracts.booleanValue()) {            criteria.addGreaterOrEqualThan("contractRegimes.dateEndContract", Calendar.getInstance()                    .getTime());            criteria.addEqualTo("endContractMotive", "");        }        if (justDesactiveContracts != null && justDesactiveContracts.booleanValue()) {            criteria.addLessOrEqualThan("contractRegimes.dateEndContract", Calendar.getInstance()                    .getTime());            criteria.addNotEqualTo("endContractMotive", "");        }        if (dateBeginContract != null) {            criteria.addGreaterOrEqualThan("contractRegimes.dateBeginContract", dateBeginContract);        }        if (dateEndContract != null) {            criteria.addLessOrEqualThan("contractRegimes.dateEndContract", dateEndContract);        }        if (grantTypeId != null) {            criteria.addEqualTo("grantType.idInternal", grantTypeId);        }        return readBySpanAndCriteria(spanNumber, numberOfElementsInSpan, criteria, orderBy, true);    }