本文整理了Java中org.hibernate.criterion.Restrictions.disjunction
方法的一些代码示例,展示了Restrictions.disjunction
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.disjunction
方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称:Restrictions
方法名:disjunction
[英]Group expressions together in a single disjunction (A or B or C...). This form creates an empty disjunction. See Disjunction#add(Criterion)
[中]将表达式组合在一个析取中(a、B或C…)。此窗体创建一个空的析取。参见析取#添加(标准)
代码示例来源:origin: hibernate/hibernate-orm
/**
* Return the disjuction of multiple expressions
*
* @param predicates The predicates making up the initial junction
*
* @return The conjunction
*/
public static Disjunction or(Criterion... predicates) {
return disjunction( predicates );
}
代码示例来源:origin: gocd/gocd
private DetachedCriteria buildModificationDetachedQuery(List<Criterion> criteria) {
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Modification.class);
Disjunction disjunction = Restrictions.disjunction();
detachedCriteria.add(disjunction);
for (Criterion criterion : criteria) {
disjunction.add(criterion);
}
detachedCriteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
return detachedCriteria;
}
代码示例来源:origin: hibernate/hibernate-orm
Restrictions.disjunction()
.add( Restrictions.eq( "integer", f.getInteger() ) )
.add( Restrictions.like( "string", f.getString() ) )
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.CohortDAO#getCohortsContainingPatientId(Integer, boolean, Date)
*/
@Override
@SuppressWarnings("unchecked")
public List<Cohort> getCohortsContainingPatientId(Integer patientId, boolean includeVoided,
Date asOfDate) throws DAOException {
Disjunction orEndDate = Restrictions.disjunction();
orEndDate.add(Restrictions.isNull("m.endDate"));
orEndDate.add(Restrictions.gt("m.endDate", asOfDate));
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Cohort.class);
criteria.createAlias("memberships", "m");
if (asOfDate != null) {
criteria.add(Restrictions.le("m.startDate", asOfDate));
criteria.add(orEndDate);
}
criteria.add(Restrictions.eq("m.patientId", patientId));
criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
if (!includeVoided) {
criteria.add(Restrictions.eq(VOIDED, includeVoided));
}
return criteria.list();
}
代码示例来源:origin: openmrs/openmrs-core
private void addEmptyVisitsByPatientCriteria(Criteria criteria, Patient patient, boolean includeVoided, String query) {
criteria.add(Restrictions.eq("patient", patient));
criteria.add(Restrictions.isEmpty("encounters"));
if (!includeVoided) {
criteria.add(Restrictions.eq("voided", includeVoided));
}
if (query != null && !StringUtils.isBlank(query)) {
criteria.createAlias("visitType", "visitType", JoinType.LEFT_OUTER_JOIN);
criteria.createAlias("location", "location", JoinType.LEFT_OUTER_JOIN);
Disjunction or = Restrictions.disjunction();
criteria.add(or);
or.add(Restrictions.ilike("visitType.name", query, MatchMode.ANYWHERE));
or.add(Restrictions.ilike("location.name", query, MatchMode.ANYWHERE));
}
criteria.addOrder(Order.desc("startDatetime"));
criteria.addOrder(Order.desc("visitId"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* Provides a Hibernate criteria object for searching patients by name, identifier or searchable attribute.
*
* The visibility of this method is "default" as this method should NOT be called directly by classes other
* than org.openmrs.api.db.hibernate.HibernatePatientDAO.
*
* Instead of calling this method consider using {@link org.openmrs.api.PatientService} or
* {@link org.openmrs.api.db.PatientDAO}.
*
* @param query defines search parameters
* @param includeVoided true/false whether or not to included voided patients
* @return criteria for searching by name OR identifier OR searchable attributes
*/
Criteria prepareCriteria(String query, boolean includeVoided) {
addAliasForName(criteria, true);
personSearchCriteria.addAliasForAttribute(criteria);
addAliasForIdentifiers(criteria);
criteria.add(Restrictions.disjunction().add(prepareCriterionForName(query, includeVoided)).add(
prepareCriterionForAttribute(query, includeVoided)).add(
prepareCriterionForIdentifier(query, new ArrayList<>(), false, includeVoided)));
if (!includeVoided) {
criteria.add(Restrictions.eq("voided", false));
}
criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
log.debug(criteria.toString());
return criteria;
}
代码示例来源:origin: openmrs/openmrs-core
Disjunction or = Restrictions.disjunction();
or.add(Restrictions.ilike("identifier", name, getMatchMode()));
or.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE));
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.OrderDAO#getActiveOrders(org.openmrs.Patient, java.util.List,
* org.openmrs.CareSetting, java.util.Date)
*/
@Override
@SuppressWarnings("unchecked")
public List<Order> getActiveOrders(Patient patient, List<OrderType> orderTypes, CareSetting careSetting, Date asOfDate) {
Criteria crit = createOrderCriteria(patient, careSetting, orderTypes, false, false);
crit.add(Restrictions.le("dateActivated", asOfDate));
Disjunction dateStoppedAndAutoExpDateDisjunction = Restrictions.disjunction();
Criterion stopAndAutoExpDateAreBothNull = Restrictions.and(Restrictions.isNull("dateStopped"), Restrictions
.isNull("autoExpireDate"));
dateStoppedAndAutoExpDateDisjunction.add(stopAndAutoExpDateAreBothNull);
Criterion autoExpireDateEqualToOrAfterAsOfDate = Restrictions.and(Restrictions.isNull("dateStopped"), Restrictions
.ge("autoExpireDate", asOfDate));
dateStoppedAndAutoExpDateDisjunction.add(autoExpireDateEqualToOrAfterAsOfDate);
dateStoppedAndAutoExpDateDisjunction.add(Restrictions.ge("dateStopped", asOfDate));
crit.add(dateStoppedAndAutoExpDateDisjunction);
return crit.list();
}
代码示例来源:origin: openmrs/openmrs-core
addAliasForIdentifiers(criteria);
criteria.add(Restrictions.disjunction().add(prepareCriterionForName(query, true, includeVoided)).add(
prepareCriterionForAttribute(query, includeVoided)).add(
prepareCriterionForIdentifier(query, new ArrayList<>(), false, includeVoided)));
代码示例来源:origin: openmrs/openmrs-core
criteria.add(Restrictions.disjunction().add(
Restrictions.and(Restrictions.le("startDate", startEffectiveDate), Restrictions.ge("endDate",
startEffectiveDate))).add(
criteria.add(Restrictions.disjunction().add(
Restrictions.and(Restrictions.le("startDate", endEffectiveDate), Restrictions
.ge("endDate", endEffectiveDate))).add(
代码示例来源:origin: openmrs/openmrs-core
criteria.add(Restrictions.disjunction().add(prepareCriterionForName(name)).add(
prepareCriterionForIdentifier(identifier, identifierTypes, matchIdentifierExactly)));
break;
代码示例来源:origin: openmrs/openmrs-core
private void addEncountersByPatientCriteria(Criteria criteria, Patient patient, boolean includeVoided, String query) {
criteria.add(Restrictions.eq("patient", patient));
criteria.createAlias("visit", "visit", JoinType.LEFT_OUTER_JOIN);
if (!includeVoided) {
criteria.add(Restrictions.eq("voided", includeVoided));
}
if (query != null && !StringUtils.isBlank(query)) {
criteria.createAlias("visit.visitType", "visitType", JoinType.LEFT_OUTER_JOIN);
criteria.createAlias("visit.location", "visitLocation", JoinType.LEFT_OUTER_JOIN);
criteria.createAlias("location", "location", JoinType.LEFT_OUTER_JOIN);
criteria.createAlias("encounterType", "encounterType", JoinType.LEFT_OUTER_JOIN);
Disjunction or = Restrictions.disjunction();
criteria.add(or);
or.add(Restrictions.ilike("visitType.name", query, MatchMode.ANYWHERE));
or.add(Restrictions.ilike("visitLocation.name", query, MatchMode.ANYWHERE));
or.add(Restrictions.ilike("location.name", query, MatchMode.ANYWHERE));
or.add(Restrictions.ilike("encounterType.name", query, MatchMode.ANYWHERE));
}
criteria.addOrder(Order.desc("visit.startDatetime"));
criteria.addOrder(Order.desc("visit.visitId"));
criteria.addOrder(Order.desc("encounterDatetime"));
criteria.addOrder(Order.desc("encounterId"));
}
代码示例来源:origin: openmrs/openmrs-core
private Criterion getCriterionForLongName(String name, boolean includeVoided) {
MatchMode matchMode = getMatchMode();
Criterion criterion = Restrictions.disjunction().add(Restrictions.like("name.givenName", name, matchMode)).add(
Restrictions.like("name.middleName", name, matchMode))
.add(Restrictions.like("name.familyName", name, matchMode)).add(
Restrictions.like("name.familyName2", name, matchMode));
if (!includeVoided) {
return Restrictions.conjunction().add(Restrictions.eq("name.voided", false)).add(criterion);
}
return criterion;
}
代码示例来源:origin: openmrs/openmrs-core
private Criterion getCriterionForShortName(String name, boolean includeVoided) {
Criterion criterion = Restrictions.disjunction().add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.givenName")).add(
Restrictions.eq("name.givenName", name).ignoreCase())).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.middleName")).add(
Restrictions.eq("name.middleName", name).ignoreCase())).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.familyName")).add(
Restrictions.eq("name.familyName", name).ignoreCase())).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.familyName2")).add(
Restrictions.eq("name.familyName2", name).ignoreCase()));
if (!includeVoided) {
return Restrictions.conjunction().add(Restrictions.eq("name.voided", false)).add(criterion);
}
return criterion;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* Creates or that matches the input name with Provider-Person-Names (not voided)
*
* @param name
* @return Junction
*/
private Junction getNameSearchExpression(String name) {
MatchMode mode = MatchMode.ANYWHERE;
Conjunction and = Restrictions.conjunction();
and.add(Restrictions.eq("personName.voided", false));
Disjunction or = Restrictions.disjunction();
and.add(or);
or.add(Restrictions.ilike("personName.givenName", name, mode));
or.add(Restrictions.ilike("personName.middleName", name, mode));
or.add(Restrictions.ilike("personName.familyName", name, mode));
or.add(Restrictions.ilike("personName.familyName2", name, mode));
return and;
}
代码示例来源:origin: openmrs/openmrs-core
Criterion prepareCriterionForName(String value, Boolean voided) {
if (voided == null || !voided) {
return Restrictions.conjunction().add(Restrictions.eq("name.voided", false)).add(
Restrictions.disjunction().add(Restrictions.ilike("name.givenName", value, MatchMode.START)).add(
Restrictions.ilike("name.middleName", value, MatchMode.START)).add(
Restrictions.ilike("name.familyName", value, MatchMode.START)).add(
Restrictions.ilike("name.familyName2", value, MatchMode.START)));
} else {
return Restrictions.conjunction().add(
Restrictions.disjunction().add(Restrictions.ilike("name.givenName", value, MatchMode.START)).add(
Restrictions.ilike("name.middleName", value, MatchMode.START)).add(
Restrictions.ilike("name.familyName", value, MatchMode.START)).add(
Restrictions.ilike("name.familyName2", value, MatchMode.START)));
}
}
代码示例来源:origin: openmrs/openmrs-core
criteria.createAlias("person.names", "personName", JoinType.LEFT_OUTER_JOIN);
Disjunction or = Restrictions.disjunction();
or.add(Restrictions.ilike("loc.name", query, mode));
or.add(Restrictions.ilike("encType.name", query, mode));
Disjunction nameOr = Restrictions.disjunction();
for (String splitName : splitNames) {
nameOr.add(Restrictions.ilike("personName.givenName", splitName, mode));
代码示例来源:origin: openmrs/openmrs-core
private Criterion getCriterionForNoExactName(String name, boolean includeVoided) {
MatchMode matchMode = getMatchMode();
Criterion criterion = Restrictions.conjunction().add(
Restrictions.disjunction().add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.givenName")).add(
Restrictions.like("name.givenName", name, matchMode))).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.middleName")).add(
Restrictions.like("name.middleName", name, matchMode))).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.familyName")).add(
Restrictions.like("name.familyName", name, matchMode))).add(
Restrictions.conjunction().add(Restrictions.isNotNull("name.familyName2")).add(
Restrictions.like("name.familyName2", name, matchMode)))).add(
Restrictions.disjunction().add(Restrictions.isNull("name.givenName")).add(
Restrictions.ne("name.givenName", name))).add(
Restrictions.disjunction().add(Restrictions.isNull("name.middleName")).add(
Restrictions.ne("name.middleName", name))).add(
Restrictions.disjunction().add(Restrictions.isNull("name.familyName")).add(
Restrictions.ne("name.familyName", name))).add(
Restrictions.disjunction().add(Restrictions.isNull("name.familyName2")).add(
Restrictions.ne("name.familyName2", name)));
if (!includeVoided) {
return Restrictions.conjunction().add(Restrictions.eq("name.voided", false)).add(criterion);
}
return criterion;
}
代码示例来源:origin: uk.ac.ebi.intact.core/intact-core
public List<T> getByObjClass( Class[] objClasses ) {
Criteria criteria = getSession().createCriteria( CvObject.class );
Disjunction disj = Restrictions.disjunction();
for ( Class objClass : objClasses ) {
disj.add( Restrictions.eq( "objClass", objClass.getName() ) );
}
criteria.add( disj );
return criteria.list();
}
代码示例来源:origin: denimgroup/threadfix
@SuppressWarnings("unchecked")
@Override
public List<VulnerabilityFilter> retrieveAllEffective(int orgId, int appId) {
return getBaseCriteria()
.add(Restrictions.disjunction()
.add(eq("application.id", appId))
.add(eq("organization.id", orgId))
.add(eq("global", true))
)
.list();
}
内容来源于网络,如有侵权,请联系作者删除!