1
votes

I try to make a method in a couchbase spring data repository interface to query with java.util.Date parameter like this one :

@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} and beginDate < $0")
public Set<Campaign> findBroadcastable(Date now);

But on execution this exception is raise:

java.lang.IllegalArgumentException: Unsupported type for JsonArray: class java.util.Date

Would someone have the solution?

1
Which version of SDC are you using? - subhashni
I use v3.0.5 of SDC. - Jérémie Randour
It is a bug that SDC doesn't do the internal conversion. Created DATACOUCH-384 for this. The workaround is to use findBroadcastable(long now) (and pass Date.getTime()). - subhashni
Thank you for your help @subhashni. I'm going to change the definition of the method while waiting for bug fixes in a future version of SDC. - Jérémie Randour

1 Answers

1
votes

I did a conversion in N1QL and instead of a Date as a parameter send a string

@Query("h.*, META(h).id AS _ID, META(h).cas AS _CAS FROM
#{#n1ql.bucket} as h WHERE MILLIS_TO_STR(h.creadoEn ,'1111-11-11') = '#{#creadoEn}' AND h.#{#n1ql.filter}")
List<y> findByFecha(@Param("creadoEn") String creadoEn);

MILLIS_TO_STR converts the milis to date and I give it the format I want "1111-11-11" is "yyyy-mm-dd" and I compare it with the String sent as a parameter.

Forgive my bad English and I hope I have helped