Example usage for javax.persistence.criteria CriteriaBuilder or

List of usage examples for javax.persistence.criteria CriteriaBuilder or

Introduction

In this page you can find the example usage for javax.persistence.criteria CriteriaBuilder or.

Prototype

Predicate or(Expression<Boolean> x, Expression<Boolean> y);

Source Link

Document

Create a disjunction of the given boolean expressions.

Usage

From source file:org.finra.herd.dao.impl.AbstractHerdDao.java

/**
 * TODO This method may be bdata specific. Consider creating new abstract class to group all bdata related DAO. Builds a query restriction predicate for the
 * sub-query business object data entity as per partition values from the specified main query business object data entity.
 *
 * @param builder the criteria builder/*from   w  ww.j ava2s .  c om*/
 * @param subBusinessObjectDataEntity the sub-query business object data entity that appears in the from clause
 * @param mainBusinessObjectDataEntity the main query business object data entity that appears in the from clause
 *
 * @return the query restriction predicate
 */
protected Predicate getQueryRestrictionOnPartitionValues(CriteriaBuilder builder,
        From<?, BusinessObjectDataEntity> subBusinessObjectDataEntity,
        From<?, BusinessObjectDataEntity> mainBusinessObjectDataEntity) {
    // Create a standard restriction on primary partition value.
    Predicate predicate = builder.equal(
            subBusinessObjectDataEntity.get(BusinessObjectDataEntity_.partitionValue),
            mainBusinessObjectDataEntity.get(BusinessObjectDataEntity_.partitionValue));

    // Create and add standard restrictions on sub-partition values. Please note that the subpartition value columns are nullable.
    for (SingularAttribute<BusinessObjectDataEntity, String> businessObjectDataPartitionValueSingularAttribute : BUSINESS_OBJECT_DATA_SUBPARTITIONS) {
        predicate = builder.and(predicate, builder.or(
                builder.and(
                        builder.isNull(subBusinessObjectDataEntity
                                .get(businessObjectDataPartitionValueSingularAttribute)),
                        builder.isNull(mainBusinessObjectDataEntity
                                .get(businessObjectDataPartitionValueSingularAttribute))),
                builder.equal(
                        subBusinessObjectDataEntity.get(businessObjectDataPartitionValueSingularAttribute),
                        mainBusinessObjectDataEntity.get(businessObjectDataPartitionValueSingularAttribute))));
    }

    return predicate;
}

From source file:org.finra.herd.dao.impl.BusinessObjectDataDaoImpl.java

@Override
public Map<BusinessObjectDataEntity, StoragePolicyEntity> getBusinessObjectDataEntitiesMatchingStoragePolicies(
        StoragePolicyPriorityLevel storagePolicyPriorityLevel, List<String> supportedBusinessObjectDataStatuses,
        int storagePolicyTransitionMaxAllowedAttempts, int startPosition, int maxResult) {
    // 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 along with the storage policy.
    Root<BusinessObjectDataEntity> businessObjectDataEntityRoot = criteria.from(BusinessObjectDataEntity.class);
    Root<StoragePolicyEntity> storagePolicyEntityRoot = criteria.from(StoragePolicyEntity.class);

    // Join to the other tables we can filter on.
    Join<BusinessObjectDataEntity, StorageUnitEntity> storageUnitEntityJoin = businessObjectDataEntityRoot
            .join(BusinessObjectDataEntity_.storageUnits);
    Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntityJoin = businessObjectDataEntityRoot
            .join(BusinessObjectDataEntity_.businessObjectFormat);

    // Create main query restrictions based on the specified parameters.
    List<Predicate> predicates = new ArrayList<>();

    // Add restriction on business object definition.
    predicates.add(storagePolicyPriorityLevel.isBusinessObjectDefinitionIsNull()
            ? builder.isNull(storagePolicyEntityRoot.get(StoragePolicyEntity_.businessObjectDefinitionId))
            : builder.equal(/*from w  ww .j  a v a  2 s.co m*/
                    businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.businessObjectDefinitionId),
                    storagePolicyEntityRoot.get(StoragePolicyEntity_.businessObjectDefinitionId)));

    // Add restriction on business object format usage.
    predicates.add(storagePolicyPriorityLevel.isUsageIsNull()
            ? builder.isNull(storagePolicyEntityRoot.get(StoragePolicyEntity_.usage))
            : builder.equal(
                    builder.upper(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.usage)),
                    builder.upper(storagePolicyEntityRoot.get(StoragePolicyEntity_.usage))));

    // Add restriction on business object format file type.
    predicates.add(storagePolicyPriorityLevel.isFileTypeIsNull()
            ? builder.isNull(storagePolicyEntityRoot.get(StoragePolicyEntity_.fileType))
            : builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.fileTypeCode),
                    storagePolicyEntityRoot.get(StoragePolicyEntity_.fileTypeCode)));

    // Add restriction on storage policy filter storage.
    predicates.add(builder.equal(storageUnitEntityJoin.get(StorageUnitEntity_.storageName),
            storagePolicyEntityRoot.get(StoragePolicyEntity_.storageName)));

    // Add restriction on storage policy latest version flag.
    predicates.add(builder.isTrue(storagePolicyEntityRoot.get(StoragePolicyEntity_.latestVersion)));

    // Add restriction on storage policy status.
    predicates.add(builder.equal(storagePolicyEntityRoot.get(StoragePolicyEntity_.statusCode),
            StoragePolicyStatusEntity.ENABLED));

    // Add restriction on supported business object data statuses.
    predicates.add(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.statusCode)
            .in(supportedBusinessObjectDataStatuses));

    // Add restrictions as per storage policy transition type.
    predicates.add(
            builder.equal(storagePolicyEntityRoot.get(StoragePolicyEntity_.storagePolicyTransitionTypeCode),
                    StoragePolicyTransitionTypeEntity.GLACIER));
    predicates.add(storageUnitEntityJoin.get(StorageUnitEntity_.statusCode)
            .in(Lists.newArrayList(StorageUnitStatusEntity.ENABLED, StorageUnitStatusEntity.ARCHIVING)));

    // If specified, add restriction on maximum allowed attempts for a storage policy transition.
    if (storagePolicyTransitionMaxAllowedAttempts > 0) {
        predicates.add(builder.or(
                builder.isNull(
                        storageUnitEntityJoin.get(StorageUnitEntity_.storagePolicyTransitionFailedAttempts)),
                builder.lessThan(
                        storageUnitEntityJoin.get(StorageUnitEntity_.storagePolicyTransitionFailedAttempts),
                        storagePolicyTransitionMaxAllowedAttempts)));
    }

    // Order the results by business object data "created on" value.
    Order orderByCreatedOn = builder.asc(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.createdOn));

    // Add the select clause to the main query.
    criteria.multiselect(businessObjectDataEntityRoot, storagePolicyEntityRoot);

    // Add the where clause to the main query.
    criteria.where(predicates.toArray(new Predicate[] {}));

    // Add the order by clause to the main query.
    criteria.orderBy(orderByCreatedOn);

    // Run the query to get a list of tuples back.
    List<Tuple> tuples = entityManager.createQuery(criteria).setFirstResult(startPosition)
            .setMaxResults(maxResult).getResultList();

    // Populate the result map from the returned tuples (i.e. 1 tuple for each row).
    Map<BusinessObjectDataEntity, StoragePolicyEntity> result = new LinkedHashMap<>();
    for (Tuple tuple : tuples) {
        // Since multiple storage policies can contain identical filters, we add the below check to select each business object data instance only once.
        if (!result.containsKey(tuple.get(businessObjectDataEntityRoot))) {
            result.put(tuple.get(businessObjectDataEntityRoot), tuple.get(storagePolicyEntityRoot));
        }
    }

    return result;
}

From source file:org.finra.herd.dao.impl.BusinessObjectDataDaoImpl.java

/**
 * Apply retention expiration filter to the main query predicate.
 *
 * @param businessObjectDataSearchKey the business object data search key
 * @param businessObjectDataEntityRoot the criteria root which is a business object data entity
 * @param businessObjectFormatEntityJoin the join with the business object format table
 * @param builder the criteria builder//w w  w  .  j a v a  2s  . c  o  m
 * @param mainQueryPredicate the main query predicate to be updated
 *
 * @return the updated main query predicate
 */
private Predicate applyRetentionExpirationFilter(BusinessObjectDataSearchKey businessObjectDataSearchKey,
        Root<BusinessObjectDataEntity> businessObjectDataEntityRoot,
        Join<BusinessObjectDataEntity, BusinessObjectFormatEntity> businessObjectFormatEntityJoin,
        CriteriaBuilder builder, Predicate mainQueryPredicate) {
    // Create a business object definition key per specified search key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(
            businessObjectDataSearchKey.getNamespace(),
            businessObjectDataSearchKey.getBusinessObjectDefinitionName());

    // Get latest versions of all business object formats that registered with the business object definition.
    List<BusinessObjectFormatEntity> businessObjectFormatEntities = businessObjectFormatDao
            .getLatestVersionBusinessObjectFormatsByBusinessObjectDefinition(businessObjectDefinitionKey);

    // Create a result predicate to join all retention expiration predicates created per selected business object formats.
    Predicate businessObjectDefinitionRetentionExpirationPredicate = null;

    // Get the current database timestamp to be used to select expired business object data per BDATA_RETENTION_DATE retention type.
    Timestamp currentTimestamp = getCurrentTimestamp();

    // Create a predicate for each business object format with the retention information.
    for (BusinessObjectFormatEntity businessObjectFormatEntity : businessObjectFormatEntities) {
        if (businessObjectFormatEntity.getRetentionType() != null) {
            // Create a retention expiration predicate for this business object format.
            Predicate businessObjectFormatRetentionExpirationPredicate = null;

            if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(),
                    RetentionTypeEntity.BDATA_RETENTION_DATE)) {
                // Select business object data that has expired per its explicitly configured retention expiration date.
                businessObjectFormatRetentionExpirationPredicate = builder.lessThan(
                        businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.retentionExpiration),
                        currentTimestamp);
            } else if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(),
                    RetentionTypeEntity.PARTITION_VALUE)
                    && businessObjectFormatEntity.getRetentionPeriodInDays() != null) {
                // Compute the retention expiration date and convert it to the date format to match against partition values.
                String retentionExpirationDate = DateFormatUtils.format(
                        DateUtils.addDays(new Date(),
                                -1 * businessObjectFormatEntity.getRetentionPeriodInDays()),
                        DEFAULT_SINGLE_DAY_DATE_MASK);

                // Create a predicate to compare business object data primary partition value against the retention expiration date.
                businessObjectFormatRetentionExpirationPredicate = builder.lessThan(
                        businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.partitionValue),
                        retentionExpirationDate);
            }

            // If it was initialize, complete processing of retention expiration predicate for this business object format.
            if (businessObjectFormatRetentionExpirationPredicate != null) {
                // Update the predicate to match this business object format w/o version.
                businessObjectFormatRetentionExpirationPredicate = builder.and(
                        businessObjectFormatRetentionExpirationPredicate,
                        builder.equal(
                                builder.upper(
                                        businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.usage)),
                                businessObjectFormatEntity.getUsage().toUpperCase()));
                businessObjectFormatRetentionExpirationPredicate = builder.and(
                        businessObjectFormatRetentionExpirationPredicate,
                        builder.equal(businessObjectFormatEntityJoin.get(BusinessObjectFormatEntity_.fileType),
                                businessObjectFormatEntity.getFileType()));

                // Add this business object format specific retention expiration predicate to other
                // retention expiration predicates created for the specified business object definition.
                if (businessObjectDefinitionRetentionExpirationPredicate == null) {
                    businessObjectDefinitionRetentionExpirationPredicate = businessObjectFormatRetentionExpirationPredicate;
                } else {
                    businessObjectDefinitionRetentionExpirationPredicate = builder.or(
                            businessObjectDefinitionRetentionExpirationPredicate,
                            businessObjectFormatRetentionExpirationPredicate);
                }
            }
        }
    }

    // Fail if no retention expiration predicates got created per specified business objject definition.
    Assert.notNull(businessObjectDefinitionRetentionExpirationPredicate, String.format(
            "Business object definition with name \"%s\" and namespace \"%s\" has no business object formats with supported retention type.",
            businessObjectDefinitionKey.getBusinessObjectDefinitionName(),
            businessObjectDefinitionKey.getNamespace()));

    // Add created business object definition retention expiration predicate to the main query predicate passed to this method and return the result.
    return builder.and(mainQueryPredicate, businessObjectDefinitionRetentionExpirationPredicate);
}

From source file:org.finra.herd.dao.impl.BusinessObjectDataNotificationRegistrationDaoImpl.java

@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(/*w  ww .j ava2  s .  co  m*/
            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);
}

From source file:org.finra.herd.dao.impl.BusinessObjectDataNotificationRegistrationDaoImpl.java

@Override
public List<BusinessObjectDataNotificationRegistrationEntity> getBusinessObjectDataNotificationRegistrations(
        String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey,
        String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus,
        String notificationRegistrationStatus) {
    // 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> businessObjectDataNotificationEntityRoot = criteria
            .from(BusinessObjectDataNotificationRegistrationEntity.class);

    // Join to the other tables we can filter on.
    Join<BusinessObjectDataNotificationRegistrationEntity, NamespaceEntity> namespaceEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.namespace);
    Join<BusinessObjectDataNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.notificationEventType);
    Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.businessObjectDefinition);
    Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntityJoin = businessObjectDefinitionEntityJoin
            .join(BusinessObjectDefinitionEntity_.namespace);
    Join<BusinessObjectDataNotificationRegistrationEntity, FileTypeEntity> fileTypeEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.fileType, JoinType.LEFT);
    Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> newBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus, JoinType.LEFT);
    Join<BusinessObjectDataNotificationRegistrationEntity, BusinessObjectDataStatusEntity> oldBusinessObjectDataStatusEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus, JoinType.LEFT);
    Join<BusinessObjectDataNotificationRegistrationEntity, NotificationRegistrationStatusEntity> notificationRegistrationStatusEntityJoin = businessObjectDataNotificationEntityRoot
            .join(BusinessObjectDataNotificationRegistrationEntity_.notificationRegistrationStatus);

    // Create the standard restrictions (i.e. the standard where clauses).
    List<Predicate> predicates = new ArrayList<>();
    predicates.add(//from  w  w  w  .jav  a 2  s  .  com
            builder.equal(builder.upper(notificationEventTypeEntityJoin.get(NotificationEventTypeEntity_.code)),
                    notificationEventTypeCode.toUpperCase()));
    predicates.add(
            builder.equal(builder.upper(businessObjectDefinitionNamespaceEntityJoin.get(NamespaceEntity_.code)),
                    businessObjectDataKey.getNamespace().toUpperCase()));
    predicates.add(builder.equal(
            builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)),
            businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase()));
    predicates.add(builder.or(
            builder.isNull(businessObjectDataNotificationEntityRoot
                    .get(BusinessObjectDataNotificationRegistrationEntity_.usage)),
            builder.equal(
                    builder.upper(businessObjectDataNotificationEntityRoot
                            .get(BusinessObjectDataNotificationRegistrationEntity_.usage)),
                    businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase())));
    predicates.add(builder.or(
            builder.isNull(businessObjectDataNotificationEntityRoot
                    .get(BusinessObjectDataNotificationRegistrationEntity_.fileType)),
            builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)),
                    businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase())));
    predicates.add(builder.or(
            builder.isNull(businessObjectDataNotificationEntityRoot
                    .get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion)),
            builder.equal(
                    businessObjectDataNotificationEntityRoot
                            .get(BusinessObjectDataNotificationRegistrationEntity_.businessObjectFormatVersion),
                    businessObjectDataKey.getBusinessObjectFormatVersion())));
    predicates.add(builder.or(
            builder.isNull(businessObjectDataNotificationEntityRoot
                    .get(BusinessObjectDataNotificationRegistrationEntity_.newBusinessObjectDataStatus)),
            builder.equal(
                    builder.upper(
                            newBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)),
                    newBusinessObjectDataStatus.toUpperCase())));
    // Please note that old business object data status parameter value is null for a business object data registration event.
    predicates.add(builder.or(
            builder.isNull(businessObjectDataNotificationEntityRoot
                    .get(BusinessObjectDataNotificationRegistrationEntity_.oldBusinessObjectDataStatus)),
            builder.equal(
                    builder.upper(
                            oldBusinessObjectDataStatusEntityJoin.get(BusinessObjectDataStatusEntity_.code)),
                    oldBusinessObjectDataStatus == null ? null : oldBusinessObjectDataStatus.toUpperCase())));
    predicates.add(builder.equal(
            builder.upper(
                    notificationRegistrationStatusEntityJoin.get(NotificationRegistrationStatusEntity_.code)),
            notificationRegistrationStatus.toUpperCase()));

    // Order the results by namespace and notification name.
    List<Order> orderBy = new ArrayList<>();
    orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
    orderBy.add(builder.asc(businessObjectDataNotificationEntityRoot
            .get(BusinessObjectDataNotificationRegistrationEntity_.name)));

    // Add the clauses for the query.
    criteria.select(businessObjectDataNotificationEntityRoot)
            .where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);

    // Execute the query and return the results.
    return entityManager.createQuery(criteria).getResultList();
}

From source file:org.finra.herd.dao.impl.StorageUnitNotificationRegistrationDaoImpl.java

@Override
public List<NotificationRegistrationKey> getStorageUnitNotificationRegistrationKeysByNotificationFilter(
        StorageUnitNotificationFilter 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 storage unit notification registration.
    Root<StorageUnitNotificationRegistrationEntity> notificationRegistrationEntityRoot = criteria
            .from(StorageUnitNotificationRegistrationEntity.class);

    // Join to the other tables we can filter on.
    Join<StorageUnitNotificationRegistrationEntity, NamespaceEntity> notificationRegistrationNamespaceEntityJoin = notificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.namespace);
    Join<StorageUnitNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = notificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.businessObjectDefinition);
    Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntity = businessObjectDefinitionEntity
            .join(BusinessObjectDefinitionEntity_.namespace);
    Join<StorageUnitNotificationRegistrationEntity, FileTypeEntity> fileTypeEntity = notificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.fileType, JoinType.LEFT);

    // Get the columns.
    Path<String> notificationRegistrationNamespaceColumn = notificationRegistrationNamespaceEntityJoin
            .get(NamespaceEntity_.code);
    Path<String> notificationRegistrationNameColumn = notificationRegistrationEntityRoot
            .get(StorageUnitNotificationRegistrationEntity_.name);

    // Create the standard restrictions (i.e. the standard where clauses).
    List<Predicate> predicates = new ArrayList<>();
    predicates.add(//from  www.ja  va2  s  . c  om
            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(StorageUnitNotificationRegistrationEntity_.usage)),
                builder.equal(
                        builder.upper(notificationRegistrationEntityRoot
                                .get(StorageUnitNotificationRegistrationEntity_.usage)),
                        businessObjectDataNotificationFilter.getBusinessObjectFormatUsage().toUpperCase())));
    }
    if (StringUtils.isNotBlank(businessObjectDataNotificationFilter.getBusinessObjectFormatFileType())) {
        predicates.add(builder.or(
                builder.isNull(notificationRegistrationEntityRoot
                        .get(StorageUnitNotificationRegistrationEntity_.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);
}

From source file:org.finra.herd.dao.impl.StorageUnitNotificationRegistrationDaoImpl.java

@Override
public List<StorageUnitNotificationRegistrationEntity> getStorageUnitNotificationRegistrations(
        String notificationEventTypeCode, BusinessObjectDataKey businessObjectDataKey, String storageName,
        String newStorageUnitStatus, String oldStorageUnitStatus, String notificationRegistrationStatus) {
    // Create the criteria builder and the criteria.
    CriteriaBuilder builder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StorageUnitNotificationRegistrationEntity> criteria = builder
            .createQuery(StorageUnitNotificationRegistrationEntity.class);

    // The criteria root is the storage unit notification registration entity.
    Root<StorageUnitNotificationRegistrationEntity> storageUnitNotificationRegistrationEntityRoot = criteria
            .from(StorageUnitNotificationRegistrationEntity.class);

    // Join to the other tables we can filter on.
    Join<StorageUnitNotificationRegistrationEntity, NamespaceEntity> namespaceEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.namespace);
    Join<StorageUnitNotificationRegistrationEntity, NotificationEventTypeEntity> notificationEventTypeEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.notificationEventType);
    Join<StorageUnitNotificationRegistrationEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.businessObjectDefinition);
    Join<BusinessObjectDefinitionEntity, NamespaceEntity> businessObjectDefinitionNamespaceEntityJoin = businessObjectDefinitionEntityJoin
            .join(BusinessObjectDefinitionEntity_.namespace);
    Join<StorageUnitNotificationRegistrationEntity, StorageEntity> storageEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.storage);
    Join<StorageUnitNotificationRegistrationEntity, FileTypeEntity> fileTypeEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.fileType, JoinType.LEFT);
    Join<StorageUnitNotificationRegistrationEntity, StorageUnitStatusEntity> newStorageUnitStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.newStorageUnitStatus, JoinType.LEFT);
    Join<StorageUnitNotificationRegistrationEntity, StorageUnitStatusEntity> oldStorageUnitStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.oldStorageUnitStatus, JoinType.LEFT);
    Join<StorageUnitNotificationRegistrationEntity, NotificationRegistrationStatusEntity> notificationRegistrationStatusEntityJoin = storageUnitNotificationRegistrationEntityRoot
            .join(StorageUnitNotificationRegistrationEntity_.notificationRegistrationStatus);

    // 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(builder.upper(notificationEventTypeEntityJoin.get(NotificationEventTypeEntity_.code)),
                    notificationEventTypeCode.toUpperCase()));
    predicates.add(
            builder.equal(builder.upper(businessObjectDefinitionNamespaceEntityJoin.get(NamespaceEntity_.code)),
                    businessObjectDataKey.getNamespace().toUpperCase()));
    predicates.add(builder.equal(
            builder.upper(businessObjectDefinitionEntityJoin.get(BusinessObjectDefinitionEntity_.name)),
            businessObjectDataKey.getBusinessObjectDefinitionName().toUpperCase()));
    predicates.add(builder.equal(builder.upper(storageEntityJoin.get(StorageEntity_.name)),
            storageName.toUpperCase()));
    predicates.add(builder.or(
            builder.isNull(storageUnitNotificationRegistrationEntityRoot
                    .get(StorageUnitNotificationRegistrationEntity_.usage)),
            builder.equal(
                    builder.upper(storageUnitNotificationRegistrationEntityRoot
                            .get(StorageUnitNotificationRegistrationEntity_.usage)),
                    businessObjectDataKey.getBusinessObjectFormatUsage().toUpperCase())));
    predicates.add(builder.or(
            builder.isNull(storageUnitNotificationRegistrationEntityRoot
                    .get(StorageUnitNotificationRegistrationEntity_.fileType)),
            builder.equal(builder.upper(fileTypeEntityJoin.get(FileTypeEntity_.code)),
                    businessObjectDataKey.getBusinessObjectFormatFileType().toUpperCase())));
    predicates.add(builder.or(
            builder.isNull(storageUnitNotificationRegistrationEntityRoot
                    .get(StorageUnitNotificationRegistrationEntity_.businessObjectFormatVersion)),
            builder.equal(
                    storageUnitNotificationRegistrationEntityRoot
                            .get(StorageUnitNotificationRegistrationEntity_.businessObjectFormatVersion),
                    businessObjectDataKey.getBusinessObjectFormatVersion())));
    predicates.add(builder.or(
            builder.isNull(storageUnitNotificationRegistrationEntityRoot
                    .get(StorageUnitNotificationRegistrationEntity_.newStorageUnitStatus)),
            builder.equal(builder.upper(newStorageUnitStatusEntityJoin.get(StorageUnitStatusEntity_.code)),
                    newStorageUnitStatus.toUpperCase())));
    // Please note that old business object data status parameter value is null for a business object data registration event.
    predicates.add(builder.or(
            builder.isNull(storageUnitNotificationRegistrationEntityRoot
                    .get(StorageUnitNotificationRegistrationEntity_.oldStorageUnitStatus)),
            builder.equal(builder.upper(oldStorageUnitStatusEntityJoin.get(StorageUnitStatusEntity_.code)),
                    oldStorageUnitStatus == null ? null : oldStorageUnitStatus.toUpperCase())));
    predicates.add(builder.equal(
            builder.upper(
                    notificationRegistrationStatusEntityJoin.get(NotificationRegistrationStatusEntity_.code)),
            notificationRegistrationStatus.toUpperCase()));

    // Order the results by namespace and notification name.
    List<Order> orderBy = new ArrayList<>();
    orderBy.add(builder.asc(namespaceEntityJoin.get(NamespaceEntity_.code)));
    orderBy.add(builder.asc(storageUnitNotificationRegistrationEntityRoot
            .get(StorageUnitNotificationRegistrationEntity_.name)));

    // Add the clauses for the query.
    criteria.select(storageUnitNotificationRegistrationEntityRoot)
            .where(builder.and(predicates.toArray(new Predicate[predicates.size()]))).orderBy(orderBy);

    // Execute the query and return the results.
    return entityManager.createQuery(criteria).getResultList();
}

From source file:org.jasig.portal.events.aggr.JpaBaseAggregationDao.java

@Override
public final void afterPropertiesSet() throws Exception {
    this.timeDimensionParameter = this.createParameterExpression(TimeDimension.class, "timeDimension");
    this.dateDimensionParameter = this.createParameterExpression(DateDimension.class, "dateDimension");
    this.intervalParameter = this.createParameterExpression(AggregationInterval.class, "interval");
    this.aggregatedGroupParameter = this.createParameterExpression(AggregatedGroupMapping.class,
            "aggregatedGroup");
    this.aggregatedGroupsParameter = this.createParameterExpression(Set.class, "aggregatedGroups");
    this.startDate = this.createParameterExpression(LocalDate.class, "startDate");
    this.endMinusOneDate = this.createParameterExpression(LocalDate.class, "endMinusOneDate");
    this.endDate = this.createParameterExpression(LocalDate.class, "endDate");
    this.startTime = this.createParameterExpression(LocalTime.class, "startTime");
    this.endTime = this.createParameterExpression(LocalTime.class, "endTime");
    this.createParameterExpressions();

    this.findAggregationByDateTimeIntervalQuery = this
            .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<T>>() {
                @Override// w ww .  ja  v a 2 s.  co  m
                public CriteriaQuery<T> apply(CriteriaBuilder cb) {
                    final CriteriaQuery<T> criteriaQuery = cb.createQuery(aggregationEntityType);

                    final Root<T> ba = criteriaQuery.from(aggregationEntityType);

                    addFetches(ba);

                    criteriaQuery.select(ba);
                    criteriaQuery.where(
                            cb.equal(ba.get(BaseAggregationImpl_.dateDimension), dateDimensionParameter),
                            cb.equal(ba.get(BaseAggregationImpl_.timeDimension), timeDimensionParameter),
                            cb.equal(ba.get(BaseAggregationImpl_.interval), intervalParameter));

                    return criteriaQuery;
                }
            });

    this.findAggregationByDateTimeIntervalGroupQuery = this
            .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<T>>() {
                @Override
                public CriteriaQuery<T> apply(CriteriaBuilder cb) {
                    final CriteriaQuery<T> criteriaQuery = cb.createQuery(aggregationEntityType);
                    final Root<T> ba = criteriaQuery.from(aggregationEntityType);

                    final List<Predicate> keyPredicates = new ArrayList<Predicate>();
                    keyPredicates
                            .add(cb.equal(ba.get(BaseAggregationImpl_.dateDimension), dateDimensionParameter));
                    keyPredicates
                            .add(cb.equal(ba.get(BaseAggregationImpl_.timeDimension), timeDimensionParameter));
                    keyPredicates.add(cb.equal(ba.get(BaseAggregationImpl_.interval), intervalParameter));
                    keyPredicates.add(
                            cb.equal(ba.get(BaseAggregationImpl_.aggregatedGroup), aggregatedGroupParameter));
                    addAggregationSpecificKeyPredicate(cb, ba, keyPredicates);

                    criteriaQuery.select(ba);
                    criteriaQuery.where(keyPredicates.toArray(new Predicate[keyPredicates.size()]));

                    return criteriaQuery;
                }
            });

    this.findAggregationsByDateRangeQuery = this
            .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<T>>() {
                @Override
                public CriteriaQuery<T> apply(CriteriaBuilder cb) {
                    final CriteriaQuery<T> criteriaQuery = cb.createQuery(aggregationEntityType);

                    final Root<T> ba = criteriaQuery.from(aggregationEntityType);
                    final Join<T, DateDimensionImpl> dd = ba.join(BaseAggregationImpl_.dateDimension,
                            JoinType.LEFT);
                    final Join<T, TimeDimensionImpl> td = ba.join(BaseAggregationImpl_.timeDimension,
                            JoinType.LEFT);

                    final List<Predicate> keyPredicates = new ArrayList<Predicate>();
                    keyPredicates.add(cb.and( //Restrict results by outer date range
                            cb.greaterThanOrEqualTo(dd.get(DateDimensionImpl_.date), startDate),
                            cb.lessThan(dd.get(DateDimensionImpl_.date), endDate)));
                    keyPredicates.add(cb.or( //Restrict start of range by time as well
                            cb.greaterThan(dd.get(DateDimensionImpl_.date), startDate),
                            cb.greaterThanOrEqualTo(td.get(TimeDimensionImpl_.time), startTime)));
                    keyPredicates.add(cb.or( //Restrict end of range by time as well
                            cb.lessThan(dd.get(DateDimensionImpl_.date), endMinusOneDate),
                            cb.lessThan(td.get(TimeDimensionImpl_.time), endTime)));
                    keyPredicates.add(cb.equal(ba.get(BaseAggregationImpl_.interval), intervalParameter));
                    keyPredicates
                            .add(ba.get(BaseAggregationImpl_.aggregatedGroup).in(aggregatedGroupsParameter));
                    addAggregationSpecificKeyPredicate(cb, ba, keyPredicates);

                    criteriaQuery.select(ba);
                    criteriaQuery.where(keyPredicates.toArray(new Predicate[keyPredicates.size()]));
                    criteriaQuery.orderBy(cb.desc(dd.get(DateDimensionImpl_.date)),
                            cb.desc(td.get(TimeDimensionImpl_.time)));

                    return criteriaQuery;
                }
            });

    /*
     * Similar to the previous query but only returns aggregates that also match the unclosed predicate generated
     * by the subclass. This is used for finding aggregates that missed having intervalComplete called due to
     * interval boundary placement.
     */
    this.findUnclosedAggregationsByDateRangeQuery = this
            .createCriteriaQuery(new Function<CriteriaBuilder, CriteriaQuery<T>>() {
                @Override
                public CriteriaQuery<T> apply(CriteriaBuilder cb) {
                    final CriteriaQuery<T> criteriaQuery = cb.createQuery(aggregationEntityType);

                    final Root<T> ba = criteriaQuery.from(aggregationEntityType);
                    final Join<T, DateDimensionImpl> dd = ba.join(BaseAggregationImpl_.dateDimension,
                            JoinType.LEFT);
                    final Join<T, TimeDimensionImpl> td = ba.join(BaseAggregationImpl_.timeDimension,
                            JoinType.LEFT);

                    addFetches(ba);

                    final List<Predicate> keyPredicates = new ArrayList<Predicate>();
                    keyPredicates.add(cb.and( //Restrict results by outer date range
                            cb.greaterThanOrEqualTo(dd.get(DateDimensionImpl_.date), startDate),
                            cb.lessThan(dd.get(DateDimensionImpl_.date), endDate)));
                    keyPredicates.add(cb.or( //Restrict start of range by time as well
                            cb.greaterThan(dd.get(DateDimensionImpl_.date), startDate),
                            cb.greaterThanOrEqualTo(td.get(TimeDimensionImpl_.time), startTime)));
                    keyPredicates.add(cb.or( //Restrict end of range by time as well
                            cb.lessThan(dd.get(DateDimensionImpl_.date), endMinusOneDate),
                            cb.lessThan(td.get(TimeDimensionImpl_.time), endTime)));
                    keyPredicates.add(cb.equal(ba.get(BaseAggregationImpl_.interval), intervalParameter));
                    //No aggregation specific key bits here, we only have start/end/interval parameters to work with
                    addUnclosedPredicate(cb, ba, keyPredicates);

                    criteriaQuery.select(ba);
                    criteriaQuery.where(keyPredicates.toArray(new Predicate[keyPredicates.size()]));

                    return criteriaQuery;
                }
            });

    this.createCriteriaQueries();
}

From source file:org.niord.core.publication.PublicationService.java

/**
 * Searches for a page of publication IDs matching the given search parameters
 * Will also update the search result with the total number of matches
 *
 * @param params the search parameters//from  ww w .  ja  v  a  2 s . c om
 * @param result the result structure to update with the total number of matches
 * @return a page of publication IDs matching the given search parameters
 */
@SuppressWarnings("all")
public List<Integer> searchPagedPublicationIds(PublicationSearchParams params,
        PagedSearchResultVo<Publication> result) {

    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Tuple> tupleQuery = cb.createTupleQuery();

    Root<Publication> publicationRoot = tupleQuery.from(Publication.class);

    // Build the predicate
    CriteriaHelper<Tuple> criteriaHelper = CriteriaHelper.initWithTupleQuery(em);

    // Match the main type
    criteriaHelper.equals(publicationRoot.get("mainType"), params.getMainType());

    // Match the file type
    criteriaHelper.equals(publicationRoot.get("type"), params.getType());

    // Match the status
    if (params.getStatuses() != null && !params.getStatuses().isEmpty()) {
        criteriaHelper.in(publicationRoot.get("status"), params.getStatuses());
    }

    // Match the title
    if (StringUtils.isNotBlank(params.getTitle())) {
        Join<Publication, PublicationDesc> descs = publicationRoot.join("descs", JoinType.LEFT);
        criteriaHelper.like(descs.get("title"), params.getTitle());

        // Optionally, match the language
        if (StringUtils.isNotBlank(params.getLanguage())) {
            criteriaHelper.equals(descs.get("lang"), params.getLanguage());
        }
    }

    // Match the category
    Join<Publication, PublicationCategory> typeJoin = publicationRoot.join("category", JoinType.LEFT);
    if (StringUtils.isNotBlank(params.getCategory())) {
        criteriaHelper.equals(typeJoin.get("categoryId"), params.getCategory());
    }

    // Match the publish flag of the category
    if (params.getPublished() != null) {
        criteriaHelper.equals(typeJoin.get("publish"), params.getPublished());
    }

    // Match the domain
    if (StringUtils.isNotBlank(params.getDomain())) {
        Join<Publication, Domain> domainJoin = publicationRoot.join("domain", JoinType.LEFT);
        criteriaHelper.add(cb.or(cb.isNull(publicationRoot.get("domain")),
                cb.equal(domainJoin.get("domainId"), params.getDomain())));
    }

    // Match the message publication category
    criteriaHelper.equals(publicationRoot.get("messagePublication"), params.getMessagePublication());

    // Filter by dates
    if (params.getFrom() != null || params.getTo() != null) {
        Date from = params.getFrom(); //TimeUtils.resetTime(params.getFrom());
        Date to = params.getTo(); //TimeUtils.endOfDay(params.getTo());
        criteriaHelper.overlaps(publicationRoot.get("publishDateFrom"), publicationRoot.get("publishDateTo"),
                from, to);
    }

    // Compute the sort order
    List<Order> sortOrders = new ArrayList<>();
    sortOrders.add(cb.asc(typeJoin.get("priority")));
    sortOrders.add(cb.desc(publicationRoot.get("publishDateFrom")));

    // Select ID field + fields used for sorting
    List<Selection<?>> fields = new ArrayList<>();
    fields.add(publicationRoot.get("id"));
    fields.add(typeJoin.get("priority"));
    fields.add(publicationRoot.get("publishDateFrom"));
    Selection[] f = fields.toArray(new Selection<?>[fields.size()]);

    // Complete the query
    tupleQuery.multiselect(f).distinct(true).where(criteriaHelper.where()).orderBy(sortOrders);

    // Execute the query
    List<Tuple> totalResult = em.createQuery(tupleQuery).getResultList();

    // Register the total result
    result.setTotal(totalResult.size());

    List<Integer> publicationIds = totalResult.stream().map(t -> (Integer) t.get(0))
            .collect(Collectors.toList());

    // Extract and return the paged sub-list
    int startIndex = Math.min(publicationIds.size(), params.getPage() * params.getMaxSize());
    int endIndex = Math.min(publicationIds.size(), startIndex + params.getMaxSize());
    return publicationIds.subList(startIndex, endIndex);
}

From source file:org.sparkcommerce.core.catalog.dao.ProductDaoImpl.java

protected List<Product> readFilteredActiveProductsByQueryInternal(String query, Date currentDate,
        ProductSearchCriteria searchCriteria) {
    // Set up the criteria query that specifies we want to return Products
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Product> criteria = builder.createQuery(Product.class);

    // The root of our search is Product since we are searching
    Root<ProductImpl> product = criteria.from(ProductImpl.class);

    // We also want to filter on attributes from sku and productAttributes
    Join<Product, Sku> sku = product.join("defaultSku");

    // Product objects are what we want back
    criteria.select(product);//from www  .j  ava 2s. co m

    // We only want results that match the search query
    List<Predicate> restrictions = new ArrayList<Predicate>();
    String lq = query.toLowerCase();
    restrictions.add(builder.or(builder.like(builder.lower(sku.get("name").as(String.class)), '%' + lq + '%'),
            builder.like(builder.lower(sku.get("longDescription").as(String.class)), '%' + lq + '%')));

    attachProductSearchCriteria(searchCriteria, product, sku, restrictions);

    attachActiveRestriction(currentDate, product, sku, restrictions);

    attachOrderBy(searchCriteria, product, sku, criteria);

    // Execute the query with the restrictions
    criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));

    TypedQuery<Product> typedQuery = em.createQuery(criteria);
    //don't cache - not really practical for open ended search

    return typedQuery.getResultList();
}