@@ -502,6 +502,7 @@ public <S extends T, R> R findBy(Specification<T> spec, Function<FetchableFluent
502
502
return doFindBy (spec , getDomainClass (), queryFunction );
503
503
}
504
504
505
+ @ SuppressWarnings ("unchecked" )
505
506
private <S extends T , R > R doFindBy (Specification <T > spec , Class <T > domainClass ,
506
507
Function <FetchableFluentQuery <S >, R > queryFunction ) {
507
508
@@ -593,6 +594,7 @@ public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
593
594
}
594
595
595
596
@ Override
597
+ @ SuppressWarnings ("unchecked" )
596
598
public <S extends T , R > R findBy (Example <S > example , Function <FetchableFluentQuery <S >, R > queryFunction ) {
597
599
598
600
Assert .notNull (example , "Example must not be null" );
@@ -615,7 +617,7 @@ public long count() {
615
617
}
616
618
617
619
@ Override
618
- public long count (@ Nullable Specification <T > spec ) {
620
+ public long count (Specification <T > spec ) {
619
621
return executeCountQuery (getCountQuery (spec , getDomainClass ()));
620
622
}
621
623
@@ -684,7 +686,7 @@ public void flush() {
684
686
* @deprecated use {@link #readPage(TypedQuery, Class, Pageable, Specification)} instead
685
687
*/
686
688
@ Deprecated
687
- protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , @ Nullable Specification <T > spec ) {
689
+ protected Page <T > readPage (TypedQuery <T > query , Pageable pageable , Specification <T > spec ) {
688
690
return readPage (query , getDomainClass (), pageable , spec );
689
691
}
690
692
@@ -694,11 +696,13 @@ protected Page<T> readPage(TypedQuery<T> query, Pageable pageable, @Nullable Spe
694
696
*
695
697
* @param query must not be {@literal null}.
696
698
* @param domainClass must not be {@literal null}.
697
- * @param spec can be {@literal null}.
699
+ * @param spec must not be {@literal null}.
698
700
* @param pageable can be {@literal null}.
699
701
*/
700
702
protected <S extends T > Page <S > readPage (TypedQuery <S > query , final Class <S > domainClass , Pageable pageable ,
701
- @ Nullable Specification <S > spec ) {
703
+ Specification <S > spec ) {
704
+
705
+ Assert .notNull (spec , "Specification must not be null" );
702
706
703
707
if (pageable .isPaged ()) {
704
708
query .setFirstResult (PageableUtils .getOffsetAsInteger (pageable ));
@@ -712,22 +716,22 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, final Class<S> dom
712
716
/**
713
717
* Creates a new {@link TypedQuery} from the given {@link Specification}.
714
718
*
715
- * @param spec can be {@literal null}.
719
+ * @param spec must not be {@literal null}.
716
720
* @param pageable must not be {@literal null}.
717
721
*/
718
- protected TypedQuery <T > getQuery (@ Nullable Specification <T > spec , Pageable pageable ) {
722
+ protected TypedQuery <T > getQuery (Specification <T > spec , Pageable pageable ) {
719
723
720
724
return getQuery (spec , getDomainClass (), pageable .getSort ());
721
725
}
722
726
723
727
/**
724
728
* Creates a new {@link TypedQuery} from the given {@link Specification}.
725
729
*
726
- * @param spec can be {@literal null}.
730
+ * @param spec must not be {@literal null}.
727
731
* @param domainClass must not be {@literal null}.
728
732
* @param pageable must not be {@literal null}.
729
733
*/
730
- protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass ,
734
+ protected <S extends T > TypedQuery <S > getQuery (Specification <S > spec , Class <S > domainClass ,
731
735
Pageable pageable ) {
732
736
733
737
return getQuery (spec , domainClass , pageable .getSort ());
@@ -806,21 +810,23 @@ protected <S> Query getDelete(DeleteSpecification<S> spec, Class<S> domainClass)
806
810
/**
807
811
* Creates a new count query for the given {@link Specification}.
808
812
*
809
- * @param spec can be {@literal null}.
813
+ * @param spec must not be {@literal null}.
810
814
* @deprecated override {@link #getCountQuery(Specification, Class)} instead
811
815
*/
812
816
@ Deprecated
813
- protected TypedQuery <Long > getCountQuery (@ Nullable Specification <T > spec ) {
817
+ protected TypedQuery <Long > getCountQuery (Specification <T > spec ) {
814
818
return getCountQuery (spec , getDomainClass ());
815
819
}
816
820
817
821
/**
818
822
* Creates a new count query for the given {@link Specification}.
819
823
*
820
- * @param spec can be {@literal null}.
824
+ * @param spec must not be {@literal null}.
821
825
* @param domainClass must not be {@literal null}.
822
826
*/
823
- protected <S extends T > TypedQuery <Long > getCountQuery (@ Nullable Specification <S > spec , Class <S > domainClass ) {
827
+ protected <S extends T > TypedQuery <Long > getCountQuery (Specification <S > spec , Class <S > domainClass ) {
828
+
829
+ Assert .notNull (spec , "Specification must not be null" );
824
830
825
831
CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
826
832
CriteriaQuery <Long > query = builder .createQuery (Long .class );
@@ -970,7 +976,7 @@ private Map<String, Object> getHints() {
970
976
private void applyComment (CrudMethodMetadata metadata , BiConsumer <String , Object > consumer ) {
971
977
972
978
if (metadata .getComment () != null && provider .getCommentHintKey () != null ) {
973
- consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (this . metadata .getComment ()));
979
+ consumer .accept (provider .getCommentHintKey (), provider .getCommentHintValue (metadata .getComment ()));
974
980
}
975
981
}
976
982
0 commit comments