Couchbase的Spring数据:使用AND……

问题描述 投票:3回答:1

我有一个SpringBoot 2应用程序,该应用程序使用Couchbase作为数据库,使用Spring-Boot和Spring-Data,以及Lombok的getters和equals方法我已经创建了此存储库

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

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


}

以及所有使用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;
    }

}

但是当我运行资源库查询时,即使有文档,也总是得到0个结果。在数据库中:

java spring-boot couchbase spring-data-couchbase couchbase-java-api
1个回答
0
投票
您需要在reference type中定义您的CouchbaseRepository<T, K>,然后只需将引用类型Item添加为CouchbaseRepository<BendicionesDoc<Item>, String>,并且只需将Repository query keywords用作findById(String id)
© www.soinside.com 2019 - 2024. All rights reserved.