javaspringhibernatespring-data-jpajpa-criteria

I am looking for an alternative to Specifications for the given scenario


I am calling findall() method of the JpaRepository as following

Service

on.findall(specificationsbuilder.getspecifications(params), paegable obj)  

specificationsbuilder.getspecifications(param)

returns specifications

My question is if specifications is null will my will findall(specifications,paegable) work


Solution

  • According to the sourcecode of SimpleJpaRepository it should work, because @Nullable says it will accept null:

    @Override
        public Page<T> findAll(@Nullable Specification<T> spec, Pageable pageable) {
    
            TypedQuery<T> query = getQuery(spec, pageable);
            return isUnpaged(pageable) ? new PageImpl<T>(query.getResultList())
                    : readPage(query, getDomainClass(), pageable, spec);
    }