@@ -513,6 +513,7 @@ public <S extends T, R> R findBy(Specification<T> spec,
513
513
return doFindBy (spec , getDomainClass (), queryFunction );
514
514
}
515
515
516
+ @ SuppressWarnings ("unchecked" )
516
517
private <S extends T , R > R doFindBy (Specification <T > spec , Class <T > domainClass ,
517
518
Function <? super SpecificationFluentQuery <S >, R > queryFunction ) {
518
519
@@ -610,6 +611,7 @@ public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
610
611
}
611
612
612
613
@ Override
614
+ @ SuppressWarnings ("unchecked" )
613
615
public <S extends T , R > R findBy (Example <S > example , Function <FetchableFluentQuery <S >, R > queryFunction ) {
614
616
615
617
Assert .notNull (example , EXAMPLE_MUST_NOT_BE_NULL );
@@ -632,7 +634,7 @@ public long count() {
632
634
}
633
635
634
636
@ Override
635
- public long count (@ Nullable Specification <T > spec ) {
637
+ public long count (Specification <T > spec ) {
636
638
return executeCountQuery (getCountQuery (spec , getDomainClass ()));
637
639
}
638
640
@@ -701,7 +703,7 @@ public void flush() {
701
703
* @deprecated use {@link #readPage(TypedQuery, Class, Pageable, Specification)} instead
702
704
*/
703
705
@ Deprecated
704
- protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , @ Nullable Specification <T > spec ) {
706
+ protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , Specification <T > spec ) {
705
707
return readPage (query , getDomainClass (), pageable , spec );
706
708
}
707
709
@@ -711,11 +713,13 @@ protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, @Nullable Spe
711
713
*
712
714
* @param query must not be {@literal null}.
713
715
* @param domainClass must not be {@literal null}.
714
- * @param spec can be {@literal null}.
716
+ * @param spec must not be {@literal null}.
715
717
* @param pageable can be {@literal null}.
716
718
*/
717
719
protected <S extends T > Page <S > readPage (TypedQuery <S > query , Class <S > domainClass , Pageable pageable ,
718
- @ Nullable Specification <S > spec ) {
720
+ Specification <S > spec ) {
721
+
722
+ Assert .notNull (spec , "Specification must not be null" );
719
723
720
724
if (pageable .isPaged ()) {
721
725
query .setFirstResult (PageableUtils .getOffsetAsInteger (pageable ));
@@ -729,21 +733,21 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, Class<S> domainCla
729
733
/**
730
734
* Creates a new {@link TypedQuery} from the given {@link Specification}.
731
735
*
732
- * @param spec can be {@literal null}.
736
+ * @param spec must not be {@literal null}.
733
737
* @param pageable must not be {@literal null}.
734
738
*/
735
- protected TypedQuery <T > getQuery (@ Nullable Specification <T > spec , Pageable pageable ) {
739
+ protected TypedQuery <T > getQuery (Specification <T > spec , Pageable pageable ) {
736
740
return getQuery (spec , getDomainClass (), pageable .getSort ());
737
741
}
738
742
739
743
/**
740
744
* Creates a new {@link TypedQuery} from the given {@link Specification}.
741
745
*
742
- * @param spec can be {@literal null}.
746
+ * @param spec must not be {@literal null}.
743
747
* @param domainClass must not be {@literal null}.
744
748
* @param pageable must not be {@literal null}.
745
749
*/
746
- protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass ,
750
+ protected <S extends T > TypedQuery <S > getQuery (Specification <S > spec , Class <S > domainClass ,
747
751
Pageable pageable ) {
748
752
return getQuery (spec , domainClass , pageable .getSort ());
749
753
}
@@ -877,21 +881,23 @@ protected <S> Query getDelete(DeleteSpecification<S> spec, Class<S> domainClass)
877
881
/**
878
882
* Creates a new count query for the given {@link Specification}.
879
883
*
880
- * @param spec can be {@literal null}.
884
+ * @param spec must not be {@literal null}.
881
885
* @deprecated override {@link #getCountQuery(Specification, Class)} instead
882
886
*/
883
887
@ Deprecated
884
- protected TypedQuery <Long > getCountQuery (@ Nullable Specification <T > spec ) {
888
+ protected TypedQuery <Long > getCountQuery (Specification <T > spec ) {
885
889
return getCountQuery (spec , getDomainClass ());
886
890
}
887
891
888
892
/**
889
893
* Creates a new count query for the given {@link Specification}.
890
894
*
891
- * @param spec can be {@literal null}.
895
+ * @param spec must not be {@literal null}.
892
896
* @param domainClass must not be {@literal null}.
893
897
*/
894
- protected <S extends T > TypedQuery <Long > getCountQuery (@ Nullable Specification <S > spec , Class <S > domainClass ) {
898
+ protected <S extends T > TypedQuery <Long > getCountQuery (Specification <S > spec , Class <S > domainClass ) {
899
+
900
+ Assert .notNull (spec , "Specification must not be null" );
895
901
896
902
CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
897
903
CriteriaQuery <Long > query = builder .createQuery (Long .class );
@@ -1041,7 +1047,7 @@ private Map<String, Object> getHints() {
1041
1047
private void applyComment (CrudMethodMetadata metadata , BiConsumer <String , Object > consumer ) {
1042
1048
1043
1049
if (metadata .getComment () != null && provider .getCommentHintKey () != null ) {
1044
- consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (this . metadata .getComment ()));
1050
+ consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (metadata .getComment ()));
1045
1051
}
1046
1052
}
1047
1053
0 commit comments