Spring Couchbase 的数据 - java.lang.IllegalArgumentException:JsonArray 不支持的类型:

Spring Data for Couchbase - java.lang.IllegalArgumentException: Unsupported type for JsonArray:

我有一个 SpringBoot 2 应用程序,它使用 Couchbase 作为数据库,Spring-Boot 和 Spring-Data 和 Lombok fot getters 和 equals 方法 我创建了这个存储库

@ViewIndexed(designDoc = "bendicionesDoc")
public interface BenRepository extends CouchbaseRepository<BendicionesDoc, String> {

    @Query("#{#n1ql.selectEntity} where #{#n1ql.filter} AND ANY uuid IN data.identifier SATISFIES uuid =  END")
    List<BendicionesDoc<Item>> findById(Identifier identifier);


}

这里是用 Lombok 库创建的所有对象

public class BendicionesDoc<T>implements Serializable {


        @Field
        private T data;

    }

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
public class Item {

    private List<Identifier> identifier;


}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(NON_NULL)
@EqualsAndHashCode
public class Identifier {

    private String id;
    private MasterServant idContext;
    private MasterServant idScope;

}

@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;
    }

}

但是当我 运行 存储库查询时,我得到了这个错误:

java.lang.IllegalArgumentException: Unsupported type for JsonArray: class com.bendiciones.Identifier

Identifier是一个对象,不能简单的让Couchbase在N1QL

中比较一个对象

您的方法定义应该类似于:

@Query("#{#n1ql.selectEntity} where #{#n1ql.filter} AND ANY uuid IN data.identifier SATISFIES uuid.id =  END")
List<BendicionesDoc<Item>> findById(String id);