I get an exception while I am trying to get objects from CouchBase. I use Spring Data Repository to query data. I save data to CouchBase without any exceptions. I need to query data by dataTime which should be in range dateBefore and dateAfter.
I have such Java Object:
@Document
public class DataObject{
@Id
@Field
private String dataId;
@Field
private boolean isEnabled;
@Field
private BigDecimal price;
@Field
private LocalDateTime dataTime;
@Field
private Currency currency;
public DataObject() {
}
public DataObject(String dataId, boolean isEnabled, BigDecimal price, Date dataTime, Currency currency) {
this.dataId = dataId;
this.dataId = dataId;
this.price = price;
this.dataTime = dataTime;
this.currency = currency;
}
}
I have such repository interface:
public interface DataObjectRepository extends CrudRepository<DataObject, String> {
@Query("#{#n1ql.selectEntity} WHERE dataTime BETWEEN $1 AND $2 AND #{#n1ql.filter}")
List<DataObject> getDataObjectsBetweenDates(LocalDateTime beforeTime, LocalDateTime afterTime);
}
When I run this query I got an exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Unsupported type for JsonArray: class java.time.LocalDateTime
I tried to use Timestamp, old Date instead LocalDateTime, however I got the same exception but with different Class in the message.
I am new to CouchBase, so any help appreciated
AND #{#n1ql.filter}is supposed to do, but if you can save data usingLocalDateTime, I think that class should be converted fine. - OneCricketeer