Using "named parameters" with @Query does not seem to work

1,038 views
Skip to first unread message

Jega A

unread,
May 14, 2014, 2:32:11 PM5/14/14
to spring-dat...@googlegroups.com
I have been experimenting with the @Query named queries with spring-data-cassandra

Example A:
This works!
@Query(value = "SELECT * FROM contracts WHERE tenant_id = ?0 AND id = ?1")
Contract findById(@Param("tenantId") int tenantId, @Param("id") String id );

However, converting this to using named parameters does not work as shown in Example B.
Example B:
This does not work!

@Query(value = "SELECT * FROM contracts WHERE tenant_id = :tenantId AND id = :id")
Contract findById(@Param("tenantId") int tenantId, @Param("id") String id );

The error returned is
com.datastax.driver.core.exceptions.InvalidQueryException: Invalid amount of bind variables


Here we are using the name parameters directly in the query with a ":" prefix.

Not sure if this is specific to spring-data-cassandra.

Jega



David Webb (Prowave)

unread,
May 14, 2014, 2:40:31 PM5/14/14
to Jega A, spring-dat...@googlegroups.com

This is on the list of todos.

 

https://jira.spring.io/browse/DATACASS-117

 

For future sanity, the JPA docs will not determine what works in SDC*. J

 

Dave

--
You received this message because you are subscribed to the Google Groups "Spring Data Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring-data-cass...@googlegroups.com.
To post to this group, send email to spring-dat...@googlegroups.com.
Visit this group at http://groups.google.com/group/spring-data-cassandra.
To view this discussion on the web visit https://groups.google.com/d/msgid/spring-data-cassandra/cfc5de86-9274-4003-8ded-e0b7007160b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages