Hi Im trying use the Paging feature of Spring Data and I get the following exception when I create a methods such as
Page<User> findByLastName(String lastName, Pageable pageable);
I have other queries (non paging) which work fine
If I comment out the above method then the code in unit tests works fine, but
soon as I start to use paging I get the error below.
Caused by: java.lang.IllegalArgumentException: You cannot use Pageable as method parameter if your persistence provider cannot extract queries!
Im using STS, Spring Data, Hibernate, DB2
My user Repoistory is defined as
public interface UserRepository extends JpaRepository<User, Long> {
User findByUserName(String userName);
Page<User> findByLastName(String lastName, Pageable pageable);
}
Peristence.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="userPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence </provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2Dialect"/>
<!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
<!-- Uncomment the following two properties for JBoss only -->
<!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
<!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
</properties>
</persistence-unit>
</persistence>
Error..
... 40 more
Caused by: java.lang.IllegalArgumentException: You cannot use Pageable as method parameter if your persistence provider cannot extract queries!
at org.springframework.data.jpa.repository.query.JpaQ ueryMethod.<init>(JpaQueryMethod.java:80)
at org.springframework.data.jpa.repository.query.JpaQ ueryLookupStrategy$AbstractQueryLookupStrategy.res olveQuery(JpaQueryLookupStrategy.java:72)
at org.springframework.data.repository.support.Reposi toryFactorySupport$QueryExecuterMethodInterceptor. <init>(RepositoryFactorySupport.java:367)
at org.springframework.data.repository.support.Reposi toryFactorySupport.getRepository(RepositoryFactory Support.java:131)
at org.springframework.data.repository.support.Reposi toryFactoryBeanSupport.getObject(RepositoryFactory BeanSupport.java:89)
at org.springframework.data.repository.support.Reposi toryFactoryBeanSupport.getObject(RepositoryFactory BeanSupport.java:37)
at org.springframework.beans.factory.support.FactoryB eanRegistrySupport.doGetObjectFromFactoryBean(Fact oryBeanRegistrySupport.java:142)
... 48 more


Reply With Quote
).
