org.hibernate.criterion.Restrictions.conjunction()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中org.hibernate.criterion.Restrictions.conjunction方法的一些代码示例,展示了Restrictions.conjunction的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.conjunction方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称:Restrictions
方法名:conjunction

Restrictions.conjunction介绍

[英]Group expressions together in a single conjunction (A and B and C...). This form creates an empty conjunction. See Conjunction#add(Criterion)
[中]将表达式组合在一个连词中(a、B和C…)。这种形式创造了一个空的连词。参见连词#添加(标准)

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Return the conjuction of multiple expressions
 *
 * @param predicates The predicates making up the initial junction
 *
 * @return The conjunction
 */
public static Conjunction and(Criterion... predicates) {
  return conjunction( predicates );
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Apply an "equals" constraint to each property in the key set of a <tt>Map</tt>
 *
 * @param propertyNameValues a map from property names to values
 *
 * @return Criterion
 *
 * @see Conjunction
 */
@SuppressWarnings("UnusedDeclaration")
public static Criterion allEq(Map<String,?> propertyNameValues) {
  final Conjunction conj = conjunction();
  for ( Map.Entry<String,?> entry : propertyNameValues.entrySet() ) {
    conj.add( eq( entry.getKey(), entry.getValue() ) );
  }
  return conj;
}

代码示例来源:origin: openmrs/openmrs-core

Criterion prepareCriterionForAttribute(String value, Boolean voided, MatchMode matchMode) {
  if (voided == null || !voided) {
    return Restrictions.conjunction().add(Restrictions.eq("attributeType.searchable", true)).add(
      Restrictions.eq("attribute.voided", false)).add(Restrictions.ilike("attribute.value", value, matchMode));
  } else {
    return Restrictions.conjunction().add(Restrictions.eq("attributeType.searchable", true)).add(
      Restrictions.ilike("attribute.value", value, matchMode));
  }
}

代码示例来源:origin: openmrs/openmrs-core

name = HibernateUtil.escapeSqlWildcards(name, sessionFactory);
Conjunction conjunction = Restrictions.conjunction();
String[] nameParts = getQueryParts(name);
if (nameParts.length > 0) {

代码示例来源: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

/**
 * Adds attribute value criteria to the given criteria query
 * 
 * @param criteria the criteria
 * @param serializedAttributeValues the serialized attribute values
 * @param <AT> the attribute type
 */
public static <AT extends AttributeType> void addAttributeCriteria(Criteria criteria,
    Map<AT, String> serializedAttributeValues) {
  Conjunction conjunction = Restrictions.conjunction();
  int a = 0;
  
  for (Map.Entry<AT, String> entry : serializedAttributeValues.entrySet()) {
    String alias = "attributes" + (a++);
    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Location.class).setProjection(Projections.id());
    detachedCriteria.createAlias("attributes", alias);
    detachedCriteria.add(Restrictions.eq(alias + ".attributeType", entry.getKey()));
    detachedCriteria.add(Restrictions.eq(alias + ".valueReference", entry.getValue()));
    detachedCriteria.add(Restrictions.eq(alias + ".voided", false));
    
    conjunction.add(Property.forName("id").in(detachedCriteria));
  }
  
  criteria.add(conjunction);
}

代码示例来源:origin: openmrs/openmrs-core

private Criterion prepareCriterionForAttribute(String query, boolean includeVoided) {
    query = HibernateUtil.escapeSqlWildcards(query, sessionFactory);
    
    Conjunction conjunction = Restrictions.conjunction();
    MatchMode matchMode = personSearchCriteria.getAttributeMatchMode();
    
    String[] queryParts = getQueryParts(query);
    for (String queryPart : queryParts) {
      conjunction.add(personSearchCriteria.prepareCriterionForAttribute(queryPart, includeVoided, matchMode));
    }
    
    return conjunction;
  }
}

代码示例来源:origin: openmrs/openmrs-core

or.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE));
Conjunction and = Restrictions.conjunction();
or.add(and);

代码示例来源:origin: openmrs/openmrs-core

criteria.add(Restrictions.conjunction().add(prepareCriterionForName(query, null, includeVoided)).add(
  Restrictions.not(prepareCriterionForName(query, true, includeVoided))).add(
  Restrictions.not(prepareCriterionForName(query, false, includeVoided))));

代码示例来源: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

Conjunction conjunction = Restrictions.conjunction();

代码示例来源: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

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: openmrs/openmrs-core

Conjunction personNameConjuction = Restrictions.conjunction();
personNameConjuction.add(Restrictions.eq("personName.voided", false));
personNameConjuction.add(nameOr);

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

@Override
  public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.Conjunction criterion, String alias) {
    Conjunction conjunction = Restrictions.conjunction();
    applySubCriteriaToJunction(hibernateQuery.getEntity(), hibernateQuery, criterion.getCriteria(), conjunction, alias);
    return conjunction;
  }
});

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

public Criterion evaluate(Object paramValue) {
 Conjunction conj = Restrictions.conjunction();
 if (!StringUtils.isEmpty(property.getNamespace())) {
  conj.add(Restrictions.eq(PROPERTY_NS_DB_FIELD, property.getNamespace()));
 }
 conj.add(Restrictions.eq(PROPERTY_NAME_DB_FIELD, property.getName()));
 conj.add(Restrictions.eq(PROPERTY_VALUE_DB_FIELD, eq.getValue().getValue()));
 return conj;
};

代码示例来源:origin: com.weicoder/dao

@Override
public <E> List<E> in(Class<E> entityClass, Map<String, List<Object>> parames, int firstResult, int maxResults) {
  // 获得Conjunction AND 条件
  Conjunction conj = Restrictions.conjunction();
  // 循环赋值in
  parames.forEach((k, v) -> conj.add(Restrictions.in(k, v)));
  // 查询结果
  return queryCriteria(entityClass, DetachedCriteria.forClass(entityClass).add(conj), firstResult, maxResults);
}

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

public Criterion evaluate(Object paramValue) {
 Conjunction conj = Restrictions.conjunction();
 if (!StringUtils.isEmpty(property.getNamespace())) {
  conj.add(Restrictions.gt(PROPERTY_NS_DB_FIELD, property.getNamespace()));
 }
 conj.add(Restrictions.gt(PROPERTY_NAME_DB_FIELD, property.getName()));
 conj.add(Restrictions.gt(PROPERTY_VALUE_DB_FIELD, gt.getValue().getValue()));
 return conj;
};

代码示例来源:origin: org.wso2.bpel/ode-dao-hibernate

public Criterion evaluate(Object paramValue) {
 Conjunction conj = Restrictions.conjunction();
 if (!StringUtils.isEmpty(property.getNamespace())) {
  conj.add(Restrictions.like(PROPERTY_NS_DB_FIELD, property.getNamespace()));
 }
 conj.add(Restrictions.like(PROPERTY_NAME_DB_FIELD, property.getName()));
 conj.add(Restrictions.like(PROPERTY_VALUE_DB_FIELD, like.getValue().getValue()));
 return conj;
};

相关文章