Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
See #3120
  • Loading branch information
gregturn committed Sep 12, 2023
1 parent 4a46dbe commit b11fae8
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ public void deleteAllInBatch(Iterable<T> entities) {
return;
}

applyAndBind(getQueryString(DELETE_ALL_QUERY_STRING, entityInformation.getEntityName()), entities,
entityManager)
applyAndBind(getQueryString(DELETE_ALL_QUERY_STRING, entityInformation.getEntityName()), entities, entityManager)
.executeUpdate();
}

Expand Down Expand Up @@ -305,7 +304,8 @@ public Optional<T> findById(ID id) {
LockModeType type = metadata.getLockModeType();
Map<String, Object> 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
Expand Down Expand Up @@ -484,17 +484,17 @@ public <S extends T> boolean exists(Example<S> example) {
@Override
public boolean exists(Specification<T> spec) {

CriteriaQuery<Integer> cq = this.em.getCriteriaBuilder().createQuery(Integer.class);
cq.select(this.em.getCriteriaBuilder().literal(1));
CriteriaQuery<Integer> cq = this.entityManager.getCriteriaBuilder().createQuery(Integer.class);
cq.select(this.entityManager.getCriteriaBuilder().literal(1));
applySpecificationToCriteria(spec, getDomainClass(), cq);
TypedQuery<Integer> query = applyRepositoryMethodMetadata(this.em.createQuery(cq));
TypedQuery<Integer> query = applyRepositoryMethodMetadata(this.entityManager.createQuery(cq));
return query.setMaxResults(1).getResultList().size() == 1;
}

@Override
public long delete(Specification<T> spec) {

CriteriaBuilder builder = this.em.getCriteriaBuilder();
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
CriteriaDelete<T> delete = builder.createCriteriaDelete(getDomainClass());

if (spec != null) {
Expand All @@ -505,7 +505,7 @@ public long delete(Specification<T> spec) {
}
}

return this.em.createQuery(delete).executeUpdate();
return this.entityManager.createQuery(delete).executeUpdate();
}

@Override
Expand Down Expand Up @@ -544,7 +544,7 @@ public <S extends T, R> R findBy(Example<S> example, Function<FetchableFluentQue
};

FetchableFluentQuery<S> fluentQuery = new FetchableFluentQueryByExample<>(example, finder, this::count,
this::exists, this.em, this.escapeCharacter);
this::exists, this.entityManager, this.escapeCharacter);

return queryFunction.apply(fluentQuery);
}
Expand All @@ -558,7 +558,7 @@ public <S extends T, R> R findBy(Specification<T> spec, Function<FetchableFluent
Function<Sort, TypedQuery<T>> finder = sort -> getQuery(spec, getDomainClass(), sort);

FetchableFluentQuery<R> fluentQuery = new FetchableFluentQueryBySpecification<T, R>(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<S>) fluentQuery);
}
Expand Down

0 comments on commit b11fae8

Please sign in to comment.