【发布时间】:2020-06-02 15:05:04
【问题描述】:
使用来自 org.springframework.data.cassandra.repository.Query 的 @Query,我想进行自定义查询并将其传递给我的存储库,然后从参数传递给 @Query 注释。
我的存储库如下所示:
@Repository
public interface TestRepository extends CassandraRepository<TestValues, id> {
@Query(value = ":customQuery")
public List<TestValues> testSearch(@Param("customQuery") String customQuery);
}
其中字符串 customQuery 是查询自身。比如“SELECT * FROM TABLE_A WHERE COLUMN_B = C”
我收到以下错误:
ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.cassandra.CassandraQuerySyntaxException: Query; CQL [{{customQuery}}]; line 1:0 no viable alternative at input '{' ([{]...); nested exception is com.datastax.driver.core.exceptions.SyntaxError: line 1:0 no viable alternative at input '{' ([{]...)] with root cause
com.datastax.driver.core.exceptions.SyntaxError: line 1:0 no viable alternative at input '{' ([{]...)
我的猜测是 customQuery 是一个带引号“”的字符串。但我不知道如何像这样传递整个查询。有人可以帮我吗? :)
【问题讨论】:
标签: java cassandra spring-data cql3