本文整理了Java中org.hibernate.criterion.Restrictions.ne
方法的一些代码示例,展示了Restrictions.ne
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Restrictions.ne
方法的具体详情如下:
包路径:org.hibernate.criterion.Restrictions
类名称:Restrictions
方法名:ne
[英]Apply a "not equal" constraint to the named property
[中]对命名属性应用“不相等”约束
代码示例来源:origin: hibernate/hibernate-orm
/**
* Creates a non-equality restriction.
*
* @param value The value to check against
*
* @return The non-equality restriction.
*
* @see Restrictions#ne(String, Object)
*/
public SimpleExpression ne(Object value) {
return Restrictions.ne( getPropertyName(), value );
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* Apply a "not equal" constraint to the named property. If the value
* is null, instead apply "is not null".
*
* @param propertyName The name of the property
* @param value The value to use in comparison
*
* @return The Criterion
*
* @see #ne
* @see #isNotNull
*/
public static Criterion neOrIsNotNull(String propertyName, Object value) {
return value == null
? isNotNull( propertyName )
: ne( propertyName, value );
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<ProfileFilter> findActualByEndpointGroupId(String groupId) {
LOG.debug("Searching actual profile filters by endpoint group id [{}] ", groupId);
List<ProfileFilter> filters = Collections.emptyList();
if (isNotBlank(groupId)) {
filters = findListByCriterionWithAlias(ENDPOINT_GROUP_PROPERTY, ENDPOINT_GROUP_ALIAS,
Restrictions.and(
Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)),
Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED)));
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.", groupId, Arrays.toString(filters.toArray()));
} else {
LOG.debug("[{}] Search result: {}.", groupId, filters.size());
}
return filters;
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<Configuration> findActualByEndpointGroupId(String groupId) {
List<Configuration> configurations = null;
LOG.debug("Searching actual configurations by endpoint group id [{}] ", groupId);
if (isNotBlank(groupId)) {
configurations = findListByCriterionWithAlias(
ENDPOINT_GROUP_PROPERTY,
ENDPOINT_GROUP_ALIAS,
Restrictions.and(
Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)),
Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED)));
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}] Search result: {}.",
groupId, Arrays.toString(configurations.toArray()));
} else {
LOG.debug("[{}] Search result: {}.",
groupId, configurations.size());
}
return configurations;
}
代码示例来源:origin: kaaproject/kaa
@Override
public boolean validateName(String tenantId, String ecfId, String name) {
LOG.debug("Validating by tenant id [{}], ecf id [{}], name [{}]", tenantId, ecfId, name);
Criteria criteria = getCriteria();
criteria.createAlias(TENANT_PROPERTY, TENANT_ALIAS);
criteria.add(Restrictions.and(
Restrictions.eq(TENANT_REFERENCE, Long.valueOf(tenantId)),
Restrictions.eq(NAME_PROPERTY, name)));
if (isNotBlank(ecfId)) {
criteria = criteria.add(Restrictions.ne(ID_PROPERTY, Long.valueOf(ecfId)));
}
List<EventClassFamily> eventClassFamilies = findListByCriteria(criteria);
boolean result = eventClassFamilies == null || eventClassFamilies.isEmpty();
LOG.debug("[{},{},{}] Validating result: {}", tenantId, ecfId, name, result);
return result;
}
代码示例来源: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: kaaproject/kaa
@Override
public boolean validateClassName(String tenantId, String ecfId, String className) {
LOG.debug("Validating fqn, tenant id [{}], ecf id [{}], className [{}]",
tenantId, ecfId, className);
Criteria criteria = getCriteria();
criteria.createAlias(TENANT_PROPERTY, TENANT_ALIAS);
criteria.add(Restrictions.and(
Restrictions.eq(TENANT_REFERENCE, Long.valueOf(tenantId)),
Restrictions.eq(CLASS_NAME_PROPERTY, className)));
if (isNotBlank(ecfId)) {
criteria = criteria.add(Restrictions.ne(ID_PROPERTY, Long.valueOf(ecfId)));
}
List<EventClassFamily> eventClassFamilies = findListByCriteria(criteria);
boolean result = eventClassFamilies == null || eventClassFamilies.isEmpty();
LOG.debug("[{},{},{}] Validating result: {}", tenantId, ecfId, className, result);
return result;
}
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<CtlSchemaMetaInfo> findSiblingsByFqnTenantIdAndApplicationId(
String fqn, String tenantId, String applicationId) {
LOG.debug("Searching siblings of ctl by fqn [{}], tenantId [{}] and applicationId [{}]",
fqn, tenantId, applicationId);
List<CtlSchemaMetaInfo> ctlSchemaMetaInfos;
if (isNotBlank(fqn) && isNotBlank(tenantId) && isNotBlank(applicationId)) {
ctlSchemaMetaInfos = findListByCriterion(
Restrictions.and(
Restrictions.eq(CTL_SCHEMA_META_INFO_FQN, fqn),
Restrictions.eq(CTL_SCHEMA_META_INFO_TENANT_ID_ALIAS, Long.valueOf(tenantId)),
Restrictions.isNotNull(CTL_SCHEMA_META_INFO_APPLICATION_ID_ALIAS),
Restrictions.ne(CTL_SCHEMA_META_INFO_APPLICATION_ID_ALIAS,
Long.valueOf(applicationId))
));
} else {
ctlSchemaMetaInfos = Collections.emptyList();
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{}][{}][{}] Search result: [{}].",
fqn, tenantId, applicationId, Arrays.toString(ctlSchemaMetaInfos.toArray()));
} else {
LOG.debug("[{}][{}][{}] Search result: [{}].",
fqn, tenantId, applicationId, ctlSchemaMetaInfos.size());
}
return ctlSchemaMetaInfos;
}
代码示例来源: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<Configuration> findActualBySchemaIdAndGroupId(String schemaId, String groupId) {
List<Configuration> configurations = Collections.emptyList();
LOG.debug("Searching actual configurations by configuration schema id [{}] "
+ "and group id [{}] ",
schemaId, groupId);
if (isNotBlank(schemaId) && isNotBlank(groupId)) {
Criteria criteria = getCriteria();
criteria.createAlias(CONFIGURATION_SCHEMA_PROPERTY, CONFIGURATION_SCHEMA_ALIAS);
criteria.createAlias(ENDPOINT_GROUP_PROPERTY, ENDPOINT_GROUP_ALIAS);
criteria.add(Restrictions.and(
Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)),
Restrictions.eq(CONFIGURATION_SCHEMA_REFERENCE, Long.valueOf(schemaId)),
Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED)));
configurations = findListByCriteria(criteria);
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{},{}] Search result: {}.",
schemaId, groupId, Arrays.toString(configurations.toArray()));
} else {
LOG.debug("[{},{}] Search result: {}.",
schemaId, groupId, configurations.size());
}
return configurations;
}
代码示例来源:origin: kaaproject/kaa
@Override
public List<ProfileFilter> findActualBySchemaIdAndGroupId(
String endpointProfileSchemaId, String serverProfileSchemaId, String groupId) {
LOG.debug("Searching actual profile filters by endpoint schema id [{}], "
+ "server schema id [{}] and group id [{}] ",
endpointProfileSchemaId, serverProfileSchemaId, groupId);
List<ProfileFilter> filters = Collections.emptyList();
if (isNotBlank(groupId)) {
Criteria criteria = getCriteria();
criteria.createAlias(ENDPOINT_GROUP_PROPERTY, ENDPOINT_GROUP_ALIAS);
criteria.createAlias(ENDPOINT_PROFILE_SCHEMA_PROPERTY, ENDPOINT_PROFILE_SCHEMA_ALIAS,
JoinType.LEFT_OUTER_JOIN);
criteria.createAlias(SERVER_PROFILE_SCHEMA_PROPERTY, SERVER_PROFILE_SCHEMA_ALIAS,
JoinType.LEFT_OUTER_JOIN);
criteria.add(Restrictions.and(
Restrictions.eq(ENDPOINT_GROUP_REFERENCE, Long.valueOf(groupId)),
buildEqIdCriterion(ENDPOINT_PROFILE_SCHEMA_REFERENCE, endpointProfileSchemaId),
buildEqIdCriterion(SERVER_PROFILE_SCHEMA_REFERENCE, serverProfileSchemaId),
Restrictions.ne(STATUS_PROPERTY, UpdateStatus.DEPRECATED)));
filters = findListByCriteria(criteria);
}
if (LOG.isTraceEnabled()) {
LOG.trace("[{},{},{}] Search result: {}.", endpointProfileSchemaId, serverProfileSchemaId,
groupId, Arrays.toString(filters.toArray()));
} else {
LOG.debug("[{},{},{}] Search result: {}.", endpointProfileSchemaId, serverProfileSchemaId,
groupId, filters.size());
}
return filters;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.UserDAO#getUsersByPerson(org.openmrs.Person, boolean)
*/
@Override
@SuppressWarnings("unchecked")
public List<User> getUsersByPerson(Person person, boolean includeRetired) {
Criteria crit = sessionFactory.getCurrentSession().createCriteria(User.class);
crit.add(Restrictions.ne("uuid", Daemon.getDaemonUserUuid()));
if (person != null) {
crit.add(Restrictions.eq("person", person));
}
if (!includeRetired) {
crit.add(Restrictions.eq("retired", false));
}
return (List<User>) crit.list();
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.db.ConceptDAO#getProposedConcepts(java.lang.String)
*/
@Override
@SuppressWarnings("unchecked")
public List<Concept> getProposedConcepts(String text) throws DAOException {
Criteria crit = sessionFactory.getCurrentSession().createCriteria(ConceptProposal.class);
crit.add(Restrictions.ne("state", OpenmrsConstants.CONCEPT_PROPOSAL_UNMAPPED));
crit.add(Restrictions.eq("originalText", text));
crit.add(Restrictions.isNotNull("mappedConcept"));
crit.setProjection(Projections.distinct(Projections.property("mappedConcept")));
return crit.list();
}
代码示例来源:origin: openmrs/openmrs-core
criteria.add(Restrictions.ne("action", Order.Action.DISCONTINUE));
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.UserService#getUsersByName(java.lang.String, java.lang.String, boolean)
*/
@Override
public List<User> getUsersByName(String givenName, String familyName, boolean includeRetired) {
Criteria crit = sessionFactory.getCurrentSession().createCriteria(User.class);
crit.createAlias("person", "person");
crit.createAlias("person.names", "names");
crit.add(Restrictions.eq("names.givenName", givenName));
crit.add(Restrictions.eq("names.familyName", familyName));
crit.add(Restrictions.ne("uuid", Daemon.getDaemonUserUuid()));
crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
if (!includeRetired) {
crit.add(Restrictions.eq("retired", false));
}
return new ArrayList<>((List<User>) crit.list());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.api.UserService#getUsersByRole(org.openmrs.Role)
*/
@SuppressWarnings("unchecked")
public List<User> getUsersByRole(Role role) throws DAOException {
return (List<User>) sessionFactory.getCurrentSession().createCriteria(User.class, "u").createCriteria("roles", "r")
.add(Restrictions.like("r.role", role.getRole())).add(Restrictions.ne("u.uuid", Daemon.getDaemonUserUuid())).addOrder(Order.asc("u.username")).list();
}
代码示例来源: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: org.jboss.seam/jboss-seam
private List<TaskInstance> getTaskInstanceList(String actorId)
{
if ( actorId == null ) return null;
return ManagedJbpmContext.instance().getSession()
.createCriteria(TaskInstance.class)
.add( Restrictions.eq("actorId", actorId) )
.add( Restrictions.eq("isOpen", true) )
.add( Restrictions.ne("isSuspended", true) )
.addOrder( Order.asc("priority") )
.setCacheable(true)
.list();
}
代码示例来源:origin: OpenNMS/opennms
private static void addCriteriaForService(OnmsCriteria criteria, int serviceId) {
criteria.createAlias("node.ipInterfaces", "ipInterface");
criteria.add(Restrictions.ne("ipInterface.isManaged", "D"));
criteria.createAlias("node.ipInterfaces.monitoredServices", "monitoredService");
criteria.createAlias("node.ipInterfaces.monitoredServices.serviceType", "serviceType");
criteria.add(Restrictions.eq("serviceType.id", serviceId));
criteria.add(Restrictions.ne("monitoredService.status", "D"));
}
代码示例来源:origin: org.opennms/opennms-web-api
private static void addCriteriaForIpLike(OnmsCriteria criteria, String iplike) {
OnmsCriteria ipInterface = criteria.createCriteria("node.ipInterfaces", "ipInterface");
ipInterface.add(Restrictions.ne("isManaged", "D"));
ipInterface.add(OnmsRestrictions.ipLike(iplike));
}
内容来源于网络,如有侵权,请联系作者删除!