本文整理了Java中org.hibernate.criterion.Restrictions.or
方法的一些代码示例,展示了Restrictions.or
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.or
方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称:Restrictions
方法名:or
[英]Return the disjuction of two expressions
[中]返回两个表达式的分离
代码示例来源:origin: kaaproject/kaa
/**
* Find user by username or email.
*
* @param usernameOrMail the username or email of user
* @return user
*/
public User findByUsernameOrMail(String usernameOrMail) {
Criteria criteria = getCriteria();
Criterion usernameCriterion = Restrictions.eq(USERNAME_PROPERTY, usernameOrMail);
Criterion mailCriterion = Restrictions.eq(MAIL_PROPERTY, usernameOrMail);
criteria.add(Restrictions.or(usernameCriterion, mailCriterion));
return (User) criteria.uniqueResult();
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<Topic> findVacantTopicsByGroupId(String appId, String groupId) {
List<Topic> topics = Collections.emptyList();
LOG.debug("Searching vacant topics for endpoint group with id [{}] and application id [{}]",
groupId, appId);
if (isNotBlank(groupId)) {
topics = findListByCriterionWithAlias(ENDPOINT_GROUPS_PROPERTY, ENDPOINT_GROUP_ALIAS,
JoinType.LEFT_OUTER_JOIN,
and(eq(APPLICATION_REFERENCE, Long.valueOf(appId)), or(
ne(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)),
isNull(ENDPOINT_GROUP_REFERENCE))));
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{},{}] Search result: {}.", groupId, appId, Arrays.toString(topics.toArray()));
} else {
LOG.debug("[{},{}] Search result: {}.", groupId, appId, topics.size());
}
return topics;
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<CtlSchemaMetaInfo> findOthersByFqnAndTenantId(
String fqn, String tenantId, String excludingId) {
LOG.debug("Searching other ctl schema meta infos by fqn [{}], "
+ "tenant id [{}] and excluding id [{}]", fqn, tenantId, excludingId);
List<CtlSchemaMetaInfo> availableSchemas = findListByCriterion(
Restrictions.and(Restrictions.ne(ID_PROPERTY, Long.valueOf(excludingId)),
Restrictions.eq(CTL_SCHEMA_META_INFO_FQN, fqn),
Restrictions.or(
Restrictions.eq(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS, Long.valueOf(tenantId)),
Restrictions.isNull(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS))));
if (LOG.isTraceEnabled()) {
LOG.trace("[{}][{}][{}] Search result: [{}].", fqn, tenantId, excludingId,
Arrays.toString(availableSchemas.toArray()));
} else {
LOG.debug("[{}][{}][{}] Search result: [{}].", fqn, tenantId, excludingId,
availableSchemas.size());
}
return availableSchemas;
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
@Override
public List<Offer> readOffersByAutomaticDeliveryType() {
//TODO change this to a JPA criteria
Criteria criteria = ((HibernateEntityManager) em).getSession().createCriteria(OfferImpl.class);
Date myDate = getCurrentDateAfterFactoringInDateResolution();
Calendar c = Calendar.getInstance();
c.setTime(myDate);
c.add(Calendar.DATE, +1);
criteria.add(Restrictions.lt("startDate", c.getTime()));
c = Calendar.getInstance();
c.setTime(myDate);
c.add(Calendar.DATE, -1);
criteria.add(Restrictions.or(Restrictions.isNull("endDate"), Restrictions.gt("endDate", c.getTime())));
criteria.add(Restrictions.or(Restrictions.eq("archiveStatus.archived", 'N'),
Restrictions.isNull("archiveStatus.archived")));
criteria.add(Restrictions.eq("automaticallyAdded", true));
criteria.setCacheable(true);
criteria.setCacheRegion("query.Offer");
return criteria.list();
}
代码示例来源:origin: kaaproject/kaa
private Criterion buildExludingSearchCriterion(
String fqn, String excludingTenantId, String excludingApplicationId) {
List<Criterion> searchCriterions = new ArrayList<>();
if (isNotBlank(excludingTenantId)) {
searchCriterions.add(Restrictions.isNull(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS));
if (isNotBlank(excludingApplicationId)) {
searchCriterions.add(Restrictions.and(
Restrictions.eq(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS, Long.valueOf(excludingTenantId)),
Restrictions.isNull(CTL_SCHEMA_META_INFO_APPLICATION_ID_ALIAS)));
} else {
searchCriterions.add(Restrictions.and(
Restrictions.eq(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS, Long.valueOf(excludingTenantId)),
Restrictions.isNotNull(CTL_SCHEMA_META_INFO_APPLICATION_ID_ALIAS)));
}
} else {
searchCriterions.add(Restrictions.isNotNull(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS));
}
return Restrictions.and(Restrictions.eq(CTL_SCHEMA_META_INFO_FQN, fqn),
Restrictions.or(searchCriterions.toArray(new Criterion[searchCriterions.size()])));
}
代码示例来源:origin: kaaproject/kaa
private Criterion buildScopeCriterion(String tenantId, String applicationId) {
if (isBlank(tenantId)) {
// SYSTEM - tenantId=null && appId=null
return Restrictions.and(Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID),
Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID));
} else {
if (isBlank(applicationId)) {
// TENANT - (tenantId=id or tenantId=null) && appId=null
return Restrictions.and(Restrictions.or(
Restrictions.eq(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID, Long.valueOf(tenantId)),
Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID)
),
Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID));
} else {
// APPLICATION - (tenantId=id or tenantId=null) && (appId=id or appId=null)
return Restrictions.and(Restrictions.or(
Restrictions.eq(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID, Long.valueOf(tenantId)),
Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_TENANT_ID)
),
Restrictions.or(
Restrictions.eq(CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID,
Long.valueOf(applicationId)),
Restrictions.isNull(CTL_SCHEMA_META_INFO_ALIAS_APPLICATION_ID)));
}
}
}
代码示例来源:origin: kaaproject/kaa
Restrictions.eq(APPLICATION_REFERENCE, Long.valueOf(appId)),
Restrictions.eq(STATUS_PROPERTY, UpdateStatus.ACTIVE),
Restrictions.or(Restrictions.and(
Restrictions.eq(ENDPOINT_PROFILE_SCHEMA_VERSION_REFERENCE, endpointSchemaVersion),
Restrictions.eq(SERVER_PROFILE_SCHEMA_VERSION_REFERENCE, serverSchemaVersion)
代码示例来源: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: hibernate/hibernate-orm
subCriteria,
subCriteria.add(
Restrictions.or(
Restrictions.isNull( "articleId" ), // Allow null
Restrictions.eq( "articleId", "1000" )
代码示例来源:origin: hibernate/hibernate-orm
rootCriteria,
rootCriteria.add(
Restrictions.or(
Restrictions.isNull( "ol.articleId" ), // Allow null
Restrictions.eq( "ol.articleId", "1000" )
代码示例来源:origin: hibernate/hibernate-orm
subCriteria,
subCriteria.add(
Restrictions.or(
Restrictions.isNull( "ol.articleId" ), // Allow null
Restrictions.eq( "ol.articleId", "1000" )
代码示例来源:origin: hibernate/hibernate-orm
"orderLines",
"ol", JoinFragment.LEFT_OUTER_JOIN,
Restrictions.or(
Restrictions.isNull( "ol.articleId" ), // Allow null
Restrictions.eq( "ol.articleId", "1000" )
代码示例来源:origin: hibernate/hibernate-orm
.add( Restrictions.or(
Restrictions.and(
Restrictions.eq( "integer", f.getInteger() ),
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ConceptDAO#getDrugsByIngredient(org.openmrs.Concept)
*/
@Override
@SuppressWarnings("unchecked")
public List<Drug> getDrugsByIngredient(Concept ingredient) {
Criteria searchDrugCriteria = sessionFactory.getCurrentSession().createCriteria(Drug.class, "drug");
Criterion rhs = Restrictions.eq("drug.concept", ingredient);
searchDrugCriteria.createAlias("ingredients", "ingredients");
Criterion lhs = Restrictions.eq("ingredients.ingredient", ingredient);
searchDrugCriteria.add(Restrictions.or(lhs, rhs));
return (List<Drug>) searchDrugCriteria.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see SerializedObjectDAO#getAllObjects(Class, boolean)
*/
@Override
@SuppressWarnings("unchecked")
public List<SerializedObject> getAllSerializedObjects(Class<?> type, boolean includeRetired) throws DAOException {
Criteria c = sessionFactory.getCurrentSession().createCriteria(SerializedObject.class);
c.add(Restrictions.or(Restrictions.eq("type", type.getName()), Restrictions.eq("subtype", type.getName())));
if (!includeRetired) {
c.add(Restrictions.like("retired", false));
}
return (List<SerializedObject>) c.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see SerializedObjectDAO#getAllSerializedObjectsByName(Class, String, boolean)
*/
@Override
@SuppressWarnings("unchecked")
public List<SerializedObject> getAllSerializedObjectsByName(Class<?> type, String name, boolean exactMatchOnly)
throws DAOException {
Criteria c = sessionFactory.getCurrentSession().createCriteria(SerializedObject.class);
c.add(Restrictions.or(Restrictions.eq("type", type.getName()), Restrictions.eq("subtype", type.getName())));
if (exactMatchOnly) {
c.add(Restrictions.eq("name", name));
} else {
c.add(Restrictions.ilike("name", name, MatchMode.ANYWHERE));
}
return (List<SerializedObject>) c.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.notification.AlertService#getAllAlerts(boolean)
*/
@Override
@SuppressWarnings("unchecked")
public List<Alert> getAllAlerts(boolean includeExpired) throws DAOException {
Criteria crit = sessionFactory.getCurrentSession().createCriteria(Alert.class);
// exclude the expired alerts unless requested
if (!includeExpired) {
crit.add(Restrictions.or(Restrictions.isNull("dateToExpire"), Restrictions.gt("dateToExpire", new Date())));
}
return crit.list();
}
代码示例来源:origin: openmrs/openmrs-core
@Override
public List<CohortMembership> getCohortMemberships(Integer patientId, Date activeOnDate, boolean includeVoided) {
Criteria criteria = sessionFactory.getCurrentSession().createCriteria(CohortMembership.class);
criteria.add(Restrictions.eq("patientId", patientId));
if (activeOnDate != null) {
criteria.add(Restrictions.le("startDate", activeOnDate));
criteria.add(Restrictions.or(
Restrictions.isNull("endDate"),
Restrictions.ge("endDate", activeOnDate)
));
}
if (!includeVoided) {
criteria.add(Restrictions.eq(VOIDED, false));
}
return criteria.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @param query
* @param includeRetired
* @return
*/
private Criteria createConceptReferenceTermCriteria(String query, ConceptSource conceptSource, boolean includeRetired) {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(ConceptReferenceTerm.class);
if (conceptSource != null) {
searchCriteria.add(Restrictions.eq("conceptSource", conceptSource));
}
if (!includeRetired) {
searchCriteria.add(Restrictions.eq("retired", false));
}
if (query != null) {
searchCriteria.add(Restrictions.or(Restrictions.ilike("name", query, MatchMode.ANYWHERE), Restrictions.ilike(
"code", query, MatchMode.ANYWHERE)));
}
return searchCriteria;
}
代码示例来源:origin: openmrs/openmrs-core
crit.add(Restrictions.or(Restrictions.like("HL7Data", query, MatchMode.ANYWHERE), Restrictions.or(
Restrictions.like("errorDetails", query, MatchMode.ANYWHERE), Restrictions.like("error", query,
MatchMode.ANYWHERE))));
内容来源于网络,如有侵权,请联系作者删除!