Hi,
I've been using this method definition in a Spring Data JPA enabled repository:
I have also used (from JpaSpecificationExecutor):Code:List<User> findAllByTenant(final Specification<User> constraints, final String tenant);
Now, trying to use:Code:Page<T> findAll(Specification<T> spec, Pageable pageable);
Fails with:Code:Page<User> findAllByTenant(final Specification<User> constraints, final String tenant, final Pageable pageable);
Caused by: java.lang.IllegalArgumentException: Parameter value [org.springframework.data.jpa.domain.Specifications @4815e] did not match expected type [java.lang.String]
at org.hibernate.ejb.AbstractQueryImpl.validateParame terBinding(AbstractQueryImpl.java:375)
at org.hibernate.ejb.AbstractQueryImpl.registerParame terBinding(AbstractQueryImpl.java:348)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl .java:375)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl .java:328)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3 .setParameter(CriteriaQueryCompiler.java:322)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3 .setParameter(CriteriaQueryCompiler.java:251)
at org.springframework.data.jpa.repository.query.Crit eriaQueryParameterBinder.bind(CriteriaQueryParamet erBinder.java:68)
at org.springframework.data.jpa.repository.query.Para meterBinder.bind(ParameterBinder.java:108)
at org.springframework.data.jpa.repository.query.Para meterBinder.bindAndPrepare(ParameterBinder.java:13 9)
at org.springframework.data.jpa.repository.query.Para meterBinder.bindAndPrepare(ParameterBinder.java:13 4)
at org.springframework.data.jpa.repository.query.Part TreeJpaQuery$QueryPreparer.invokeBinding(PartTreeJ paQuery.java:144)
at org.springframework.data.jpa.repository.query.Part TreeJpaQuery$QueryPreparer.createQuery(PartTreeJpa Query.java:121)
at org.springframework.data.jpa.repository.query.Part TreeJpaQuery.doCreateQuery(PartTreeJpaQuery.java:7 1)
at org.springframework.data.jpa.repository.query.Abst ractJpaQuery.createQuery(AbstractJpaQuery.java:144 )
at org.springframework.data.jpa.repository.query.JpaQ ueryExecution$CollectionExecution.doExecute(JpaQue ryExecution.java:77)
at org.springframework.data.jpa.repository.query.JpaQ ueryExecution.execute(JpaQueryExecution.java:55)
at org.springframework.data.jpa.repository.query.Abst ractJpaQuery.doExecute(AbstractJpaQuery.java:95)
at org.springframework.data.jpa.repository.query.Abst ractJpaQuery.execute(AbstractJpaQuery.java:85)
at org.springframework.data.repository.core.support.R epositoryFactorySupport$QueryExecutorMethodInterce ptor.invoke(RepositoryFactorySupport.java:313)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:110)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
at org.springframework.dao.support.PersistenceExcepti onTranslationInterceptor.invoke(PersistenceExcepti onTranslationInterceptor.java:155)
... 48 more
So, essentially, it works with the specification and the simple field, it works with the specification and pagination, but it doesn't work with all 3.
Is there anything I'm missing on this? Should it work or is this not supported?
Thanks.
Eugen.


Reply With Quote
