Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException:Either use @Param on all parameters except Pageable and Sort typed once, or none at all

I'm using Spring Data Cassandra.I'm getting exception when i pass multiple parameters to the repository method. Can anyone help how to pass multiple parameters to append and use where clause.

My Repo method:

@Query("select site_name,month_gen from mykeyspace.dgr_item where type='Site' and name = ?0 and dgr_date in (:list)")
public List<Object> findGen(String siteName, @Param("list") List<Date> listt);

Exception:

Caused by: java.lang.IllegalArgumentException: Either use @Param on all parameters except Pageable and Sort typed once, or none at all!
at org.springframework.util.Assert.isTrue(Assert.java:68)
at org.springframework.data.repository.query.Parameters.assertEitherAllParamAnnotatedOrNone(Parameters.java:294)
at org.springframework.data.repository.query.Parameters.<init>(Parameters.java:91)
at org.springframework.data.cassandra.repository.query.CassandraParameters.<init>(CassandraParameters.java:45)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.createParameters(CassandraQueryMethod.java:131)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.createParameters(CassandraQueryMethod.java:45)
at org.springframework.data.repository.query.QueryMethod.<init>(QueryMethod.java:75)
at org.springframework.data.cassandra.repository.query.CassandraQueryMethod.<init>(CassandraQueryMethod.java:64)
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactory$CassandraQueryLookupStrategy.resolveQuery(CassandraRepositoryFactory.java:152)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263)
at org.springframework.data.cassandra.repository.support.CassandraRepositoryFactoryBean.afterPropertiesSet(CassandraRepositoryFactoryBean.java:76)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
... 41 common frames omitted
like image 618
sreedhar Avatar asked Apr 19 '17 07:04

sreedhar


2 Answers

Caused by: java.lang.IllegalArgumentException: Either use Param annotation on all parameters except Pageable and Sort typed once, or none at all! states that all the parameters should have Param annotation your first argument is not having it

like image 193
pshirishreddy Avatar answered Oct 17 '22 11:10

pshirishreddy


This can also happen if you use PageRequest in the repository as well.

you should use Pageable with below import,

import org.springframework.data.domain.Pageable;
like image 20
tk_ Avatar answered Oct 17 '22 09:10

tk_