本文整理汇总了Java中org.hibernate.criterion.Disjunction类的典型用法代码示例。如果您正苦于以下问题:Java Disjunction类的具体用法?Java Disjunction怎么用?Java Disjunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Disjunction类属于org.hibernate.criterion包,在下文中一共展示了Disjunction类的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: getTasks
import org.hibernate.criterion.Disjunction; //导入依赖的package包/类
public Pagination getTasks(final User user, final List<RolePrivilege> privs, final int pageNum, final int pageSize) {
return (Pagination) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session aSession) throws HibernateException, SQLException {
Criteria query = aSession.createCriteria(Task.class);
Disjunction dis = Restrictions.disjunction();
for(RolePrivilege userPriv: privs) {
dis.add(Restrictions.eq("privilege", userPriv.getPrivilege()));
}
dis.add(Restrictions.eq("assigneeOid",user.getOid()));
query.add(dis);
query.createCriteria("agency").add(Restrictions.eq("oid", user.getAgency().getOid()));
query.addOrder(Order.desc("sentDate"));
Criteria cntQuery = aSession.createCriteria(Task.class);
cntQuery.add(dis);
cntQuery.createCriteria("agency").add(Restrictions.eq("oid", user.getAgency().getOid()));
cntQuery.setProjection(Projections.rowCount());
return new Pagination(cntQuery, query, pageNum, pageSize);
}
});
}
示例6: countTasks
import org.hibernate.criterion.Disjunction; //导入依赖的package包/类
public int countTasks(final User user, final List<RolePrivilege> privs) {
return (Integer) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Criteria query = session.createCriteria(Task.class);
query.setProjection(Projections.rowCount());
Disjunction dis = Restrictions.disjunction();
for(RolePrivilege userPriv: privs) {
dis.add(Restrictions.eq("privilege", userPriv.getPrivilege()));
}
dis.add(Restrictions.eq("assigneeOid",user.getOid()));
query.add(dis);
query.createCriteria("agency").add(Restrictions.eq("oid", user.getAgency().getOid()));
Integer count = (Integer) query.uniqueResult();
return count;
}
});
}
示例7: countTargetInstances
import org.hibernate.criterion.Disjunction; //导入依赖的package包/类
public int countTargetInstances(final String aUsername, final ArrayList<String> aStates) {
return (Integer) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session) {
Criteria query = session.createCriteria(TargetInstance.class);
query.setProjection(Projections.rowCount());
if (aStates != null && !aStates.isEmpty()) {
Disjunction stateDisjunction = Restrictions.disjunction();
for(String s: aStates) {
stateDisjunction.add(Restrictions.eq("state", s));
}
query.add(stateDisjunction);
}
query.createCriteria("owner").add(Restrictions.eq("username", aUsername));
Integer count = (Integer) query.uniqueResult();
return count;
}
}
);
}
示例8: 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();
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: getPointOfContactSubquery
import org.hibernate.criterion.Disjunction; //导入依赖的package包/类
private DetachedCriteria getPointOfContactSubquery(SampleQueryBean query,
String pocAlias1, String pocAlias2, String projectionProperty) {
DetachedCriteria subCrit = DetachedCriteria.forClass(
PointOfContact.class, "subCrit");
subCrit.createAlias("subCrit.organization", "organization",
CriteriaSpecification.LEFT_JOIN);
subCrit.setProjection(Projections.distinct(Property.forName("id")));
Disjunction pocDisjunction = getPointOfContactDisjunctionPerQuery(
query, "", "");
subCrit.add(pocDisjunction);
if (pocAlias1.equals(pocAlias2)) {
subCrit.add(Restrictions.eqProperty(
"subCrit." + projectionProperty, pocAlias1 + "id"));
} else {
subCrit.add(Restrictions.or(Restrictions.eqProperty("subCrit."
+ projectionProperty, pocAlias1 + "id"), Restrictions
.eqProperty("subCrit." + projectionProperty, pocAlias2
+ "id")));
}
return subCrit;
}
示例13: 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;
}
示例14: 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"));
}
}
示例15: 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);
}