Search in sources :

Example 11 with Criterion

use of org.hibernate.criterion.Criterion in project hibernate-orm by hibernate.

the class TestSpatialRestrictions method isEmpty.

@Test
public void isEmpty() throws SQLException {
    if (!isSupportedByDialect(SpatialFunction.isempty)) {
        return;
    }
    Map<Integer, Boolean> dbexpected = expectationsFactory.getIsEmpty();
    Criterion spatialCriterion = SpatialRestrictions.isEmpty("geom");
    retrieveAndCompare(dbexpected, spatialCriterion);
}
Also used : Criterion(org.hibernate.criterion.Criterion) Test(org.junit.Test)

Example 12 with Criterion

use of org.hibernate.criterion.Criterion in project hibernate-orm by hibernate.

the class TestSpatialRestrictions method havingSRID.

@Test
public void havingSRID() throws SQLException {
    if (!isSupportedByDialect(SpatialFunction.srid)) {
        return;
    }
    Map<Integer, Boolean> dbexpected = expectationsFactory.havingSRID(4326);
    Criterion spatialCriterion = SpatialRestrictions.havingSRID("geom", 4326);
    retrieveAndCompare(dbexpected, spatialCriterion);
    dbexpected = expectationsFactory.havingSRID(31370);
    spatialCriterion = SpatialRestrictions.havingSRID("geom", 31370);
    retrieveAndCompare(dbexpected, spatialCriterion);
}
Also used : Criterion(org.hibernate.criterion.Criterion) Test(org.junit.Test)

Example 13 with Criterion

use of org.hibernate.criterion.Criterion in project dhis2-core by dhis2.

the class HibernateMinMaxDataElementStore method parseFilter.

private Criteria parseFilter(Criteria criteria, List<String> filters) {
    Conjunction conjunction = Restrictions.conjunction();
    Schema schema = schemaService.getDynamicSchema(MinMaxDataElement.class);
    if (!filters.isEmpty()) {
        for (String filter : filters) {
            String[] split = filter.split(":");
            if (split.length != 3) {
                throw new QueryParserException("Invalid filter: " + filter);
            }
            QueryPath queryPath = queryPlanner.getQueryPath(schema, split[0]);
            Property property = queryParser.getProperty(schema, split[0]);
            Criterion restriction = getRestriction(property, queryPath.getPath(), split[1], split[2]);
            if (restriction != null) {
                conjunction.add(restriction);
                if (queryPath.haveAlias()) {
                    for (String alias : queryPath.getAlias()) {
                        criteria.createAlias(alias, alias);
                    }
                }
            }
        }
    }
    criteria.add(conjunction);
    return criteria;
}
Also used : QueryPath(org.hisp.dhis.query.planner.QueryPath) QueryParserException(org.hisp.dhis.query.QueryParserException) Criterion(org.hibernate.criterion.Criterion) Schema(org.hisp.dhis.schema.Schema) Conjunction(org.hibernate.criterion.Conjunction) Property(org.hisp.dhis.schema.Property)

Example 14 with Criterion

use of org.hibernate.criterion.Criterion in project dhis2-core by dhis2.

the class CriteriaQueryEngine method addJunction.

private void addJunction(org.hibernate.criterion.Junction junction, org.hisp.dhis.query.Criterion criterion) {
    if (Restriction.class.isInstance(criterion)) {
        Restriction restriction = (Restriction) criterion;
        Criterion hibernateCriterion = getHibernateCriterion(restriction);
        if (hibernateCriterion != null) {
            junction.add(hibernateCriterion);
        }
    } else if (Junction.class.isInstance(criterion)) {
        org.hibernate.criterion.Junction j = null;
        if (Disjunction.class.isInstance(criterion)) {
            j = Restrictions.disjunction();
        } else if (Conjunction.class.isInstance(criterion)) {
            j = Restrictions.conjunction();
        }
        junction.add(j);
        for (org.hisp.dhis.query.Criterion c : ((Junction) criterion).getCriterions()) {
            addJunction(junction, c);
        }
    }
}
Also used : Criterion(org.hibernate.criterion.Criterion)

Example 15 with Criterion

use of org.hibernate.criterion.Criterion in project dhis2-core by dhis2.

the class HibernateGenericStore method getCriteria.

/**
     * Creates a Criteria for the implementation Class type restricted by the
     * given Criterions.
     *
     * @param expressions the Criterions for the Criteria.
     * @return a Criteria instance.
     */
protected final Criteria getCriteria(Criterion... expressions) {
    Criteria criteria = getCriteria();
    for (Criterion expression : expressions) {
        criteria.add(expression);
    }
    criteria.setCacheable(cacheable);
    return criteria;
}
Also used : Criterion(org.hibernate.criterion.Criterion) Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Aggregations

Criterion (org.hibernate.criterion.Criterion)27 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)7 List (java.util.List)6 RootMap (com.cosylab.cdb.jdal.hibernate.RootMap)5 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 LinkedList (java.util.LinkedList)5 Map (java.util.Map)5 Session (org.hibernate.Session)5 Criteria (org.hibernate.Criteria)4 Field (java.lang.reflect.Field)3 Method (java.lang.reflect.Method)3 Component (alma.acs.tmcdb.Component)2 Container (alma.acs.tmcdb.Container)2 Comparator (java.util.Comparator)2 IrrelevantEntity (org.hibernate.IrrelevantEntity)2 SessionFactory (org.hibernate.SessionFactory)2 Configuration (org.hibernate.cfg.Configuration)2 DetachedCriteria (org.hibernate.criterion.DetachedCriteria)2