/** * 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()); }
/** * 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 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(); }
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(); }
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; } }
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; } }
if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches);
if (metadata != null && metadata.getEntityGraph() != null && (fetches = metadata.getEntityGraph().attributePaths()).length != 0) { cb.fetch(fetches);