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

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

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

Restrictions.not介绍

[英]Return the negation of an expression
[中]返回表达式的否定

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
public List<EndpointProfileSchema> findVacantSchemas(String appId, List<String> usedSchemaIds) {
 LOG.debug("Searching vacant schemas by application id [{}] and used schema ids [{}] ",
     appId, usedSchemaIds);
 List<EndpointProfileSchema> schemas = Collections.emptyList();
 if (isNotBlank(appId)) {
  Criteria criteria = getCriteria().createAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS)
    .add(Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)));
  if (usedSchemaIds != null && !usedSchemaIds.isEmpty()) {
   criteria.add(Restrictions.not(Restrictions.in(ID_PROPERTY, toLongIds(usedSchemaIds))));
  }
  schemas = findListByCriteria(criteria);
 }
 if (LOG.isTraceEnabled()) {
  LOG.trace("[{}] Search result: {}.", appId, Arrays.toString(schemas.toArray()));
 } else {
  LOG.debug("[{}] Search result: {}.", appId, schemas.size());
 }
 return schemas;
}

代码示例来源:origin: kaaproject/kaa

/**
 * Check if email already occupied. Return user with the same email or null if email not occupied.
 *
 * @param mail is user's mail
 * @param userId is user's id
 * @return user with the same email or null if email not occupied
 */
public User checkEmailOccupied(String mail, Long userId) {
 Criteria criteria = getCriteria();
 Criterion mailCriterion = Restrictions.eq(MAIL_PROPERTY, mail);
 if (userId != null) {
  criteria.add(Restrictions.and(
    mailCriterion, Restrictions.not(Restrictions.eq(ID_PROPERTY, userId))));
 } else {
  criteria.add(mailCriterion);
 }
 return (User) criteria.uniqueResult();
}

代码示例来源:origin: kaaproject/kaa

@Override
public List<ConfigurationSchema> findVacantSchemas(String appId, List<String> usedSchemaIds) {
 LOG.debug("Searching vacant schemas by application id [{}] ", appId);
 List<ConfigurationSchema> schemas = Collections.emptyList();
 if (isNotBlank(appId)) {
  List<Long> lids = toLongIds(usedSchemaIds);
  if (lids.isEmpty()) {
   schemas = findListByCriterionWithAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS,
     Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)));
  } else {
   schemas = findListByCriterionWithAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS,
     Restrictions.and(
       Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)),
       Restrictions.not(Restrictions.in(ID_PROPERTY, lids))));
  }
 }
 if (LOG.isTraceEnabled()) {
  LOG.trace("[{}] Search result: {}.", appId, Arrays.toString(schemas.toArray()));
 } else {
  LOG.debug("[{}] Search result: {}.", appId, schemas.size());
 }
 return schemas;
}

代码示例来源:origin: kaaproject/kaa

/**
 * Check if username already occupied. Return user with the same username or null if username not
 * occupied.
 *
 * @param userName is sername
 * @param userId   is user's id
 * @return user with the same username or null if email not occupied
 */
public User checkUserNameOccupied(String userName, Long userId) {
 Criteria criteria = getCriteria();
 Criterion usernameCriterion = Restrictions.eq(USERNAME_PROPERTY, userName);
 if (userId != null) {
  criteria.add(
    Restrictions.and(
      usernameCriterion, Restrictions.not(Restrictions.eq(ID_PROPERTY, userId))));
 } else {
  criteria.add(usernameCriterion);
 }
 return (User) criteria.uniqueResult();
}

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

@Test
@SkipForDialect( value = SybaseASE15Dialect.class, jiraKey = "HHH-4580")
public void testJunctionNotExpressionQBE() throws Exception {
  deleteData();
  initData();
  Session s = openSession();
  Transaction t = s.beginTransaction();
  Componentizable master = getMaster("hibernate", null, "ope%");
  Criteria crit = s.createCriteria(Componentizable.class);
  Example ex = Example.create(master).enableLike();
  crit.add(Restrictions.or(Restrictions.not(ex), ex));
  List result = crit.list();
  assertNotNull(result);
  assertEquals(2, result.size());
  t.commit();
  s.close();
}

代码示例来源:origin: bill1012/AdminEAP

@Override
  public DetachedCriteria getCriteria(DetachedCriteria criteria, String key, Object value)
      throws QueryException {
    criteria.add(Restrictions.not(Restrictions.eq(key, value)));
    return criteria;
  }
};

代码示例来源:origin: bill1012/AdminEAP

@Override
public DetachedCriteria getCriteria(DetachedCriteria criteria, String key, Object value)
    throws QueryException {
  criteria.add(Restrictions.not(Restrictions.in(key, (List) value)));
  return criteria;
}

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

/**
 * @see org.openmrs.api.db.ProviderDAO#getProviderByIdentifier(java.lang.String)
 */
@Override
public boolean isProviderIdentifierUnique(Provider provider) throws DAOException {
  
  Criteria criteria = getSession().createCriteria(Provider.class);
  criteria.add(Restrictions.eq("identifier", provider.getIdentifier()));
  if (provider.getProviderId() != null) {
    criteria.add(Restrictions.not(Restrictions.eq("providerId", provider.getProviderId())));
  }
  criteria.setProjection(Projections.countDistinct("providerId"));
  
  return (Long) criteria.uniqueResult() == 0L;
}

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

Restrictions.not(prepareCriterionForName(query, true, includeVoided))).add(
    Restrictions.not(prepareCriterionForName(query, false, includeVoided))));
} else if (!matchExactly) {
  criteria.add(prepareCriterionForName(query, false, includeVoided));

代码示例来源:origin: OpenNMS/opennms

@Override
public void visitNotComplete(final NotRestriction restriction) {
  if (m_criterions.size() == 0) {
    throw new IllegalStateException("NotRestriction called, but no criterions exist to negate!");
  }
  final Criterion criterion = m_criterions.remove(m_criterions.size() - 1);
  m_criterions.add(org.hibernate.criterion.Restrictions.not(criterion));
}

代码示例来源:origin: com.arsframework/ars-database

/**
 * 排除模糊查询条件匹配对象
 *
 * @param property 属性名称
 * @param values   属性值集合
 * @return 条件匹配对象
 */
protected Criterion getNlikeCriterion(String property, Collection<String> values) {
  return Restrictions.not(this.getLikeCriterion(property, values));
}

代码示例来源:origin: com.arsframework/ars-database

/**
 * 获取非条件匹配对象
 *
 * @param property 属性名称
 * @param values   属性值数组
 * @return 条件匹配对象
 */
protected Criterion getNotCriterion(String property, Collection<?> values) {
  return Restrictions.not(this.getOrCriterion(property, values));
}

代码示例来源:origin: org.geomajas.plugin/geomajas-layer-hibernate

/** {@inheritDoc} */
@Override
public Object visit(ExcludeFilter filter, Object userData) {
  return Restrictions.not(Restrictions.conjunction());
}

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

@Override
public Criterion getHibernateCriterion( QueryPath queryPath )
{
  return Restrictions.not( super.getHibernateCriterion( queryPath ) );
}

代码示例来源:origin: com.arsframework/ars-database

/**
 * 获取排除模糊查询开始条件匹配对象
 *
 * @param property 属性名称
 * @param values   属性值集合
 * @return 条件匹配对象
 */
protected Criterion getNstartCriterion(String property, Collection<String> values) {
  return Restrictions.not(this.getStartCriterion(property, values));
}

代码示例来源:origin: org.geomajas.plugin/geomajas-layer-hibernate

/** {@inheritDoc} */
@Override
public Object visit(Not filter, Object userData) {
  Criterion c = (Criterion) filter.getFilter().accept(this, userData);
  return Restrictions.not(c);
}

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

@Override
  public Criterion toHibernateCriterion(AbstractHibernateQuery hibernateQuery, Query.Negation criterion, String alias) {
    CriterionAdaptor<Query.Disjunction> adapter = (CriterionAdaptor<Query.Disjunction>)criterionAdaptors.get(Query.Disjunction.class);
    return Restrictions.not(adapter.toHibernateCriterion(hibernateQuery, new Query.Disjunction(criterion.getCriteria()), alias));
  }
});

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

@Override
  public org.hibernate.criterion.Criterion toHibernateCriterion(HibernateQuery hibernateQuery, Query.Criterion criterion, String alias) {
    Query.Junction existing = (Query.Junction) criterion;
    Junction disjunction = Restrictions.disjunction();
    applySubCriteriaToJunction(hibernateQuery.getEntity(), hibernateQuery, existing.getCriteria(), disjunction, alias);
    return Restrictions.not(disjunction);
  }
});

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

@Override
public Junction negation() {
  final org.hibernate.criterion.Disjunction disjunction = Restrictions.disjunction();
  addToCriteria(Restrictions.not(disjunction));
  return new HibernateJunction(disjunction, alias);
}

代码示例来源:origin: com.github.vsspt/db-generic-dao-spring-hibernate

private Criterion getCriterionListOfValues(final Filter filter) {
 final int operator = filter.getOperator();
 switch (operator) {
  case Filter.OP_IN:
   return Restrictions.in(filter.getProperty(), filter.getValuesAsCollection());
  case Filter.OP_NOT_IN:
   return Restrictions.not(Restrictions.in(filter.getProperty(), filter.getValuesAsCollection()));
  default:
   return null;
 }
}

相关文章