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);
}
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);
}
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;
}
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);
}
}
}
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;
}
Aggregations