Java Code Examples for javax.persistence.criteria.CriteriaQuery#from()
The following examples show how to use
javax.persistence.criteria.CriteriaQuery#from() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionListWithIdentity.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private List<Wo> list(Business business, String identityFlag) throws Exception { Identity identity = business.identity().pick(identityFlag); if (null == identity) { throw new ExceptionIdentityNotExist(identityFlag); } EntityManager em = business.entityManagerContainer().get(UnitDuty.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<UnitDuty> cq = cb.createQuery(UnitDuty.class); Root<UnitDuty> root = cq.from(UnitDuty.class); Predicate p = cb.isMember(identity.getId(), root.get(UnitDuty_.identityList)); List<UnitDuty> os = em.createQuery(cq.select(root).where(p)).getResultList(); List<Wo> wos = Wo.copier.copy(os); for (Wo wo : wos) { this.referenceUnit(business, wo); } wos = business.unitDuty().sort(wos); return wos; }
Example 2
Source File: Business.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public List<String> expendUnitToPersonId(List<String> unitList) throws Exception { if (ListTools.isEmpty(unitList)) { return new ArrayList<String>(); } List<String> identityIds = this.expendUnitToIdentityId(unitList); if (ListTools.isEmpty(identityIds)) { return new ArrayList<String>(); } EntityManager em = this.entityManagerContainer().get(Identity.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Identity> root = cq.from(Identity.class); Predicate p = cb.isMember(root.get(Identity_.id), cb.literal(identityIds)); List<String> personIds = em.createQuery(cq.select(root.get(Identity_.person)).where(p)).getResultList(); personIds = ListTools.trim(personIds, true, true); return personIds; }
Example 3
Source File: OkrStatisticReportStatusFactory.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 根据身份名称,从工作汇报状态统计信息中查询与该身份有关的所有信息列表 * @param identity * @param recordId * @return * @throws Exception */ public List<OkrStatisticReportStatus> listErrorIdentitiesInStReportStatus(String identity, String recordId) throws Exception { EntityManager em = this.entityManagerContainer().get( OkrStatisticReportStatus.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<OkrStatisticReportStatus> cq = cb.createQuery( OkrStatisticReportStatus.class ); Root<OkrStatisticReportStatus> root = cq.from( OkrStatisticReportStatus.class ); Predicate p = cb.isNotNull(root.get( OkrStatisticReportStatus_.id )); if( recordId != null && !recordId.isEmpty() && !"all".equals( recordId ) ){ p = cb.and( p, cb.equal( root.get( OkrStatisticReportStatus_.id ), recordId ) ); } Predicate p_responsibilityIdentity = cb.isNotNull(root.get( OkrStatisticReportStatus_.responsibilityIdentity )); p_responsibilityIdentity = cb.and( p_responsibilityIdentity, cb.equal( root.get( OkrStatisticReportStatus_.responsibilityIdentity ), identity ) ); p = cb.and( p, p_responsibilityIdentity ); return em.createQuery(cq.where(p)).getResultList(); }
Example 4
Source File: ActionListWithUnitSubDirectLikeObject.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private List<String> people(Business business, Wi wi) throws Exception { List<Unit> os = business.unit().pick(wi.getUnitList()); List<String> unitIds = ListTools.extractField(os, Unit.id_FIELDNAME, String.class, true, true); EntityManager em = business.entityManagerContainer().get(Identity.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Identity> root = cq.from(Identity.class); Predicate p = root.get(Identity_.unit).in(unitIds); List<String> list = em.createQuery(cq.select(root.get(Identity_.person)).where(p).distinct(true)) .getResultList(); return list; }
Example 5
Source File: ReviewFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public List<String> listWithWork(String id) throws Exception { EntityManager em = this.entityManagerContainer().get(Review.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Review> root = cq.from(Review.class); Predicate p = cb.equal(root.get(Review_.work), id); cq.select(root.get(Review_.id)).where(p); return em.createQuery(cq).getResultList(); }
Example 6
Source File: FolderFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public List<String> listWithPersonWithSuperior(String person, String superior) throws Exception { EntityManager em = this.entityManagerContainer().get(Folder.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Folder> root = cq.from(Folder.class); Predicate p = cb.equal(root.get(Folder_.person), person); p = cb.and(p, cb.equal(root.get(Folder_.superior), superior)); cq.select(root.get(Folder_.id)).where(p); return em.createQuery(cq).getResultList(); }
Example 7
Source File: GlobalAttributeDefinitionDaoImpl.java From herd with Apache License 2.0 | 5 votes |
@Override public GlobalAttributeDefinitionEntity getGlobalAttributeDefinitionByKey(GlobalAttributeDefinitionKey globalAttributeDefinitionKey) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<GlobalAttributeDefinitionEntity> criteria = builder.createQuery(GlobalAttributeDefinitionEntity.class); // The criteria root is the global attribute definition entity. Root<GlobalAttributeDefinitionEntity> globalAttributeDefinitionEntityRoot = criteria.from(GlobalAttributeDefinitionEntity.class); //Join on the other tables that we filter on Join<GlobalAttributeDefinitionEntity, GlobalAttributeDefinitionLevelEntity> globalAttributeDefinitionLevelEntityJoin = globalAttributeDefinitionEntityRoot.join(GlobalAttributeDefinitionEntity_.globalAttributeDefinitionLevel); // Create the standard restrictions (i.e. the standard where clauses). List<Predicate> predicates = new ArrayList<>(); predicates.add(builder .equal(builder.upper(globalAttributeDefinitionLevelEntityJoin.get(GlobalAttributeDefinitionLevelEntity_.globalAttributeDefinitionLevel)), globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel().toUpperCase())); predicates.add(builder.equal(builder.upper(globalAttributeDefinitionEntityRoot.get(GlobalAttributeDefinitionEntity_.globalAttributeDefinitionName)), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName().toUpperCase())); // Add all clauses to the query. criteria.select(globalAttributeDefinitionEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))); return executeSingleResultQuery(criteria, String.format( "Found more than one global attribute definition with parameters {globalAttributeDefinitionLevel=\"%s\", globalAttributeDefinitionLevel=\"%s\"}.", globalAttributeDefinitionKey.getGlobalAttributeDefinitionLevel(), globalAttributeDefinitionKey.getGlobalAttributeDefinitionName())); }
Example 8
Source File: JpaTestHelper.java From nestedj with MIT License | 5 votes |
@Override public TestNode findNode(String symbol) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<TestNode> select = cb.createQuery(TestNode.class); Root<TestNode> root = select.from(TestNode.class); select.where(cb.equal(root.get("name"), symbol)); TestNode n = em.createQuery(select).getSingleResult(); TestHelper.printNode(symbol, n); this.em.refresh(n); return n; }
Example 9
Source File: TimerExpiredWorkApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listProcessFromWork(Business business, DateRange dateRange, ApplicationStub applicationStub) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Work.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Work> root = cq.from(Work.class); Predicate p = cb.between(root.get(Work_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Work_.application), applicationStub.getValue())); cq.select(root.get(Work_.process)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 10
Source File: JpaUtil.java From linq with Apache License 2.0 | 5 votes |
/** * 删除实体类对应的所有记录 * @param domainClass 领域类(实体类) * @param <T> 领域类(实体类)范型 */ public static <T> void removeAll(Class<T> domainClass) { EntityManager em = getEntityManager(domainClass); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<T> cq = cb.createQuery(domainClass); cq.from(domainClass); List<T> result = findAll(cq); for (T element : result) { remove(element); } }
Example 11
Source File: BaseAction.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
protected boolean idleAlias(Business business, Stat stat) throws Exception { EntityManager em = business.entityManagerContainer().get(Stat.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Long> cq = cb.createQuery(Long.class); Root<Stat> root = cq.from(Stat.class); Predicate p = cb.equal(root.get(Stat_.query), stat.getQuery()); p = cb.and(p, cb.equal(root.get(Stat_.alias), stat.getAlias())); p = cb.and(p, cb.notEqual(root.get(Stat_.id), stat.getId())); return em.createQuery(cq.select(cb.count(root)).where(p)).getSingleResult() == 0; }
Example 12
Source File: AttributeValueListDaoImpl.java From herd with Apache License 2.0 | 5 votes |
@Override public List<AttributeValueListKey> getAttributeValueLists(Collection<String> namespaces) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<AttributeValueListEntity> criteria = builder.createQuery(AttributeValueListEntity.class); // The criteria root is the attribute value list entity. Root<AttributeValueListEntity> attributeValueListEntityRoot = criteria.from(AttributeValueListEntity.class); // Join to the other tables we can filter on. Join<AttributeValueListEntity, NamespaceEntity> namespaceEntityJoin = attributeValueListEntityRoot.join(AttributeValueListEntity_.namespace); // Create the standard restrictions (i.e. the standard where clauses). List<Predicate> predicates = new ArrayList<>(); if (CollectionUtils.isNotEmpty(namespaces)) { predicates.add(namespaceEntityJoin.get(NamespaceEntity_.code).in(namespaces)); } // Order the results by namespace and job name. List<Order> orderBy = new ArrayList<>(); orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code))); orderBy.add(builder.asc(attributeValueListEntityRoot.get(AttributeValueListEntity_.name))); // Add all clauses to the query. criteria.select(attributeValueListEntityRoot).where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy); // Execute the query and build a list of keys. List<AttributeValueListKey> attributeValueListKeys = new ArrayList<>(); for (AttributeValueListEntity attributeValueListEntity : entityManager.createQuery(criteria).getResultList()) { attributeValueListKeys.add(new AttributeValueListKey(attributeValueListEntity.getNamespace().getCode(), attributeValueListEntity.getName())); } return attributeValueListKeys; }
Example 13
Source File: MindShareRecordFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public Boolean exists(MindShareRecord mindShareRecord) throws Exception { if( mindShareRecord == null ){ throw new Exception( "mindShareRecord is null!" ); } EntityManager em = this.entityManagerContainer().get(MindShareRecord.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<MindShareRecord> root = cq.from(MindShareRecord.class); Predicate p = cb.equal( root.get(MindShareRecord_.fileId), mindShareRecord.getFileId() ); p = cb.and( p , cb.equal( root.get(MindShareRecord_.target), mindShareRecord.getTarget())); p = cb.and( p , cb.equal( root.get(MindShareRecord_.targetType), mindShareRecord.getTargetType())); cq.select( root.get(MindShareRecord_.id) ); List<String> ids = em.createQuery(cq.where(p)).getResultList(); return ListTools.isNotEmpty(ids); }
Example 14
Source File: TimerExpiredWorkApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private String getProcessNameFromWorkCompleted(Business business, DateRange dateRange, String processId) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(WorkCompleted.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<WorkCompleted> root = cq.from(WorkCompleted.class); Predicate p = cb.between(root.get(WorkCompleted_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(WorkCompleted_.expired), true)); p = cb.and(p, cb.equal(root.get(WorkCompleted_.process), processId)); cq.select(root.get(WorkCompleted_.processName)).where(p); List<String> list = em.createQuery(cq).setMaxResults(1).getResultList(); return list.isEmpty() ? null : list.get(0); }
Example 15
Source File: IdentityFactory.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Identity pickObject(String flag) throws Exception { Identity o = this.entityManagerContainer().flag(flag, Identity.class); if (o != null) { this.entityManagerContainer().get(Identity.class).detach(o); } else { String name = flag; Matcher matcher = PersistenceProperties.Identity.distinguishedName_pattern.matcher(flag); if (matcher.find()) { name = matcher.group(1); String unique = matcher.group(2); o = this.entityManagerContainer().flag(unique, Identity.class); if (null != o) { this.entityManagerContainer().get(Identity.class).detach(o); } } if (null == o) { EntityManager em = this.entityManagerContainer().get(Identity.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Identity> cq = cb.createQuery(Identity.class); Root<Identity> root = cq.from(Identity.class); Predicate p = cb.equal(root.get(Identity_.name), name); List<Identity> os = em.createQuery(cq.select(root).where(p).distinct(true)).getResultList(); if (os.size() == 1) { o = os.get(0); em.detach(o); } } } return o; }
Example 16
Source File: TimerExpiredTaskApplicationStubs.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private Collection<String> listActivityFromTask(Business business, DateRange dateRange, ProcessStub processStub) throws Exception { EntityManagerContainer emc = business.entityManagerContainer(); EntityManager em = emc.get(Task.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<Task> root = cq.from(Task.class); Predicate p = cb.between(root.get(Task_.expireTime), dateRange.getStart(), dateRange.getEnd()); p = cb.and(p, cb.equal(root.get(Task_.process), processStub.getValue())); cq.select(root.get(Task_.activity)).distinct(true).where(p); List<String> list = em.createQuery(cq).getResultList(); return list; }
Example 17
Source File: AbstractBundleSubmissionHibernateDao.java From judgels with GNU General Public License v2.0 | 5 votes |
@Override public List<M> getByContainerJidAndUserJidAndProblemJid(String containerJid, String userJid, String problemJid) { CriteriaBuilder cb = currentSession().getCriteriaBuilder(); CriteriaQuery<M> query = cb.createQuery(getEntityClass()); Root<M> root = query.from(getEntityClass()); query.where(cb.and(cb.equal(root.get(AbstractBundleSubmissionModel_.containerJid), containerJid), cb.equal(root.get(AbstractBundleSubmissionModel_.createdBy), userJid), cb.equal(root.get(AbstractBundleSubmissionModel_.problemJid), problemJid))); return currentSession().createQuery(query).getResultList(); }
Example 18
Source File: CmsPermissionService.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
/** * 查询用户有权限访问的所有栏目ID列表( 不检测allPeopleView, with List copy ) * * @param personName * @param unitNames * @param groupNames * @param inAppInfoIds * @param excludAppInfoIds * @return * @throws Exception */ private List<String> listViewableAppIdsInPermission(EntityManagerContainer emc, String personName, List<String> unitNames, List<String> groupNames, List<String> inAppInfoIds, List<String> excludAppInfoIds, String documentType, Integer maxCount) throws Exception { List<String> appInfoIds = null; List<String> appInfoIds_out = new ArrayList<>(); EntityManager em = emc.get(AppInfo.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<String> cq = cb.createQuery(String.class); Root<AppInfo> root = cq.from(AppInfo.class); Predicate p = null; // 限定范围 if (ListTools.isNotEmpty(inAppInfoIds)) { p = CriteriaBuilderTools.predicate_and(cb, p, root.get(AppInfo.id_FIELDNAME).in(inAppInfoIds)); } // 排队指定的ID列表 if (ListTools.isNotEmpty(excludAppInfoIds)) { p = CriteriaBuilderTools.predicate_and(cb, p, cb.not(root.get(AppInfo.id_FIELDNAME).in(excludAppInfoIds))); } if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) { p = CriteriaBuilderTools.predicate_and(cb, p, cb.equal(root.get(AppInfo.documentType_FIELDNAME), documentType)); } Predicate p_permission = null; if (StringUtils.isNotEmpty(personName)) { // 可以管理的栏目,肯定可以看到 p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, cb.isMember(personName, root.get(AppInfo.manageablePersonList_FIELDNAME))); // 可发布的栏目,肯定可以看到 p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, cb.isMember(personName, root.get(AppInfo.publishablePersonList_FIELDNAME))); p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, cb.isMember(personName, root.get(AppInfo.viewablePersonList_FIELDNAME))); } if (ListTools.isNotEmpty(unitNames)) { p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, root.get(AppInfo.publishableUnitList_FIELDNAME).in(unitNames)); p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, root.get(AppInfo.viewableUnitList_FIELDNAME).in(unitNames)); } if (ListTools.isNotEmpty(groupNames)) { p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, root.get(AppInfo.publishableGroupList_FIELDNAME).in(groupNames)); p_permission = CriteriaBuilderTools.predicate_or(cb, p_permission, root.get(AppInfo.viewableGroupList_FIELDNAME).in(groupNames)); } p = CriteriaBuilderTools.predicate_and(cb, p, p_permission); cq.select(root.get(AppInfo.id_FIELDNAME)); appInfoIds = em.createQuery(cq.where(p)).setMaxResults(maxCount).getResultList(); if (appInfoIds == null) { appInfoIds = new ArrayList<>(); } appInfoIds_out.addAll(appInfoIds); appInfoIds_out = excludListContent(appInfoIds_out, excludAppInfoIds); return appInfoIds_out; }
Example 19
Source File: BBSReplyInfoFactory.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public List<BBSReplyInfo> listReplyForPage( String creatorName, String forumId, String mainSectionId, String sectionId, String subjectId, String orderType, Integer maxCount ) throws Exception { Boolean allFilterNull = true; if( StringUtils.isNotEmpty( creatorName ) ){ allFilterNull = false; } if( StringUtils.isNotEmpty( forumId ) ){ allFilterNull = false; } if( StringUtils.isNotEmpty( mainSectionId ) ){ allFilterNull = false; } if( StringUtils.isNotEmpty( sectionId ) ){ allFilterNull = false; } if( StringUtils.isNotEmpty( subjectId ) ){ allFilterNull = false; } if( allFilterNull ){ throw new Exception( "list filter can not all null." ); } if( maxCount == null ){ maxCount = 20; } EntityManager em = this.entityManagerContainer().get( BBSReplyInfo.class ); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<BBSReplyInfo> cq = cb.createQuery( BBSReplyInfo.class ); Root<BBSReplyInfo> root = cq.from( BBSReplyInfo.class ); Predicate p = cb.isNotNull( root.get( BBSReplyInfo_.id ) ); if( StringUtils.isNotEmpty( creatorName ) ){ p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.creatorName ), creatorName ) ); } if( StringUtils.isNotEmpty( forumId ) ){ p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.forumId ), forumId ) ); } if( StringUtils.isNotEmpty( mainSectionId ) ){ p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.mainSectionId ), mainSectionId ) ); } if( StringUtils.isNotEmpty( sectionId ) ){ p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.sectionId ), sectionId ) ); } if( StringUtils.isNotEmpty( subjectId ) ){ p = cb.and( p, cb.equal( root.get( BBSReplyInfo_.subjectId ), subjectId ) ); } if( StringUtils.equalsIgnoreCase(orderType, "DESC")){ cq.orderBy( cb.desc( root.get( BBSReplyInfo_.createTime ) ) ); }else{ cq.orderBy( cb.asc( root.get( BBSReplyInfo_.createTime ) ) ); } return em.createQuery(cq.where(p)).setMaxResults( maxCount ).getResultList(); }
Example 20
Source File: BusinessObjectDataNotificationRegistrationDaoImpl.java From herd with Apache License 2.0 | 4 votes |
@Override public List<NotificationRegistrationKey> getBusinessObjectDataNotificationRegistrationKeysByNotificationFilter( BusinessObjectDataNotificationFilter businessObjectDataNotificationFilter) { // Create the criteria builder and a tuple style criteria query. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<Tuple> criteria = builder.createTupleQuery(); // The criteria root is the business object data notification registration. Root<BusinessObjectDataNotificationRegistrationEntity> notificationRegistrationEntityRoot = criteria.from(BusinessObjectDataNotificationRegistrationEntity.class); // Join to the other tables we can filter on. Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> notificationRegistrationNamespaceEntityJoin = notificationRegistrationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.namespace); Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = notificationRegistrationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.businessObjectDefinition); Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace); Join<BusinessObjectDataNotificationRegistrationEntity, FileTypeEntity> fileTypeEntity = notificationRegistrationEntityRoot.join(BusinessObjectDataNotificationRegistrationEntity_.fileType, JoinType.LEFT); // Get the columns. Path<String> notificationRegistrationNamespaceColumn = notificationRegistrationNamespaceEntityJoin.get(NamespaceEntity_.code); Path<String> notificationRegistrationNameColumn = notificationRegistrationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.name); // Create the standard restrictions (i.e. the standard where clauses). List<Predicate> predicates = new ArrayList<>(); predicates.add(builder.equal(builder.upper(businessObjectDefinitionNamespaceEntity.get(NamespaceEntity_.code)), businessObjectDataNotificationFilter.getNamespace().toUpperCase())); predicates.add(builder.equal(builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataNotificationFilter.getBusinessObjectDefinitionName().toUpperCase())); if (StringUtils.isNotBlank(businessObjectDataNotificationFilter.getBusinessObjectFormatUsage())) { predicates.add(builder.or(builder.isNull(notificationRegistrationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), builder .equal(builder.upper(notificationRegistrationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.usage)), businessObjectDataNotificationFilter.getBusinessObjectFormatUsage().toUpperCase()))); } if (StringUtils.isNotBlank(businessObjectDataNotificationFilter.getBusinessObjectFormatFileType())) { predicates.add(builder.or(builder.isNull(notificationRegistrationEntityRoot.get(BusinessObjectDataNotificationRegistrationEntity_.fileType)), builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectDataNotificationFilter.getBusinessObjectFormatFileType().toUpperCase()))); } // Add the select and where clauses to the query. criteria.multiselect(notificationRegistrationNamespaceColumn, notificationRegistrationNameColumn) .where(builder.and(predicates.toArray(new Predicate[predicates.size()]))); // Add the order by clause to the query. criteria.orderBy(builder.asc(notificationRegistrationNamespaceColumn), builder.asc(notificationRegistrationNameColumn)); // Run the query to get a list of tuples back. List<Tuple> tuples = entityManager.createQuery(criteria).getResultList(); // Populate the list of keys from the returned tuples. return getNotificationRegistrationKeys(tuples, notificationRegistrationNamespaceColumn, notificationRegistrationNameColumn); }