From b11fae8ff101e0e24b6eda51d1d58e03ef80ac74 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Tue, 12 Sep 2023 10:07:26 -0500 Subject: [PATCH] Polishing. See #3120 --- .../support/SimpleJpaRepository.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index 728e06d345..ea9a80fc67 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -266,8 +266,7 @@ public void deleteAllInBatch(Iterable entities) { return; } - applyAndBind(getQueryString(DELETE_ALL_QUERY_STRING, entityInformation.getEntityName()), entities, - entityManager) + applyAndBind(getQueryString(DELETE_ALL_QUERY_STRING, entityInformation.getEntityName()), entities, entityManager) .executeUpdate(); } @@ -305,7 +304,8 @@ public Optional findById(ID id) { LockModeType type = metadata.getLockModeType(); Map hints = getHints(); - return Optional.ofNullable(type == null ? entityManager.find(domainType, id, hints) : entityManager.find(domainType, id, type, hints)); + return Optional.ofNullable( + type == null ? entityManager.find(domainType, id, hints) : entityManager.find(domainType, id, type, hints)); } @Deprecated @@ -484,17 +484,17 @@ public boolean exists(Example example) { @Override public boolean exists(Specification spec) { - CriteriaQuery cq = this.em.getCriteriaBuilder().createQuery(Integer.class); - cq.select(this.em.getCriteriaBuilder().literal(1)); + CriteriaQuery cq = this.entityManager.getCriteriaBuilder().createQuery(Integer.class); + cq.select(this.entityManager.getCriteriaBuilder().literal(1)); applySpecificationToCriteria(spec, getDomainClass(), cq); - TypedQuery query = applyRepositoryMethodMetadata(this.em.createQuery(cq)); + TypedQuery query = applyRepositoryMethodMetadata(this.entityManager.createQuery(cq)); return query.setMaxResults(1).getResultList().size() == 1; } @Override public long delete(Specification spec) { - CriteriaBuilder builder = this.em.getCriteriaBuilder(); + CriteriaBuilder builder = this.entityManager.getCriteriaBuilder(); CriteriaDelete delete = builder.createCriteriaDelete(getDomainClass()); if (spec != null) { @@ -505,7 +505,7 @@ public long delete(Specification spec) { } } - return this.em.createQuery(delete).executeUpdate(); + return this.entityManager.createQuery(delete).executeUpdate(); } @Override @@ -544,7 +544,7 @@ public R findBy(Example example, Function fluentQuery = new FetchableFluentQueryByExample<>(example, finder, this::count, - this::exists, this.em, this.escapeCharacter); + this::exists, this.entityManager, this.escapeCharacter); return queryFunction.apply(fluentQuery); } @@ -558,7 +558,7 @@ public R findBy(Specification spec, Function> finder = sort -> getQuery(spec, getDomainClass(), sort); FetchableFluentQuery fluentQuery = new FetchableFluentQueryBySpecification(spec, getDomainClass(), - Sort.unsorted(), null, finder, this::count, this::exists, this.em); + Sort.unsorted(), null, finder, this::count, this::exists, this.entityManager); return queryFunction.apply((FetchableFluentQuery) fluentQuery); }