Skip to content

Commit 1de082d

Browse files
committed
Resolved merge conflicts
2 parents fc1f167 + 91b0cb9 commit 1de082d

29 files changed

+146
-125
lines changed

src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java

+27-30
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.data.jpa.domain.Specification;
3030
import org.springframework.data.jpa.provider.PersistenceProvider;
3131
import org.springframework.data.jpa.repository.EntityGraph;
32-
import org.springframework.data.jpa.repository.query.DefaultQueryEnhancer;
3332
import org.springframework.data.jpa.repository.query.EscapeCharacter;
3433
import org.springframework.data.jpa.repository.query.QueryUtils;
3534
import org.springframework.data.jpa.repository.support.QueryHints.NoHints;
@@ -61,6 +60,7 @@
6160
* @author Jesse Wouters
6261
* @author Greg Turnquist
6362
* @author Yanming Zhou
63+
* @author Ernst-Jan van der Laan
6464
*/
6565
@Repository
6666
@Transactional(readOnly = true)
@@ -206,13 +206,22 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
206206
return;
207207
}
208208

209-
String queryString = String.format(DELETE_ALL_QUERY_BY_ID_STRING, entityInformation.getEntityName(),
210-
entityInformation.getIdAttribute().getName());
209+
if (entityInformation.hasCompositeId()) {
210+
211+
List<T> entities = new ArrayList<>();
212+
// generate entity (proxies) without accessing the database.
213+
ids.forEach(id -> entities.add(getReferenceById(id)));
214+
deleteAllInBatch(entities);
215+
} else {
211216

212-
Query query = em.createQuery(queryString);
213-
query.setParameter("ids", ids);
217+
String queryString = String.format(DELETE_ALL_QUERY_BY_ID_STRING, entityInformation.getEntityName(),
218+
entityInformation.getIdAttribute().getName());
214219

215-
query.executeUpdate();
220+
Query query = em.createQuery(queryString);
221+
query.setParameter("ids", ids);
222+
223+
query.executeUpdate();
224+
}
216225
}
217226

218227
/*
@@ -298,7 +307,6 @@ public Optional<T> findById(ID id) {
298307
* Returns {@link QueryHints} with the query hints based on the current {@link CrudMethodMetadata} and potential
299308
* {@link EntityGraph} information.
300309
*
301-
* @return
302310
*/
303311
protected QueryHints getQueryHints() {
304312
return metadata == null ? NoHints.INSTANCE : DefaultQueryHints.of(entityInformation, metadata);
@@ -403,7 +411,7 @@ public List<T> findAllById(Iterable<ID> ids) {
403411

404412
if (entityInformation.hasCompositeId()) {
405413

406-
List<T> results = new ArrayList<T>();
414+
List<T> results = new ArrayList<>();
407415

408416
for (ID id : ids) {
409417
findById(id).ifPresent(results::add);
@@ -414,7 +422,7 @@ public List<T> findAllById(Iterable<ID> ids) {
414422

415423
Collection<ID> idCollection = Streamable.of(ids).toList();
416424

417-
ByIdsSpecification<T> specification = new ByIdsSpecification<T>(entityInformation);
425+
ByIdsSpecification<T> specification = new ByIdsSpecification<>(entityInformation);
418426
TypedQuery<T> query = getQuery(specification, Sort.unsorted());
419427

420428
return query.setParameter(specification.parameter, idCollection).getResultList();
@@ -437,7 +445,7 @@ public List<T> findAll(Sort sort) {
437445
public Page<T> findAll(Pageable pageable) {
438446

439447
if (isUnpaged(pageable)) {
440-
return new PageImpl<T>(findAll());
448+
return new PageImpl<>(findAll());
441449
}
442450

443451
return findAll((Specification<T>) null, pageable);
@@ -474,7 +482,7 @@ public List<T> findAll(@Nullable Specification<T> spec) {
474482
public Page<T> findAll(@Nullable Specification<T> spec, Pageable pageable) {
475483

476484
TypedQuery<T> query = getQuery(spec, pageable);
477-
return isUnpaged(pageable) ? new PageImpl<T>(query.getResultList())
485+
return isUnpaged(pageable) ? new PageImpl<>(query.getResultList())
478486
: readPage(query, getDomainClass(), pageable, spec);
479487
}
480488

@@ -496,7 +504,7 @@ public <S extends T> Optional<S> findOne(Example<S> example) {
496504

497505
try {
498506
return Optional
499-
.of(getQuery(new ExampleSpecification<S>(example, escapeCharacter), example.getProbeType(), Sort.unsorted())
507+
.of(getQuery(new ExampleSpecification<>(example, escapeCharacter), example.getProbeType(), Sort.unsorted())
500508
.getSingleResult());
501509
} catch (NoResultException e) {
502510
return Optional.empty();
@@ -510,7 +518,7 @@ public <S extends T> Optional<S> findOne(Example<S> example) {
510518
@Override
511519
public <S extends T> long count(Example<S> example) {
512520
return executeCountQuery(
513-
getCountQuery(new ExampleSpecification<S>(example, escapeCharacter), example.getProbeType()));
521+
getCountQuery(new ExampleSpecification<>(example, escapeCharacter), example.getProbeType()));
514522
}
515523

516524
/*
@@ -534,7 +542,7 @@ public <S extends T> boolean exists(Example<S> example) {
534542
*/
535543
@Override
536544
public <S extends T> List<S> findAll(Example<S> example) {
537-
return getQuery(new ExampleSpecification<S>(example, escapeCharacter), example.getProbeType(), Sort.unsorted())
545+
return getQuery(new ExampleSpecification<>(example, escapeCharacter), example.getProbeType(), Sort.unsorted())
538546
.getResultList();
539547
}
540548

@@ -544,8 +552,7 @@ public <S extends T> List<S> findAll(Example<S> example) {
544552
*/
545553
@Override
546554
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
547-
return getQuery(new ExampleSpecification<S>(example, escapeCharacter), example.getProbeType(), sort)
548-
.getResultList();
555+
return getQuery(new ExampleSpecification<>(example, escapeCharacter), example.getProbeType(), sort).getResultList();
549556
}
550557

551558
/*
@@ -646,7 +653,7 @@ public <S extends T> List<S> saveAll(Iterable<S> entities) {
646653

647654
Assert.notNull(entities, "Entities must not be null!");
648655

649-
List<S> result = new ArrayList<S>();
656+
List<S> result = new ArrayList<>();
650657

651658
for (S entity : entities) {
652659
result.add(save(entity));
@@ -686,7 +693,6 @@ public void flush() {
686693
* @param query must not be {@literal null}.
687694
* @param spec can be {@literal null}.
688695
* @param pageable must not be {@literal null}.
689-
* @return
690696
* @deprecated use {@link #readPage(TypedQuery, Class, Pageable, Specification)} instead
691697
*/
692698
@Deprecated
@@ -702,7 +708,6 @@ protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, @Nullable Spe
702708
* @param domainClass must not be {@literal null}.
703709
* @param spec can be {@literal null}.
704710
* @param pageable can be {@literal null}.
705-
* @return
706711
*/
707712
protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> domainClass, Pageable pageable,
708713
@Nullable Specification<S> spec) {
@@ -721,7 +726,6 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> dom
721726
*
722727
* @param spec can be {@literal null}.
723728
* @param pageable must not be {@literal null}.
724-
* @return
725729
*/
726730
protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pageable) {
727731

@@ -735,7 +739,6 @@ protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pagea
735739
* @param spec can be {@literal null}.
736740
* @param domainClass must not be {@literal null}.
737741
* @param pageable must not be {@literal null}.
738-
* @return
739742
*/
740743
protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec, Class<S> domainClass,
741744
Pageable pageable) {
@@ -749,7 +752,6 @@ protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec,
749752
*
750753
* @param spec can be {@literal null}.
751754
* @param sort must not be {@literal null}.
752-
* @return
753755
*/
754756
protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Sort sort) {
755757
return getQuery(spec, getDomainClass(), sort);
@@ -761,7 +763,6 @@ protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Sort sort) {
761763
* @param spec can be {@literal null}.
762764
* @param domainClass must not be {@literal null}.
763765
* @param sort must not be {@literal null}.
764-
* @return
765766
*/
766767
protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec, Class<S> domainClass, Sort sort) {
767768

@@ -782,7 +783,6 @@ protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec,
782783
* Creates a new count query for the given {@link Specification}.
783784
*
784785
* @param spec can be {@literal null}.
785-
* @return
786786
* @deprecated override {@link #getCountQuery(Specification, Class)} instead
787787
*/
788788
@Deprecated
@@ -795,7 +795,6 @@ protected TypedQuery<Long> getCountQuery(@Nullable Specification<T> spec) {
795795
*
796796
* @param spec can be {@literal null}.
797797
* @param domainClass must not be {@literal null}.
798-
* @return
799798
*/
800799
protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S> spec, Class<S> domainClass) {
801800

@@ -811,7 +810,7 @@ protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S
811810
}
812811

813812
// Remove all Orders the Specifications might have applied
814-
query.orderBy(Collections.<Order> emptyList());
813+
query.orderBy(Collections.emptyList());
815814

816815
return em.createQuery(query);
817816
}
@@ -822,7 +821,6 @@ protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S
822821
* @param spec can be {@literal null}.
823822
* @param domainClass must not be {@literal null}.
824823
* @param query must not be {@literal null}.
825-
* @return
826824
*/
827825
private <S, U extends T> Root<U> applySpecificationToCriteria(@Nullable Specification<U> spec, Class<U> domainClass,
828826
CriteriaQuery<S> query) {
@@ -868,7 +866,6 @@ private void applyQueryHints(Query query) {
868866
* Executes a count query and transparently sums up all values returned.
869867
*
870868
* @param query must not be {@literal null}.
871-
* @return
872869
*/
873870
private static long executeCountQuery(TypedQuery<Long> query) {
874871

@@ -941,8 +938,8 @@ private static class ExampleSpecification<T> implements Specification<T> {
941938
/**
942939
* Creates new {@link ExampleSpecification}.
943940
*
944-
* @param example
945-
* @param escapeCharacter
941+
* @param example the example to base the specification of. Must not be {@literal null}.
942+
* @param escapeCharacter the escape character to use for like expressions. Must not be {@literal null}.
946943
*/
947944
ExampleSpecification(Example<T> example, EscapeCharacter escapeCharacter) {
948945

src/test/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessorUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@ DefaultListableBeanFactory getBeanFactory() {
5959
}
6060

6161
@Test
62-
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() throws Exception {
62+
void beanConfigurerAspectShouldBeConfiguredAfterPostProcessing() {
6363

6464
processor.postProcessBeanFactory(beanFactory);
6565

src/test/java/org/springframework/data/jpa/domain/support/AuditingNamespaceUnitTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ String getConfigFile() {
3939
}
4040

4141
@Test
42-
void registersBeanDefinitions() throws Exception {
42+
void registersBeanDefinitions() {
4343

4444
BeanDefinition definition = beanFactory.getBeanDefinition(AuditingEntityListener.class.getName());
4545
PropertyValue propertyValue = definition.getPropertyValues().getPropertyValue("auditingHandler");

src/test/java/org/springframework/data/jpa/repository/EclipseLinkNamespaceUserRepositoryTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -106,7 +106,7 @@ void bindsNativeQueryResultsToProjectionByName() {}
106106
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
107107
*/
108108
@Override
109-
void findByEmptyArrayOfIntegers() throws Exception {}
109+
void findByEmptyArrayOfIntegers() {}
110110

111111
/**
112112
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
@@ -119,13 +119,13 @@ void findByAgeWithEmptyArrayOfIntegersOrFirstName() {
119119
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
120120
*/
121121
@Override
122-
void findByEmptyCollectionOfIntegers() throws Exception {}
122+
void findByEmptyCollectionOfIntegers() {}
123123

124124
/**
125125
* Ignores the test. Reconsider once https://bugs.eclipse.org/bugs/show_bug.cgi?id=533240 is fixed.
126126
*/
127127
@Override
128-
void findByEmptyCollectionOfStrings() throws Exception {}
128+
void findByEmptyCollectionOfStrings() {}
129129

130130
/**
131131
* Ignores the test for EclipseLink.

src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ class EclipseLinkUserRepositoryFinderTests extends UserRepositoryFinderTests {
2929

3030
@Disabled
3131
@Override
32-
void executesNotInQueryCorrectly() throws Exception {}
32+
void executesNotInQueryCorrectly() {}
3333

3434
@Disabled
3535
@Override

src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2021 the original author or authors.
2+
* Copyright 2008-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,10 +40,9 @@ public class ORMInfrastructureTests {
4040
/**
4141
* Tests, that the context got initialized and injected correctly.
4242
*
43-
* @throws Exception
4443
*/
4544
@Test
46-
void contextInitialized() throws Exception {
45+
void contextInitialized() {
4746

4847
assertThat(context).isNotNull();
4948
}

src/test/java/org/springframework/data/jpa/repository/OpenJpaParentRepositoryIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,5 +23,5 @@ class OpenJpaParentRepositoryIntegrationTests extends ParentRepositoryIntegratio
2323

2424
@Override
2525
@Disabled
26-
void testWithJoin() throws Exception {}
26+
void testWithJoin() {}
2727
}

src/test/java/org/springframework/data/jpa/repository/OpenJpaUserRepositoryFinderTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2021 the original author or authors.
2+
* Copyright 2011-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,5 +29,5 @@ class OpenJpaUserRepositoryFinderTests extends UserRepositoryFinderTests {
2929

3030
@Disabled
3131
@Override
32-
void findsByLastnameIgnoringCaseLike() throws Exception {}
32+
void findsByLastnameIgnoringCaseLike() {}
3333
}

src/test/java/org/springframework/data/jpa/repository/ParentRepositoryIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2021 the original author or authors.
2+
* Copyright 2013-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, Criteria
8484
}
8585

8686
@Test // DATAJPA-287
87-
void testWithJoin() throws Exception {
87+
void testWithJoin() {
8888
Page<Parent> page = repository.findAll(new Specification<Parent>() {
8989
@Override
9090
public Predicate toPredicate(Root<Parent> root, CriteriaQuery<?> query, CriteriaBuilder cb) {

0 commit comments

Comments
 (0)