'Cassandra DAO - can't set statement attributes

I have following following DAO query method

@Query("SELECT * FROM user_level_insights WHERE organization_id = :orgId AND user_id = :userId")
fun getInsightsByUserId1(orgId: String, userId: String, builder: (BoundStatementBuilder) -> BoundStatementBuilder): PagingIterable<UserLevelInsights>

Specifically I am trying to specify some statement attributes (at the end it should be paging state). I am trying to test this DAO using following code

        val iterable = controller.userLevelInsightsDao.getInsightsByUserId2(
        basicInsight.organizationId,
        basicInsight.userId
    ) { builder -> builder.setPageSize(1) }

Unfortunately this call fails with

java.lang.IllegalArgumentException: builder is not a variable in this bound statement

And when I look into autogenerated code for DAO interface I see following

  public PagingIterable<UserLevelInsights> getInsightsByUserId1(String orgId, String userId,
  Function1<? super BoundStatementBuilder, ? extends BoundStatementBuilder> builder) {
BoundStatementBuilder boundStatementBuilder = getInsightsByUserId1Statement.boundStatementBuilder();
NullSavingStrategy nullSavingStrategy = NullSavingStrategy.DO_NOT_SET;
if (orgId != null || nullSavingStrategy == NullSavingStrategy.SET_TO_NULL) {
  boundStatementBuilder = boundStatementBuilder.set("orgId", orgId, String.class);
}
if (userId != null || nullSavingStrategy == NullSavingStrategy.SET_TO_NULL) {
  boundStatementBuilder = boundStatementBuilder.set("userId", userId, String.class);
}
if (builder != null || nullSavingStrategy == NullSavingStrategy.SET_TO_NULL) {
  boundStatementBuilder = boundStatementBuilder.set("builder", builder, GENERIC_TYPE);
}

BoundStatement boundStatement = boundStatementBuilder.build();
return executeAndMapToEntityIterable(boundStatement, userLevelInsightsHelper);

} Which looks wrong to me - builder is really is not a field on bound statement. So my question is what am I doing wrong defining builder lambda?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source