/** * Creates an {@link JpaEntityGraph}. * * @param entityGraph must not be {@literal null}. * @param nameFallback must not be {@literal null} or empty. */ public JpaEntityGraph(EntityGraph entityGraph, String nameFallback) { this(StringUtils.hasText(entityGraph.value()) ? entityGraph.value() : nameFallback, entityGraph.type(), entityGraph .attributePaths()); }
/** * Retrieves an Action with all lazy attributes. * * @param actionId * the ID of the action * @return the found {@link Action} */ @EntityGraph(value = "Action.all", type = EntityGraphType.LOAD) Optional<Action> getById(Long actionId);
public List<V> findAll(Iterable<ID> idIterable) { Assert.notNull(idIterable, ID_MUST_NOT_BE_NULL); List<ID> idList = new ArrayList<>(); for (ID id : idIterable) { idList.add(id); } CriteriaBuilder<?> cb = cbf.create(entityManager, getDomainClass()) .where(idAttributeName).in(idList); String[] fetches = EMPTY; if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches); } TypedQuery<V> findAllByIdsQuery; Class<V> entityViewClass = metadata == null || metadata.getEntityViewClass() == null ? this.entityViewClass : (Class<V>) metadata.getEntityViewClass(); if (entityViewClass == null) { findAllByIdsQuery = (TypedQuery<V>) cb.getQuery(); } else { findAllByIdsQuery = evm.applySetting(EntityViewSetting.create(entityViewClass), cb).getQuery(); } applyRepositoryMethodMetadata(findAllByIdsQuery, fetches.length == 0); return findAllByIdsQuery.getResultList(); }
/** * Retrieves an Action with all lazy attributes. * * @param actionId * the ID of the action * @return the found {@link Action} */ @EntityGraph(value = "Action.all", type = EntityGraphType.LOAD) Optional<Action> getById(Long actionId);
public List<V> findAll(Iterable<ID> idIterable) { Assert.notNull(idIterable, ID_MUST_NOT_BE_NULL); List<ID> idList = new ArrayList<>(); for (ID id : idIterable) { idList.add(id); } CriteriaBuilder<?> cb = cbf.create(entityManager, getDomainClass()) .where(idAttributeName).in(idList); String[] fetches = EMPTY; if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches); } TypedQuery<V> findAllByIdsQuery; Class<V> entityViewClass = metadata == null || metadata.getEntityViewClass() == null ? this.entityViewClass : (Class<V>) metadata.getEntityViewClass(); if (entityViewClass == null) { findAllByIdsQuery = (TypedQuery<V>) cb.getQuery(); } else { findAllByIdsQuery = evm.applySetting(EntityViewSetting.create(entityViewClass), cb).getQuery(); } applyRepositoryMethodMetadata(findAllByIdsQuery, fetches.length == 0); return findAllByIdsQuery.getResultList(); }
/** * Finds all status updates for the defined action and target including * {@link ActionStatus#getMessages()}. * * @param pageReq * for page configuration * @param target * to look for * @param actionId * to look for * @return Page with found targets */ @EntityGraph(value = "ActionStatus.withMessages", type = EntityGraphType.LOAD) Page<ActionStatus> getByActionId(Pageable pageReq, Long actionId);
/** * Creates an {@link JpaEntityGraph}. * * @param entityGraph must not be {@literal null}. * @param nameFallback must not be {@literal null} or empty. */ public JpaEntityGraph(EntityGraph entityGraph, String nameFallback) { this(StringUtils.hasText(entityGraph.value()) ? entityGraph.value() : nameFallback, entityGraph.type(), entityGraph .attributePaths()); }
public V findOne(ID id) { Assert.notNull(id, ID_MUST_NOT_BE_NULL); CriteriaBuilder<?> cb = cbf.create(entityManager, getDomainClass()) .where(idAttributeName).eq(id); String[] fetches = EMPTY; if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches); } TypedQuery<V> findOneQuery; Class<V> entityViewClass = metadata == null || metadata.getEntityViewClass() == null ? this.entityViewClass : (Class<V>) metadata.getEntityViewClass(); if (entityViewClass == null) { findOneQuery = (TypedQuery<V>) cb.getQuery(); } else { findOneQuery = evm.applySetting(EntityViewSetting.create(entityViewClass), cb).getQuery(); } applyQueryHints(findOneQuery, fetches.length == 0); try { return findOneQuery.getSingleResult(); } catch (NoResultException e) { return null; } }
/** * Retrieves the oldest {@link Action} that is active and referring to the * given {@link Target}. * * @param sort * order * @param controllerId * the target to find assigned actions * @param active * the action active flag * * @return the found {@link Action} */ @EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD) Optional<Action> findFirstByTargetControllerIdAndActive(Sort sort, String controllerId, boolean active);
public V findOne(ID id) { Assert.notNull(id, ID_MUST_NOT_BE_NULL); CriteriaBuilder<?> cb = cbf.create(entityManager, getDomainClass()) .where(idAttributeName).eq(id); String[] fetches = EMPTY; if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches); } TypedQuery<V> findOneQuery; Class<V> entityViewClass = metadata == null || metadata.getEntityViewClass() == null ? this.entityViewClass : (Class<V>) metadata.getEntityViewClass(); if (entityViewClass == null) { findOneQuery = (TypedQuery<V>) cb.getQuery(); } else { findOneQuery = evm.applySetting(EntityViewSetting.create(entityViewClass), cb).getQuery(); } applyQueryHints(findOneQuery, fetches.length == 0); try { return findOneQuery.getSingleResult(); } catch (NoResultException e) { return null; } }
@EntityGraph(attributePaths = { "owner" }) public KeysetAwarePage<Cat> findAll(Specification<Cat> specification, Pageable pageable); }
if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches);
/** * Finds all status updates for the defined action and target including * {@link ActionStatus#getMessages()}. * * @param pageReq * for page configuration * @param target * to look for * @param actionId * to look for * @return Page with found targets */ @EntityGraph(value = "ActionStatus.withMessages", type = EntityGraphType.LOAD) Page<ActionStatus> getByActionId(Pageable pageReq, Long actionId);
if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches);
@EntityGraph(value = "StockProduct.detail", type = EntityGraphType.LOAD) Page<StockProduct> findByIndices(Index index, Pageable pageable); List<StockProduct> findByIdIn(List<String> asList);
/** * Retrieving all actions referring to the first group of a rollout. * * @param pageable * page parameters * @param rollout * the rollout the actions belong to * @param actionStatus * the status the actions have * @return the actions referring a specific rollout and a specific parent * rolloutgroup in a specific status */ @EntityGraph(attributePaths = { "target" }, type = EntityGraphType.LOAD) Page<Action> findByRolloutIdAndRolloutGroupParentIsNullAndStatus(Pageable pageable, Long rollout, Status actionStatus);
/** * Retrieving all actions referring to the first group of a rollout. * * @param pageable * page parameters * @param rollout * the rollout the actions belong to * @param actionStatus * the status the actions have * @return the actions referring a specific rollout and a specific parent * rolloutgroup in a specific status */ @EntityGraph(attributePaths = { "target" }, type = EntityGraphType.LOAD) Page<Action> findByRolloutIdAndRolloutGroupParentIsNullAndStatus(Pageable pageable, Long rollout, Status actionStatus);
/** * Retrieves the oldest {@link Action} that is active and referring to the * given {@link Target}. * * @param sort * order * @param controllerId * the target to find assigned actions * @param active * the action active flag * * @return the found {@link Action} */ @EntityGraph(value = "Action.ds", type = EntityGraphType.LOAD) Optional<Action> findFirstByTargetControllerIdAndActive(Sort sort, String controllerId, boolean active);
/** * Retrieving all actions referring to a given rollout with a specific * action as parent reference and a specific status. * * Finding all actions of a specific rolloutgroup parent relation. * * @param pageable * page parameters * @param rollout * the rollout the actions belong to * @param rolloutGroupParent * the parent rolloutgroup the actions should reference * @param actionStatus * the status the actions have * @return the actions referring a specific rollout and a specific parent * rolloutgroup in a specific status */ @EntityGraph(attributePaths = { "target" }, type = EntityGraphType.LOAD) Page<Action> findByRolloutIdAndRolloutGroupParentIdAndStatus(Pageable pageable, Long rollout, Long rolloutGroupParent, Status actionStatus);
/** * Retrieving all actions referring to a given rollout with a specific * action as parent reference and a specific status. * * Finding all actions of a specific rolloutgroup parent relation. * * @param pageable * page parameters * @param rollout * the rollout the actions belong to * @param rolloutGroupParent * the parent rolloutgroup the actions should reference * @param actionStatus * the status the actions have * @return the actions referring a specific rollout and a specific parent * rolloutgroup in a specific status */ @EntityGraph(attributePaths = { "target" }, type = EntityGraphType.LOAD) Page<Action> findByRolloutIdAndRolloutGroupParentIdAndStatus(Pageable pageable, Long rollout, Long rolloutGroupParent, Status actionStatus);