Exception using Pageable and Sort instances

When you're using Pageable and Sort instances on your data repository methods, you can encouter following exception:
Caused by: java.lang.IllegalStateException: Method must not have Pageable *and* Sort parameter. Use sorting capabilities on Pageble instead! Offending method: public abstract org.springframework.data.domain.Page com.specimen.db.repository.ProjectRepository.getAllProjects(org.springframework.data.domain.Pageable,org.springframework.data.domain.Sort)
        at org.springframework.data.repository.query.QueryMethod.(QueryMethod.java:64)
        at org.springframework.data.jpa.repository.query.JpaQueryMethod.(JpaQueryMethod.java:59)
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.(RepositoryFactorySupport.java:279)
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147)
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153)
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43)
        at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
        ... 57 more
To avoid it, you shouldn't put Pageable and Sort instances together, in the method signature, for example like that:
@Query("SELECT p FROM Project p")
public Page<Project> getAllProjects(Pageable pageable, Sort sort);
Instead of this, you should pass only Pageable instance constructed with Sort object:
@Query("SELECT p FROM Project p")
public Page<Project> getAllProjects(Pageable pageable);
// And in the method invocation, you should initialize following Pageable object
Pageable pageable = new PageRequest(page, size, Sort.Direction.ASC, "name");