My n1ql query stopped working as I upgraded from springboot 3.1.2 to 3.1.5.
My repository and n1ql is like this :
@Repository
public interface StoreStockMovementRepository extends ReactiveCouchbaseRepository<StoreStockMovement, String> {
@Query("SELECT META().id as eventId FROM #{#n1ql.bucket} WHERE " +
"STR_TO_MILLIS(`createdAt`) >= STR_TO_MILLIS($1) " +
"AND STR_TO_MILLIS(`createdAt`) < STR_TO_MILLIS($2) " +
"AND `locationReference`.`country` = $3 " +
"AND `sourceTransaction`.`source` IN $4 " +
"AND `sourceTransaction`.`sourceTransactionType` IN $5 " +
"AND #{#n1ql.filter}")
Flux<String> findByCreatedAtAndCountry(String startDate, String endDate, String countryId,
List<String> sources, List<String> sourceTransactionTypes);
}
This was working fine and giving proper result. But when I upgraded springboot I am getting following error
om.couchbase.client.core.error.IndexFailureException: The server reported an issue with the underlying index {"completed":true,"coreId":"0xbcdb06b200000001","errors":[{"code":12003,"message":"Keyspace not found in CB datastore: default:myProd-stock-dev.stockMovement.myProd-stock-dev","retry":false}],"httpStatus":500,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:57229","lastDispatchedTo":"127.0.0.1:8093","requestId":24,"requestType":"QueryRequest","retried":0,"service":{"bucket":"myProd-stock-dev","operationId":"null","scope":"stockMovement","statement":"SELECT META().id as eventId FROM `myProd-stock-dev` WHERE STR_TO_MILLIS(`createdAt`) >= STR_TO_MILLIS($1) AND STR_TO_MILLIS(`createdAt`) < STR_TO_MILLIS($2) AND `locationReference`.`country` = $3 AND `sourceTransaction`.`source` IN $4 AND `sourceTransaction`.`sourceTransactionType` IN $5 AND `_class` = \"com.myComp.finance.myProd.commons.model.stock.entity.StoreStockMovement\"","type":"query"},"timeoutMs":75000,"timings":{"dispatchMicros":5744,"totalDispatchMicros":5744,"totalMicros":14899}}
at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.errorsToThrowable(QueryChunkResponseParser.java:176)
at com.couchbase.client.core.io.netty.query.QueryChunkResponseParser.lambda$error$10(QueryChunkResponseParser.java:128)
at java.base/java.util.Optional.map(Optional.java:260)
My entity class is this
@Builder
@Scope("stockMovement")
@Collection("storeStockMovement")
@TypeAlias("com.myComp.finance.myProd.commons.model.stock.entity.StoreStockMovement")
@Getter
public class StoreStockMovement {
@Id
private String eventId;
private String eventType;
private String traceId;
private ZonedDateTime eventTimestamp;
private SourceTransaction sourceTransaction;
private SourceTransactionDetails sourceTransactionDetails;
private StockTransaction stockTransaction;
private LocationReference locationReference;
private ProductReference productReference;
private List<StockState> states;
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
private LocalDateTime createdAt;
}
Also, I am using the ReactiveCouchbaseRepository, but I don’t feel that will be having the issue as it works fine with 3.1.2 springboot.