I have a SpringBoot 2 app that uses using Couchbase as a database, Spring-Boot and Spring-Data and Lombok fot the getters and equals method I have created this Repository
@ViewIndexed(designDoc = "bendicionesDoc")
public interface BenRepository extends CouchbaseRepository<BendicionesDoc, String> {
@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} AND ANY uuid IN data.identifier SATISFIES uuid = $1 END")
List<BendicionesDoc<Item>> findById(Identifier identifier);
}
and here all the objects created with Lombok library
public class BendicionesDoc<T>implements Serializable {
@Field
private T data;
}
and
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
public class Item {
private List<Identifier> identifier;
}
and
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
@EqualsAndHashCode
public class Identifier {
private String id;
private MasterServant idContext;
private MasterServant idScope;
}
and
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class MasterServant {
private String context;
@JsonValue
@EqualsAndHashCode.Include
private String value;
private Name valueDescription;
@JsonCreator
public MasterServant(String value) {
this.value = value;
}
}
But when I run the repository query I got this error:
java.lang.IllegalArgumentException: Unsupported type for JsonArray: class com.bendiciones.Identifier
Identifier is an object, you can't simply ask Couchbase to compare an object in N1QL
Your method definition should be something like:
@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} AND ANY uuid IN data.identifier SATISFIES uuid.id = $1 END")
List<BendicionesDoc<Item>> findById(String id);