List of usage examples for javax.persistence.criteria CriteriaBuilder asc
Order asc(Expression<?> x);
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * TODO: Make this method the main body of getStorageUploadStatsByBusinessObjectDefinition once we migrate away from Oracle TODO: * getStorageUploadStatsByBusinessObjectDefinition that uses storage file view. This method is meant to be database agnostic. * * @param storageAlternateKey the storage alternate key * @param dateRange the date range//from w ww . j av a 2 s .c om * * @return the upload statistics */ private StorageBusinessObjectDefinitionDailyUploadStats getStorageUploadStatsByBusinessObjectDefinitionDatabaseAgnostic( StorageAlternateKeyDto storageAlternateKey, DateRangeDto dateRange) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<Tuple> criteria = builder.createTupleQuery(); Root<StorageFileViewEntity> storageFileViewEntity = criteria.from(StorageFileViewEntity.class); Path<String> namespaceCode = storageFileViewEntity.get(StorageFileViewEntity_.namespaceCode); Path<String> dataProviderCode = storageFileViewEntity.get(StorageFileViewEntity_.dataProviderCode); Path<String> businessObjectDefinitionName = storageFileViewEntity .get(StorageFileViewEntity_.businessObjectDefinitionName); Path<Date> createdDate = storageFileViewEntity.get(StorageFileViewEntity_.createdDate); Expression<Long> totalFilesExpression = builder .count(storageFileViewEntity.get(StorageFileViewEntity_.storageFileId)); Expression<Long> totalBytesExpression = builder .sum(storageFileViewEntity.get(StorageFileViewEntity_.fileSizeInBytes)); Predicate storageNameRestriction = builder.equal( builder.upper(storageFileViewEntity.get(StorageFileViewEntity_.storageCode)), storageAlternateKey.getStorageName().toUpperCase()); Predicate createDateRestriction = builder.and( builder.greaterThanOrEqualTo(createdDate, dateRange.getLowerDate()), builder.lessThanOrEqualTo(createdDate, dateRange.getUpperDate())); criteria.multiselect(createdDate, namespaceCode, dataProviderCode, businessObjectDefinitionName, totalFilesExpression, totalBytesExpression); criteria.where(builder.and(storageNameRestriction, createDateRestriction)); // Create the group by clause. List<Expression<?>> grouping = new ArrayList<>(); grouping.add(createdDate); grouping.add(namespaceCode); grouping.add(dataProviderCode); grouping.add(businessObjectDefinitionName); criteria.groupBy(grouping); // Create the order by clause. criteria.orderBy(builder.asc(createdDate), builder.asc(namespaceCode), builder.asc(dataProviderCode), builder.asc(businessObjectDefinitionName)); // Retrieve and return the storage upload statistics. List<Tuple> tuples = entityManager.createQuery(criteria).getResultList(); StorageBusinessObjectDefinitionDailyUploadStats uploadStats = new StorageBusinessObjectDefinitionDailyUploadStats(); for (Tuple tuple : tuples) { StorageBusinessObjectDefinitionDailyUploadStat uploadStat = new StorageBusinessObjectDefinitionDailyUploadStat(); uploadStats.getStorageBusinessObjectDefinitionDailyUploadStats().add(uploadStat); uploadStat.setUploadDate(DmDateUtils.getXMLGregorianCalendarValue(tuple.get(createdDate))); uploadStat.setNamespace(tuple.get(namespaceCode)); uploadStat.setDataProviderName(tuple.get(dataProviderCode)); uploadStat.setBusinessObjectDefinitionName(tuple.get(businessObjectDefinitionName)); uploadStat.setTotalFiles(tuple.get(totalFilesExpression)); uploadStat.setTotalBytes(tuple.get(totalBytesExpression)); } return uploadStats; }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * TODO: Remove this method once we migrate away from Oracle getStorageUploadStatsByBusinessObjectDefinition that uses Oracle specific 'trunc' function. * * @param storageAlternateKey the storage alternate key * @param dateRange the date range/*from www. ja v a 2 s . c om*/ * * @return the upload statistics */ private StorageBusinessObjectDefinitionDailyUploadStats getStorageUploadStatsByBusinessObjectDefinitionOracle( StorageAlternateKeyDto storageAlternateKey, DateRangeDto dateRange) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<Tuple> criteria = builder.createTupleQuery(); // The criteria root is the storage file. Root<StorageFileEntity> storageFileEntity = criteria.from(StorageFileEntity.class); // Join to the other tables we can filter on. Join<StorageFileEntity, StorageUnitEntity> storageUnitEntity = storageFileEntity .join(StorageFileEntity_.storageUnit); Join<StorageUnitEntity, StorageEntity> storageEntity = storageUnitEntity.join(StorageUnitEntity_.storage); Join<StorageUnitEntity, BusinessObjectDataEntity> businessObjectDataEntity = storageUnitEntity .join(StorageUnitEntity_.businessObjectData); Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntity = businessObjectDataEntity .join(BusinessObjectDataEntity_.businessObjectFormat); Join<BusinessObjectFormatEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = businessObjectFormatEntity .join(BusinessObjectFormatEntity_.businessObjectDefinition); Join<BusinessObjectDefinitionEntity, DataProviderEntity> dataProviderEntity = businessObjectDefinitionEntity .join(BusinessObjectDefinitionEntity_.dataProvider); Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity .join(BusinessObjectDefinitionEntity_.namespace); // Create paths and expressions. Path<String> namespacePath = namespaceEntity.get(NamespaceEntity_.code); Path<String> dataProviderNamePath = dataProviderEntity.get(DataProviderEntity_.name); Path<String> businessObjectDefinitionNamePath = businessObjectDefinitionEntity .get(BusinessObjectDefinitionEntity_.name); Expression<Date> truncCreatedOnDateExpression = builder.function("trunc", Date.class, storageFileEntity.get(StorageFileEntity_.createdOn)); Expression<Long> totalFilesExpression = builder.count(storageFileEntity.get(StorageFileEntity_.id)); Expression<Long> totalBytesExpression = builder .sum(storageFileEntity.get(StorageFileEntity_.fileSizeBytes)); // Create the standard restrictions (i.e. the standard where clauses). Predicate storageNameRestriction = builder.equal(builder.upper(storageEntity.get(StorageEntity_.name)), storageAlternateKey.getStorageName().toUpperCase()); Predicate createDateRestriction = builder.and( builder.greaterThanOrEqualTo(truncCreatedOnDateExpression, dateRange.getLowerDate()), builder.lessThanOrEqualTo(truncCreatedOnDateExpression, dateRange.getUpperDate())); criteria.multiselect(truncCreatedOnDateExpression, namespacePath, dataProviderNamePath, businessObjectDefinitionNamePath, totalFilesExpression, totalBytesExpression); criteria.where(builder.and(storageNameRestriction, createDateRestriction)); // Create the group by clause. List<Expression<?>> grouping = new ArrayList<>(); grouping.add(truncCreatedOnDateExpression); grouping.add(namespacePath); grouping.add(dataProviderNamePath); grouping.add(businessObjectDefinitionNamePath); criteria.groupBy(grouping); // Create the order by clause. criteria.orderBy(builder.asc(truncCreatedOnDateExpression), builder.asc(namespacePath), builder.asc(dataProviderNamePath), builder.asc(businessObjectDefinitionNamePath)); // Retrieve and return the storage upload statistics. List<Tuple> tuples = entityManager.createQuery(criteria).getResultList(); StorageBusinessObjectDefinitionDailyUploadStats uploadStats = new StorageBusinessObjectDefinitionDailyUploadStats(); for (Tuple tuple : tuples) { StorageBusinessObjectDefinitionDailyUploadStat uploadStat = new StorageBusinessObjectDefinitionDailyUploadStat(); uploadStats.getStorageBusinessObjectDefinitionDailyUploadStats().add(uploadStat); uploadStat.setUploadDate( DmDateUtils.getXMLGregorianCalendarValue(tuple.get(truncCreatedOnDateExpression))); uploadStat.setNamespace(tuple.get(namespacePath)); uploadStat.setDataProviderName(tuple.get(dataProviderNamePath)); uploadStat.setBusinessObjectDefinitionName(tuple.get(businessObjectDefinitionNamePath)); uploadStat.setTotalFiles(tuple.get(totalFilesExpression)); uploadStat.setTotalBytes(tuple.get(totalBytesExpression)); } return uploadStats; }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * {@inheritDoc}/*from w ww . ja v a2 s.c o m*/ */ @Override public List<BusinessObjectDataNotificationRegistrationKey> getBusinessObjectDataNotificationRegistrationKeys( String namespaceCode) { // 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. Root<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationEntity = criteria .from(BusinessObjectDataNotificationRegistrationEntity.class); // Join to the other tables we can filter on. Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntity = businessObjectDataNotificationEntity .join(BusinessObjectDataNotificationRegistrationEntity_.namespace); // Get the columns. Path<String> namespaceCodeColumn = namespaceEntity.get(NamespaceEntity_.code); Path<String> notificationNameColumn = businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.name); // Create the standard restrictions (i.e. the standard where clauses). Predicate queryRestriction = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), namespaceCode.toUpperCase()); // Add the select clause. criteria.multiselect(namespaceCodeColumn, notificationNameColumn); // Add the where clause. criteria.where(queryRestriction); // Add the order by clause. criteria.orderBy(builder.asc(notificationNameColumn)); // Run the query to get a list of tuples back. List<Tuple> tuples = entityManager.createQuery(criteria).getResultList(); // Populate the "keys" objects from the returned tuples (i.e. 1 tuple for each row). List<BusinessObjectDataNotificationRegistrationKey> businessObjectDataNotificationKeys = new ArrayList<>(); for (Tuple tuple : tuples) { BusinessObjectDataNotificationRegistrationKey businessObjectDataNotificationKey = new BusinessObjectDataNotificationRegistrationKey(); businessObjectDataNotificationKeys.add(businessObjectDataNotificationKey); businessObjectDataNotificationKey.setNamespace(tuple.get(namespaceCodeColumn)); businessObjectDataNotificationKey.setNotificationName(tuple.get(notificationNameColumn)); } return businessObjectDataNotificationKeys; }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * {@inheritDoc}//from w w w. j a v a2 s . c o m */ @Override public List<BusinessObjectDataNotificationRegistrationEntity> getBusinessObjectDataNotificationRegistrations( String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<BusinessObjectDataNotificationRegistrationEntity> criteria = builder .createQuery(BusinessObjectDataNotificationRegistrationEntity.class); // The criteria root is the business object data notification registration entity. Root<BusinessObjectDataNotificationRegistrationEntity> businessObjectDataNotificationEntity = criteria .from(BusinessObjectDataNotificationRegistrationEntity.class); // Join to the other tables we can filter on. Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntity = businessObjectDataNotificationEntity .join(BusinessObjectDataNotificationRegistrationEntity_.namespace); Join<BusinessObjectDataNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntity = businessObjectDataNotificationEntity .join(BusinessObjectDataNotificationRegistrationEntity_.notificationEventType); Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = businessObjectDataNotificationEntity .join(BusinessObjectDataNotificationRegistrationEntity_.businessObjectDefinition); Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntity = businessObjectDefinitionEntity .join(BusinessObjectDefinitionEntity_.namespace); Join<BusinessObjectDataNotificationRegistrationEntity, FileTypeEntity> fileTypeEntity = businessObjectDataNotificationEntity .join(BusinessObjectDataNotificationRegistrationEntity_.fileType, JoinType.LEFT); // Create the standard restrictions (i.e. the standard where clauses). Predicate queryRestriction = builder.equal( builder.upper(notificationEventTypeEntity.get(NotificationEventTypeEntity_.code)), notificationEventTypeCode.toUpperCase()); queryRestriction = builder.and(queryRestriction, builder.equal(builder.upper(businessObjectDefinitionNamespaceEntity.get(NamespaceEntity_.code)), businessObjectDataKey.getNamespace().toUpperCase())); queryRestriction = builder.and(queryRestriction, builder.equal( builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)), businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase())); queryRestriction = builder.and(queryRestriction, builder.or( builder.isNull(businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.usage)), builder.equal( builder.upper(businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.usage)), businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase()))); queryRestriction = builder.and(queryRestriction, builder.or( builder.isNull(businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.fileType)), builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase()))); queryRestriction = builder.and(queryRestriction, builder.or( builder.isNull(businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion)), builder.equal( businessObjectDataNotificationEntity .get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion), businessObjectDataKey.getBusinessObjectFormatVersion()))); // Order the results by namespace and notification name. List<Order> orderBy = new ArrayList<>(); orderBy.add(builder.asc(namespaceEntity.get(NamespaceEntity_.code))); orderBy.add(builder.asc( businessObjectDataNotificationEntity.get(BusinessObjectDataNotificationRegistrationEntity_.name))); // Add the clauses for the query. criteria.select(businessObjectDataNotificationEntity).where(queryRestriction).orderBy(orderBy); // Execute the query and return the results. return entityManager.createQuery(criteria).getResultList(); }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * {@inheritDoc}/*w ww. j a v a2 s . c om*/ */ @Override @Cacheable(DaoSpringModuleConfig.DM_CACHE_NAME) public List<String> getSecurityFunctionsForRole(String roleCd) { // Create the criteria builder and a tuple style criteria query. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); // CriteriaQuery<Tuple> criteria = builder.createTupleQuery(); CriteriaQuery<String> criteria = builder.createQuery(String.class); // The criteria root is the business object definition. Root<SecurityRoleFunctionEntity> securityRoleFunctionEntity = criteria .from(SecurityRoleFunctionEntity.class); // Join to the other tables we can filter on. Join<SecurityRoleFunctionEntity, SecurityRoleEntity> securityRoleEntity = securityRoleFunctionEntity .join(SecurityRoleFunctionEntity_.securityRole); Join<SecurityRoleFunctionEntity, SecurityFunctionEntity> securityFunctionEntity = securityRoleFunctionEntity .join(SecurityRoleFunctionEntity_.securityFunction); // Get the columns. Path<String> functionCodeColumn = securityFunctionEntity.get(SecurityFunctionEntity_.code); // Add the select clause. criteria.select(functionCodeColumn); criteria.where(builder.equal(builder.upper(securityRoleEntity.get(SecurityRoleEntity_.code)), roleCd.toUpperCase())); // Add the order by clause. criteria.orderBy(builder.asc(functionCodeColumn)); // Run the query to get a list of tuples back. return entityManager.createQuery(criteria).getResultList(); }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * {@inheritDoc}//www .jav a2s . co m */ @Override @Cacheable(DaoSpringModuleConfig.DM_CACHE_NAME) public List<String> getSecurityFunctions() { // Create the criteria builder and a tuple style criteria query. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<String> criteria = builder.createQuery(String.class); // The criteria root is the business object definition. Root<SecurityFunctionEntity> securityFunctionEntity = criteria.from(SecurityFunctionEntity.class); // Get the columns. Path<String> functionCodeColumn = securityFunctionEntity.get(SecurityFunctionEntity_.code); // Add the select clause. criteria.select(functionCodeColumn); // Add the order by clause. criteria.orderBy(builder.asc(functionCodeColumn)); // Run the query to get a list of tuples back. return entityManager.createQuery(criteria).getResultList(); }
From source file:org.finra.dm.dao.impl.DmDaoImpl.java
/** * {@inheritDoc}/* w w w .jav a 2s .c o m*/ */ @Override public JmsMessageEntity getOldestJmsMessage() { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<JmsMessageEntity> criteria = builder.createQuery(JmsMessageEntity.class); // The criteria root is the jms message. Root<JmsMessageEntity> jmsMessageEntity = criteria.from(JmsMessageEntity.class); // Add the select clause. criteria.select(jmsMessageEntity); // Add the order by clause, since we want to return only the oldest JMS message (a message with the smallest sequence generated id). criteria.orderBy(builder.asc(jmsMessageEntity.get(JmsMessageEntity_.id))); // Execute the query and ask it to return only the first row. List<JmsMessageEntity> resultList = entityManager.createQuery(criteria).setMaxResults(1).getResultList(); // Return the result. return resultList.size() > 0 ? resultList.get(0) : null; }
From source file:org.finra.herd.dao.impl.AttributeValueListDaoImpl.java
@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)); }/*from w w w. j ava2s . co m*/ // 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; }
From source file:org.finra.herd.dao.impl.BusinessObjectDataDaoImpl.java
@Override public List<BusinessObjectDataEntity> getBusinessObjectDataEntities( BusinessObjectDataKey businessObjectDataKey) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class); // The criteria root is the business object data. Root<BusinessObjectDataEntity> businessObjectDataEntity = criteria.from(BusinessObjectDataEntity.class); // Join to the other tables we can filter on. Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntity = businessObjectDataEntity .join(BusinessObjectDataEntity_.businessObjectFormat); Join<BusinessObjectFormatEntity, FileTypeEntity> fileTypeEntity = businessObjectFormatEntity .join(BusinessObjectFormatEntity_.fileType); Join<BusinessObjectFormatEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = businessObjectFormatEntity .join(BusinessObjectFormatEntity_.businessObjectDefinition); // Create the standard restrictions (i.e. the standard where clauses). Predicate queryRestriction = getQueryRestriction(builder, businessObjectDataEntity, businessObjectFormatEntity, fileTypeEntity, businessObjectDefinitionEntity, businessObjectDataKey); // Add the clauses for the query. criteria.select(businessObjectDataEntity).where(queryRestriction); // Order by business object format and data versions. criteria.orderBy(/*from w w w . j av a2s. c om*/ builder.asc( businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion)), builder.asc(businessObjectDataEntity.get(BusinessObjectDataEntity_.version))); return entityManager.createQuery(criteria).getResultList(); }
From source file:org.finra.herd.dao.impl.BusinessObjectDataDaoImpl.java
@Override public List<BusinessObjectDataEntity> getBusinessObjectDataFromStorageOlderThan(StorageEntity storageEntity, int thresholdMinutes, List<String> businessObjectDataStatuses) { // Create the criteria builder and the criteria. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class); // The criteria root is the business object data. Root<BusinessObjectDataEntity> businessObjectDataEntityRoot = criteria.from(BusinessObjectDataEntity.class); // Join to the other tables we can filter on. Join<BusinessObjectDataEntity, StorageUnitEntity> storageUnitEntityJoin = businessObjectDataEntityRoot .join(BusinessObjectDataEntity_.storageUnits); // Compute threshold timestamp based on the current database timestamp and threshold minutes. Timestamp thresholdTimestamp = HerdDateUtils.addMinutes(getCurrentTimestamp(), -thresholdMinutes); // Create the standard restrictions (i.e. the standard where clauses). List<Predicate> predicates = new ArrayList<>(); predicates.add(/* w w w . j av a 2s .c om*/ builder.equal(storageUnitEntityJoin.get(StorageUnitEntity_.storageName), storageEntity.getName())); predicates.add(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.statusCode) .in(businessObjectDataStatuses)); predicates.add(builder.lessThanOrEqualTo( businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.createdOn), thresholdTimestamp)); // Order results by "created on" timestamp. Order orderBy = builder.asc(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.createdOn)); // Add all clauses to the query. criteria.select(businessObjectDataEntityRoot) .where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy); // Execute the query and return the results. return entityManager.createQuery(criteria).getResultList(); }