Spring Data Couchbase documentation (version 4.4.5) specifies that the method getCouchbaseOperations() has also been removed. It also states that you still can access all methods from the native Java SDK via the class CouchbaseTemplate or Cluster. But I couldn’t resolve this. (Spring Data Couchbase - Reference Documentation)
The code below is from Couchbase SDK 2 implementation. I opted to migrate the deprecated DSL packages into my code as specified in below mentioned thread. (What are the solutions for com.couchbase.client.java.query.dsl.Sort issue?)
I am currently facing the issue of resolving getCouchbaseOperations() related issues. Could someone please specify how I may handle this as a scenario?
package com.acme.acmepay.config.dao;
import com.acme.acmepay.config.document.paymentoption.PaymentGatewayConfiguration;
import com.acme.acmepay.config.logic.paymenttemplatereportlogic.data.PaymentTemplateDataTableSearchLogicData;
import com.acme.acmepay.config.repository.PaymentGatewayConfigurationRepository;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.query.N1qlQuery;
import com.couchbase.client.java.query.Statement;
import com.couchbase.client.java.query.dsl.Expression;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.couchbase.repository.query.support.N1qlUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class PaymentTemplateConfigDAOImpl implements PaymentTemplateConfigDAO {
@Autowired
PaymentGatewayConfigurationRepository paymentGatewayConfigurationRepository;
Bucket couchbaseBucket;
public List<PaymentGatewayConfiguration> getPaymentTemplateSearchReportList(
PaymentTemplateDataTableSearchLogicData paymentTemplateDataTableSearchLogicData) {
Statement statement = getQueryStatement(paymentTemplateDataTableSearchLogicData);
log.info("N1QL Statement" + statement);
//Error happen here
N1qlQuery query = N1qlQuery.simple(statement);
return paymentGatewayConfigurationRepository.getCouchbaseOperations().findByN1QL(query,
PaymentGatewayConfiguration.class);
}
private Statement getQueryStatement(
PaymentTemplateDataTableSearchLogicData paymentTemplateDataTableSearchLogicData) {
//Error happen here
return N1qlUtils
.createSelectClauseForEntity(
paymentGatewayConfigurationRepository.getCouchbaseOperations().getCouchbaseBucket().name())
.from(Expression
.i(paymentGatewayConfigurationRepository.getCouchbaseOperations().getCouchbaseBucket().name()))
.where(paymentTemplateDataTableSearchLogicData.getSearchQuery())
.orderBy(paymentTemplateDataTableSearchLogicData.getSort())
.limit(paymentTemplateDataTableSearchLogicData.getLimit())
.offset(paymentTemplateDataTableSearchLogicData.getOffset());
}
}
What would be the best possible options?