@@ -223,13 +223,13 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
223
223
}
224
224
225
225
if (entityInformation .hasCompositeId ()) {
226
- // XXX Hibernate just creates an empty Entity when doing the getById.
227
- // Others might do a select right away causing a big performance penalty.
228
- // See JavaDoc for getById.
226
+
229
227
List <T > entities = new ArrayList <>();
228
+ // generate entity (proxies) without accessing the database.
230
229
ids .forEach (id -> entities .add (getById (id )));
231
230
deleteAllInBatch (entities );
232
231
} else {
232
+
233
233
String queryString = String .format (DELETE_ALL_QUERY_BY_ID_STRING , entityInformation .getEntityName (),
234
234
entityInformation .getIdAttribute ().getName ());
235
235
@@ -418,7 +418,7 @@ public List<T> findAllById(Iterable<ID> ids) {
418
418
419
419
if (entityInformation .hasCompositeId ()) {
420
420
421
- List <T > results = new ArrayList <T >();
421
+ List <T > results = new ArrayList <>();
422
422
423
423
for (ID id : ids ) {
424
424
findById (id ).ifPresent (results ::add );
@@ -429,7 +429,7 @@ public List<T> findAllById(Iterable<ID> ids) {
429
429
430
430
Collection <ID > idCollection = Streamable .of (ids ).toList ();
431
431
432
- ByIdsSpecification <T > specification = new ByIdsSpecification <T >(entityInformation );
432
+ ByIdsSpecification <T > specification = new ByIdsSpecification <>(entityInformation );
433
433
TypedQuery <T > query = getQuery (specification , Sort .unsorted ());
434
434
435
435
return query .setParameter (specification .parameter , idCollection ).getResultList ();
@@ -452,7 +452,7 @@ public List<T> findAll(Sort sort) {
452
452
public Page <T > findAll (Pageable pageable ) {
453
453
454
454
if (isUnpaged (pageable )) {
455
- return new PageImpl <T >(findAll ());
455
+ return new PageImpl <>(findAll ());
456
456
}
457
457
458
458
return findAll ((Specification <T >) null , pageable );
@@ -489,7 +489,7 @@ public List<T> findAll(@Nullable Specification<T> spec) {
489
489
public Page <T > findAll (@ Nullable Specification <T > spec , Pageable pageable ) {
490
490
491
491
TypedQuery <T > query = getQuery (spec , pageable );
492
- return isUnpaged (pageable ) ? new PageImpl <T >(query .getResultList ())
492
+ return isUnpaged (pageable ) ? new PageImpl <>(query .getResultList ())
493
493
: readPage (query , getDomainClass (), pageable , spec );
494
494
}
495
495
@@ -511,7 +511,7 @@ public <S extends T> Optional<S> findOne(Example<S> example) {
511
511
512
512
try {
513
513
return Optional
514
- .of (getQuery (new ExampleSpecification <S >(example , escapeCharacter ), example .getProbeType (), Sort .unsorted ())
514
+ .of (getQuery (new ExampleSpecification <>(example , escapeCharacter ), example .getProbeType (), Sort .unsorted ())
515
515
.getSingleResult ());
516
516
} catch (NoResultException e ) {
517
517
return Optional .empty ();
@@ -525,7 +525,7 @@ public <S extends T> Optional<S> findOne(Example<S> example) {
525
525
@ Override
526
526
public <S extends T > long count (Example <S > example ) {
527
527
return executeCountQuery (
528
- getCountQuery (new ExampleSpecification <S >(example , escapeCharacter ), example .getProbeType ()));
528
+ getCountQuery (new ExampleSpecification <>(example , escapeCharacter ), example .getProbeType ()));
529
529
}
530
530
531
531
/*
@@ -549,7 +549,7 @@ public <S extends T> boolean exists(Example<S> example) {
549
549
*/
550
550
@ Override
551
551
public <S extends T > List <S > findAll (Example <S > example ) {
552
- return getQuery (new ExampleSpecification <S >(example , escapeCharacter ), example .getProbeType (), Sort .unsorted ())
552
+ return getQuery (new ExampleSpecification <>(example , escapeCharacter ), example .getProbeType (), Sort .unsorted ())
553
553
.getResultList ();
554
554
}
555
555
@@ -559,7 +559,7 @@ public <S extends T> List<S> findAll(Example<S> example) {
559
559
*/
560
560
@ Override
561
561
public <S extends T > List <S > findAll (Example <S > example , Sort sort ) {
562
- return getQuery (new ExampleSpecification <S >(example , escapeCharacter ), example .getProbeType (), sort ).getResultList ();
562
+ return getQuery (new ExampleSpecification <>(example , escapeCharacter ), example .getProbeType (), sort ).getResultList ();
563
563
}
564
564
565
565
/*
@@ -636,7 +636,7 @@ public <S extends T> List<S> saveAll(Iterable<S> entities) {
636
636
637
637
Assert .notNull (entities , "Entities must not be null!" );
638
638
639
- List <S > result = new ArrayList <S >();
639
+ List <S > result = new ArrayList <>();
640
640
641
641
for (S entity : entities ) {
642
642
result .add (save (entity ));
@@ -676,7 +676,6 @@ public void flush() {
676
676
* @param query must not be {@literal null}.
677
677
* @param spec can be {@literal null}.
678
678
* @param pageable must not be {@literal null}.
679
- * @return
680
679
* @deprecated use {@link #readPage(TypedQuery, Class, Pageable, Specification)} instead
681
680
*/
682
681
@ Deprecated
@@ -692,7 +691,6 @@ protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, @Nullable Spe
692
691
* @param domainClass must not be {@literal null}.
693
692
* @param spec can be {@literal null}.
694
693
* @param pageable can be {@literal null}.
695
- * @return
696
694
*/
697
695
protected <S extends T > Page <S > readPage (TypedQuery <S > query , final Class <S > domainClass , Pageable pageable ,
698
696
@ Nullable Specification <S > spec ) {
@@ -711,7 +709,6 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> dom
711
709
*
712
710
* @param spec can be {@literal null}.
713
711
* @param pageable must not be {@literal null}.
714
- * @return
715
712
*/
716
713
protected TypedQuery <T > getQuery (@ Nullable Specification <T > spec , Pageable pageable ) {
717
714
@@ -725,7 +722,6 @@ protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pagea
725
722
* @param spec can be {@literal null}.
726
723
* @param domainClass must not be {@literal null}.
727
724
* @param pageable must not be {@literal null}.
728
- * @return
729
725
*/
730
726
protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass ,
731
727
Pageable pageable ) {
@@ -739,7 +735,6 @@ protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec,
739
735
*
740
736
* @param spec can be {@literal null}.
741
737
* @param sort must not be {@literal null}.
742
- * @return
743
738
*/
744
739
protected TypedQuery <T > getQuery (@ Nullable Specification <T > spec , Sort sort ) {
745
740
return getQuery (spec , getDomainClass (), sort );
@@ -751,7 +746,6 @@ protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Sort sort) {
751
746
* @param spec can be {@literal null}.
752
747
* @param domainClass must not be {@literal null}.
753
748
* @param sort must not be {@literal null}.
754
- * @return
755
749
*/
756
750
protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass , Sort sort ) {
757
751
@@ -772,7 +766,6 @@ protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec,
772
766
* Creates a new count query for the given {@link Specification}.
773
767
*
774
768
* @param spec can be {@literal null}.
775
- * @return
776
769
* @deprecated override {@link #getCountQuery(Specification, Class)} instead
777
770
*/
778
771
@ Deprecated
@@ -785,7 +778,6 @@ protected TypedQuery<Long> getCountQuery(@Nullable Specification<T> spec) {
785
778
*
786
779
* @param spec can be {@literal null}.
787
780
* @param domainClass must not be {@literal null}.
788
- * @return
789
781
*/
790
782
protected <S extends T > TypedQuery <Long > getCountQuery (@ Nullable Specification <S > spec , Class <S > domainClass ) {
791
783
@@ -801,7 +793,7 @@ protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S
801
793
}
802
794
803
795
// Remove all Orders the Specifications might have applied
804
- query .orderBy (Collections .< Order > emptyList ());
796
+ query .orderBy (Collections .emptyList ());
805
797
806
798
return em .createQuery (query );
807
799
}
@@ -812,7 +804,6 @@ protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S
812
804
* @param spec can be {@literal null}.
813
805
* @param domainClass must not be {@literal null}.
814
806
* @param query must not be {@literal null}.
815
- * @return
816
807
*/
817
808
private <S , U extends T > Root <U > applySpecificationToCriteria (@ Nullable Specification <U > spec , Class <U > domainClass ,
818
809
CriteriaQuery <S > query ) {
@@ -858,7 +849,6 @@ private void applyQueryHints(Query query) {
858
849
* Executes a count query and transparently sums up all values returned.
859
850
*
860
851
* @param query must not be {@literal null}.
861
- * @return
862
852
*/
863
853
private static long executeCountQuery (TypedQuery <Long > query ) {
864
854
@@ -930,8 +920,8 @@ private static class ExampleSpecification<T> implements Specification<T> {
930
920
/**
931
921
* Creates new {@link ExampleSpecification}.
932
922
*
933
- * @param example
934
- * @param escapeCharacter
923
+ * @param example the example to base the specification of. Must not be {@literal null}.
924
+ * @param escapeCharacter the escape character to use for like expressions. Must not be {@literal null}.
935
925
*/
936
926
ExampleSpecification (Example <T > example , EscapeCharacter escapeCharacter ) {
937
927
0 commit comments