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

sreedhar picture sreedhar · Apr 19, 2017 · Viewed 7.1k times · Source

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

Answer

pshirishreddy picture pshirishreddy · Apr 19, 2017

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