本文整理汇总了Java中org.hibernate.criterion.Disjunction.add方法的典型用法代码示例。如果您正苦于以下问题:Java Disjunction.add方法的具体用法?Java Disjunction.add怎么用?Java Disjunction.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.criterion.Disjunction
的用法示例。
在下文中一共展示了Disjunction.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCriteriaForMaclike
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private void addCriteriaForMaclike(OnmsCriteria criteria, String macLike) {
String macLikeStripped = macLike.replaceAll("[:-]", "");
criteria.createAlias("node.snmpInterfaces", "snmpInterface", CriteriaSpecification.LEFT_JOIN);
criteria.createAlias("node.arpInterfaces", "arpInterface", CriteriaSpecification.LEFT_JOIN);
Disjunction physAddrDisjunction = Restrictions.disjunction();
physAddrDisjunction.add(Restrictions.ilike("snmpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
physAddrDisjunction.add(Restrictions.ilike("arpInterface.physAddr", macLikeStripped, MatchMode.ANYWHERE));
criteria.add(physAddrDisjunction);
// This is an alternative to the above code if we need to use the out-of-the-box DetachedCriteria which doesn't let us specify the join type
/*
String propertyName = "nodeId";
String value = "%" + macLikeStripped + "%";
Disjunction physAddrDisjuction = Restrictions.disjunction();
physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM snmpinterface WHERE snmpphysaddr LIKE ? )", value, new StringType()));
physAddrDisjuction.add(Restrictions.sqlRestriction("{alias}." + propertyName + " IN (SELECT nodeid FROM atinterface WHERE atphysaddr LIKE ? )", value, new StringType()));
criteria.add(physAddrDisjuction);
*/
}
示例2: getBatchInstanceIdentifierForUserRoles
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* API for getting the batch instance identifiers having the user roles.
* @param userRoles Set<String>
* @return Set<String>
*/
@Override
public Set<String> getBatchInstanceIdentifierForUserRoles(final Set<String> userRoles) {
boolean isValid = true;
if (userRoles == null || userRoles.size() == 0) {
isValid = false;
}
Set<String> batchInstanceIdentifiers = null;
if (isValid) {
batchInstanceIdentifiers = new HashSet<String>();
final DetachedCriteria criteria = criteria();
final Disjunction disjunction = Restrictions.disjunction();
disjunction.add(Restrictions.in(GROUP_NAME, userRoles));
criteria.add(disjunction);
final List<BatchInstanceGroups> batchInstanceGroups = find(criteria);
for (final BatchInstanceGroups batchInstanceGroup : batchInstanceGroups) {
batchInstanceIdentifiers.add(batchInstanceGroup.getBatchInstanceIdentifier());
}
}
return batchInstanceIdentifiers;
}
示例3: listUsersBySearch
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* Buscar usuários de acordo com um nome.
*
* @param terms Nome buscado.
* @return PaginatedList Lista de usuários que contém o nome buscado
* em alguma parte do nome.
*/
public PaginatedList<User> listUsersBySearch(String terms) {
PaginatedList<User> results = new PaginatedList<User>();
Criteria criteria = this.dao.newCriteria(User.class);
criteria.add(Restrictions.eq("deleted", false));
Criteria count = this.dao.newCriteria(User.class).add(Restrictions.eq("deleted", false))
.setProjection(Projections.countDistinct("id"));
if (terms != null && !terms.isEmpty()) {
Disjunction or = Restrictions.disjunction();
or.add(Restrictions.like("name", "%" + terms + "%").ignoreCase());
criteria.add(or);
count.add(or);
}
results.setList(this.dao.findByCriteria(criteria, User.class));
results.setTotal((Long) count.uniqueResult());
return results;
}
示例4: createEntityIdsInCriterion
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* Create a in list criterion potentially using disjunction to overcome the
* size limitation of certain DBs in restriction (e.g. Oracle is 1000).
*
* @param entityIds
* the list of entity ids.
* @param chunkSize
* the size of disjunctions parts.
* @return the criterion.
*/
public static Criterion createEntityIdsInCriterion(Collection<Serializable> entityIds, int chunkSize) {
if (entityIds.size() < chunkSize) {
return Restrictions.in(IEntity.ID, entityIds);
}
int i = 0;
Disjunction splittedInlist = Restrictions.disjunction();
Set<Serializable> currentEntityIds = new LinkedHashSet<>();
boolean complete = false;
for (Iterator<Serializable> ite = entityIds.iterator(); ite.hasNext(); i++) {
currentEntityIds.add(ite.next());
if (i % chunkSize == (chunkSize - 1)) {
splittedInlist.add(Restrictions.in(IEntity.ID, currentEntityIds));
currentEntityIds = new LinkedHashSet<>();
complete = true;
} else {
complete = false;
}
}
if (!complete) {
splittedInlist.add(Restrictions.in(IEntity.ID, currentEntityIds));
}
return splittedInlist;
}
示例5: getTweetByOwnerId
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public List<Tweet> getTweetByOwnerId(String ownerId){
DetachedCriteria dcr = DetachedCriteria.forClass(User.class, "follower");
dcr.createAlias("follower.following", "following");
dcr.add(Restrictions.eq("follower.id", ownerId));
dcr.setProjection(Projections.property("following.id"));
Criteria cr = getSession().createCriteria(Tweet.class, "tweets");
Disjunction res = Restrictions.disjunction();
res.add(Restrictions.eq("ownerId", ownerId));
res.add(Subqueries.propertyIn("tweets.ownerId", dcr));
cr.add(res);
return cr.list();
}
示例6: getDatumJunction
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private Junction getDatumJunction(AdvancedSampleSearchBean searchBean) {
// if AND and more than one type of datum, don't use junction
if (searchBean.getCharacterizationLogicalOperator().equals("and")
&& searchBean.getDatumTypeCount() > 1) {
return null;
}
Disjunction datumDisjunction = Restrictions.disjunction();
Conjunction datumConjunction = Restrictions.conjunction();
for (CharacterizationQueryBean charQuery : searchBean
.getCharacterizationQueries()) {
Criterion datumCrit = getDatumCriterion(charQuery);
if (datumCrit != null) {
datumDisjunction.add(datumCrit);
if (searchBean.getDatumTypeCount() == 1) {
datumConjunction.add(datumCrit);
}
}
}
// default to or if only one query
Junction junction = (searchBean.getCharacterizationLogicalOperator()
.equals("or") || searchBean.getCharacterizationQueries().size() == 1) ? datumDisjunction
: datumConjunction;
return junction;
}
示例7: getPointOfContactDisjunctionPerQuery
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private Disjunction getPointOfContactDisjunctionPerQuery(
SampleQueryBean query, String pocAlias, String otherPOCAlias) {
String pocCritStrs[] = null;
if (StringUtils.isEmpty(otherPOCAlias)) {
pocCritStrs = new String[] { pocAlias + "lastName",
pocAlias + "firstName", "organization.name" };
} else {
pocCritStrs = new String[] { pocAlias + "lastName",
pocAlias + "firstName", "organization.name",
otherPOCAlias + "lastName", otherPOCAlias + "firstName",
"otherOrg.name" };
}
TextMatchMode nameMatchMode = null;
if (query.getOperand().equals("equals")) {
nameMatchMode = new TextMatchMode(query.getName());
} else if (query.getOperand().equals(Constants.STRING_OPERAND_CONTAINS)) {
nameMatchMode = new TextMatchMode("*" + query.getName() + "*");
}
Disjunction pocDisjunction = Restrictions.disjunction();
for (String critStr : pocCritStrs) {
Criterion pocCrit = Restrictions.ilike(critStr, nameMatchMode
.getUpdatedText(), nameMatchMode.getMatchMode());
pocDisjunction.add(pocCrit);
}
return pocDisjunction;
}
示例8: getSampleNameJunction
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* Get the sample name junction used in sample queries
*
* @param searchBean
* @param crit
* @return
* @throws Exception
*/
private Junction getSampleNameJunction(AdvancedSampleSearchBean searchBean)
throws Exception {
Disjunction sampleDisjunction = Restrictions.disjunction();
Conjunction sampleConjunction = Restrictions.conjunction();
for (SampleQueryBean query : searchBean.getSampleQueries()) {
if (query.getNameType().equals("sample name")) {
Criterion sampleNameCrit = getSampleNameCriterion(query);
if (sampleNameCrit != null) {
sampleDisjunction.add(sampleNameCrit);
sampleConjunction.add(sampleNameCrit);
}
}
}
Junction junction = (searchBean.getSampleLogicalOperator().equals("or") || searchBean
.getSampleQueries().size() == 1) ? sampleDisjunction
: sampleConjunction;
return junction;
}
示例9: getRolesByNamesAndOrg
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* Return the roles with the given names in the organisation if present
*
* @author Adelina
*
* @param organisationId
* @param count
* @param name
* @return List<Role>
*/
public List<Role> getRolesByNamesAndOrg(Integer organisationId, int count, String... name) {
logger.debug("getRoleByNameAndOrg DAO IMPL - START - ");
for(int i = 0; i < count; i++) {
logger.debug("name = ".concat(name[i]));
}
logger.debug("organisationId = ".concat(String.valueOf(organisationId)));
DetachedCriteria dc = DetachedCriteria.forEntityName(IModelConstant.roleForListingEntity);
Disjunction disjunction = Restrictions.disjunction();
for(int i = 0; i < count; i++) {
disjunction.add(Restrictions.eq("name", name[i]));
}
dc.add(disjunction);
dc.add(Restrictions.eq("organisation.organisationId", organisationId));
List<Role> roles = getHibernateTemplate().findByCriteria(dc);
return roles;
}
示例10: setSeriesSecurityGroups
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
private static void setSeriesSecurityGroups(DetachedCriteria criteria, List<String> securityGroups)
{
Conjunction con = new Conjunction();
if (securityGroups != null && securityGroups.size() != 0)
{
Disjunction disjunction = Restrictions.disjunction();
disjunction.add(Restrictions.isNull("securityGroup"));
disjunction.add(Restrictions.in("securityGroup", securityGroups));
con.add(disjunction);
criteria.add(con);
}
else
{
criteria.add(Restrictions.isNull("securityGroup"));
}
}
示例11: getUsersById
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
@Override
public List<User> getUsersById(Collection<Integer> usersId) {
if (usersId.isEmpty()) {
return new ArrayList<>();
}
final Disjunction disjunction = Restrictions.disjunction();
for (final Integer id : usersId) {
disjunction.add(Property.forName(Constants.ID).eq(id));
}
final DetachedCriteria detachedCriteria = DetachedCriteria.forClass(User.class)
.add(disjunction);
return dao.getAllBy(detachedCriteria);
}
示例12: getRolesForBatchInstance
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* API for getting roles for the specified batch instance.
* @param batchInstanceId String
* @return Set<String>
*/
@Override
public Set<String> getRolesForBatchInstance(String batchInstanceId) {
Set<String> grps = new HashSet<String>();
final DetachedCriteria criteria = criteria();
final Disjunction disjunction = Restrictions.disjunction();
disjunction.add(Restrictions.eq(BATCH_INSTANCE_ID, batchInstanceId));
criteria.add(disjunction);
final List<BatchInstanceGroups> batchClassGroups = find(criteria);
for (final BatchInstanceGroups batchInstanceGroup : batchClassGroups) {
grps.add(batchInstanceGroup.getGroupName());
}
return grps;
}
示例13: getBatchInstanceIdentifiersExceptUserRoles
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* API for getting the batch instance identifiers except provided user roles.
*
* @param userRoles Set<String>
* @return Set<String>
*/
@Override
public Set<String> getBatchInstanceIdentifiersExceptUserRoles(final Set<String> userRoles) {
Set<String> batchInstanceIdentifiers = new HashSet<String>();
final DetachedCriteria criteria = criteria();
final Disjunction disjunction = Restrictions.disjunction();
disjunction.add(Restrictions.not(Restrictions.in(GROUP_NAME, userRoles)));
criteria.add(disjunction);
final List<BatchInstanceGroups> batchInstanceGroups = find(criteria);
for (final BatchInstanceGroups batchInstanceGroup : batchInstanceGroups) {
batchInstanceIdentifiers.add(batchInstanceGroup.getBatchInstanceIdentifier());
}
return batchInstanceIdentifiers;
}
示例14: getBatchClassIdentifierForUserRoles
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
/**
* API for getting the batch class identifiers having the user roles.
* @param userRoles Set<String>
* @param includeDeleted boolean
* @return Set<String>
*/
@Override
public Set<String> getBatchClassIdentifierForUserRoles(Set<String> userRoles, boolean includeDeleted) {
boolean isValid = true;
if (userRoles == null || userRoles.size() == 0) {
isValid = false;
}
Set<String> batchClassIdentifiers = null;
// New version of fetching.
if (isValid) {
batchClassIdentifiers = new LinkedHashSet<String>();
DetachedCriteria criteria = criteria();
Disjunction disjunction = Restrictions.disjunction();
for (String userRole : userRoles) {
disjunction.add(Restrictions.eq(GROUP_NAME, userRole));
}
criteria.add(disjunction);
criteria.addOrder(Order.asc(BATCH_CLASS));
List<BatchClassGroups> batchClassGroups = find(criteria);
for (BatchClassGroups batchClassGroup : batchClassGroups) {
if(includeDeleted) {
batchClassIdentifiers.add(batchClassGroup.getBatchClass().getIdentifier());
} else {
if(!batchClassGroup.getBatchClass().isDeleted()) {
batchClassIdentifiers.add(batchClassGroup.getBatchClass().getIdentifier());
}
}
}
}
return batchClassIdentifiers;
}
示例15: getAttributeSearch
import org.hibernate.criterion.Disjunction; //导入方法依赖的package包/类
protected DetachedCriteria getAttributeSearch(DetachedCriteria ciCrit) {
if (getTextMatch() != null) {
DetachedCriteria attribute = DetachedCriteria.forClass(BasicAttribute.class);
//ciCrit.setProjection();
Disjunction orAttribute = Restrictions.disjunction();
boolean orAttributeAdded = false;
if (isTextMatchAlias()) {
orAttribute.add(Expression.ilike("alias", getTextMatch(), MatchMode.ANYWHERE));
orAttributeAdded = true;
}
if (isTextMatchDescription()) {
orAttribute.add(Expression.ilike("description", getTextMatch(), MatchMode.ANYWHERE));
orAttributeAdded = true;
}
if (isTextMatchValue()) {
orAttribute.add(Expression.ilike("valueAsString", getTextMatch(), MatchMode.ANYWHERE));
orAttributeAdded = true;
}
if (orAttributeAdded) {
DetachedCriteria ciIdCriteria = ciCrit.setProjection(Projections.property("longId"));
DetachedCriteria attributeCriteira = DetachedCriteria.forClass(BasicAttribute.class);
attributeCriteira.add(Property.forName("ownerId").in(ciIdCriteria));
attributeCriteira.add(orAttribute);
return(attributeCriteira);
}
}
return(null);
}