当前位置: 首页>>代码示例>>Java>>正文


Java Expression.disjunction方法代码示例

本文整理汇总了Java中org.hibernate.criterion.Expression.disjunction方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.disjunction方法的具体用法?Java Expression.disjunction怎么用?Java Expression.disjunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.criterion.Expression的用法示例。


在下文中一共展示了Expression.disjunction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSharedfields

import org.hibernate.criterion.Expression; //导入方法依赖的package包/类
public List getSharedfields(Patient patient) throws PersistenceException, org.cidrz.webapp.dynasite.exception.ObjectNotFoundException {
    List results = null;
    try {
        Session session = HibernateUtil.currentSession();
        Transaction tx = session.beginTransaction();
        Criteria crit = session.createCriteria(EncounterValue.class)
                .add(Expression.eq("patient", patient));
        //todo: filter out empty values
        Disjunction any = Expression.disjunction();
        any.add(Expression.eq("fieldId", new Long(129)));
        /*any.add(Expression.eq("fieldId", new Long(224)));
        any.add(Expression.eq("fieldId", new Long(225)));*/
        /* any.add(Expression.eq("fieldId", new Long(228)));*/
        any.add(Expression.eq("fieldId", new Long(232)));
        /*any.add(Expression.eq("fieldId", new Long(235)));*/
        any.add(Expression.eq("fieldId", new Long(242)));
        any.add(Expression.eq("fieldId", new Long(243)));
        any.add(Expression.eq("fieldId", new Long(244)));
        crit.add(any);
        crit.addOrder(Order.asc("visitDate"))
                .setFetchMode("pageItem.getForm_field().getEnumerations()", FetchMode.EAGER);
        // .setFetchMode("pageItem.form_field).enumerations", FetchMode.EAGER);
        results = crit.list();
        //log.info("test logging");
        //log.info(sql);
        //log.error(sql);
        //System.out.println("sql: " + sql.toString());
        //results = q.list();
        tx.commit();
        HibernateUtil.closeSession();

    } catch (Exception e) {
        throw new PersistenceException(e);
    }
    if (results == null) {
        throw new PersistenceException();
    }
    return results;
}
 
开发者ID:chrisekelley,项目名称:zeprs,代码行数:40,代码来源:BasePersistenceManager.java

示例2: getItemScores

import org.hibernate.criterion.Expression; //导入方法依赖的package包/类
public Map<Long, List<ItemGradingData>> getItemScores(final Long itemId, List<AssessmentGradingData> scores, boolean loadItemGradingAttachment) {
    try {
        HashMap<Long, List<ItemGradingData>> map = new HashMap<>();

        HibernateCallback<List<ItemGradingData>> hcb = session -> {
            Criteria criteria = session.createCriteria(ItemGradingData.class);
            Disjunction disjunction = Expression.disjunction();

            /** make list from AssessmentGradingData ids */
            List<Long> gradingIdList = scores.stream()
                    .map(AssessmentGradingData::getAssessmentGradingId)
                    .collect(Collectors.toList());

            /** create or disjunctive expression for (in clauses) */
            List tempList;
            for (int i = 0; i < gradingIdList.size(); i += 50) {
                if (i + 50 > gradingIdList.size()) {
                    tempList = gradingIdList.subList(i, gradingIdList.size());
                    disjunction.add(Expression.in("assessmentGradingId", tempList));
                } else {
                    tempList = gradingIdList.subList(i, i + 50);
                    disjunction.add(Expression.in("assessmentGradingId", tempList));
                }
            }

            if (itemId.equals(Long.valueOf(0))) {
                criteria.add(disjunction);
                //criteria.add(Expression.isNotNull("submittedDate"));
            } else {

                /** create logical and between the pubCriterion and the disjunction criterion */
                //Criterion pubCriterion = Expression.eq("publishedItem.itemId", itemId);
                Criterion pubCriterion = Expression.eq("publishedItemId", itemId);
                criteria.add(Expression.and(pubCriterion, disjunction));
                //criteria.add(Expression.isNotNull("submittedDate"));
            }
            criteria.addOrder(Order.asc("agentId"));
            criteria.addOrder(Order.desc("submittedDate"));
            return criteria.list();
            //large list cause out of memory error (java heap space)
            //return criteria.setMaxResults(10000).list();
        };
        List<ItemGradingData> temp = getHibernateTemplate().execute(hcb);

        Map<Long, List<ItemGradingAttachment>> attachmentMap = new HashMap<>();
        if (loadItemGradingAttachment) {
            attachmentMap = getItemGradingAttachmentMap(itemId);
        }
        for (ItemGradingData data : temp) {
            if (loadItemGradingAttachment) {
                if (attachmentMap.get(data.getItemGradingId()) != null) {
                    data.setItemGradingAttachmentList(attachmentMap.get(data.getItemGradingId()));
                } else {
                    data.setItemGradingAttachmentList(new ArrayList<>());
                }
            }
            List<ItemGradingData> thisone = map.get(data.getPublishedItemId());
            if (thisone == null) {
                thisone = new ArrayList<>();
            }
            thisone.add(data);
            map.put(data.getPublishedItemId(), thisone);
        }
        return map;
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
        return new HashMap<>();
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:70,代码来源:AssessmentGradingFacadeQueries.java

示例3: getMediaArray

import org.hibernate.criterion.Expression; //导入方法依赖的package包/类
public List<MediaData> getMediaArray(Long publishedId, final Long publishedItemId, String which) {
    try {
        Map<Long, List<ItemGradingData>> itemScores = getItemScores(publishedId, publishedItemId, which);
        final List<ItemGradingData> list = itemScores.get(publishedItemId);
        log.debug("list size list.size() = " + list.size());

        HibernateCallback<List<MediaData>> hcb = session -> {
            Criteria criteria = session.createCriteria(MediaData.class);
            Disjunction disjunction = Expression.disjunction();

            /** make list from AssessmentGradingData ids */
            List<Long> itemGradingIdList = list.stream()
                    .map(ItemGradingData::getItemGradingId)
                    .collect(Collectors.toList());

            /** create or disjunctive expression for (in clauses) */
            List<Long> tempList;
            for (int i = 0; i < itemGradingIdList.size(); i += 50) {
                if (i + 50 > itemGradingIdList.size()) {
                    tempList = itemGradingIdList.subList(i, itemGradingIdList.size());
                    disjunction.add(Expression.in("itemGradingData.itemGradingId", tempList));
                } else {
                    tempList = itemGradingIdList.subList(i, i + 50);
                    disjunction.add(Expression.in("itemGradingData.itemGradingId", tempList));
                }
            }
            criteria.add(disjunction);
            return criteria.list();
            //large list cause out of memory error (java heap space)
            //return criteria.setMaxResults(10000).list();
        };

        List<MediaData> a = new ArrayList<>();
        List<MediaData> hbmList = getHibernateTemplate().execute(hcb);
        for (MediaData mediaData : hbmList) {
            mediaData.setContentResource(getMediaContentResource(mediaData));
            a.add(mediaData);
        }
        return a;

    } catch (Exception e) {
        log.warn(e.getMessage(), e);
        return new ArrayList<>();
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:46,代码来源:AssessmentGradingFacadeQueries.java


注:本文中的org.hibernate.criterion.Expression.disjunction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。