gpt4 book ai didi

java - 数组中的 QueryDSL 不区分大小写的过滤器

转载 作者:行者123 更新时间:2023-11-30 05:28:48 25 4
gpt4 key购买 nike

考虑以下 Java 类:

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.List;

@Document(collection = "Doc")
public class Doc {

@Id
private String id;

private List<String> tags;
}

我已经生成了一个查询类型 QDoc 因为我想轻松地按不区分大小写标签名称进行过滤。

/**
* QDoc is a Querydsl query type for Doc
*/
@Generated("com.querydsl.codegen.EntitySerializer")
public class QDoc extends EntityPathBase<Doc> {

private static final long serialVersionUID = 602371596L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QDoc doc = new QDoc("doc");

public final StringPath id = createString("id");

public final ListPath<String, StringPath> tags = this.<String, StringPath>createList("tags", String.class, StringPath.class, PathInits.DIRECT2);

...
}

目前,我使用以下代码行完成区分大小写的过滤:

QDoc qDoc = QDoc.doc;
BooleanBuilder where = new BooleanBuilder();
where.and(qDoc.tags.contains("Tag name to filter for"));

如何对 ListPath<String, StringPath> 进行不区分大小写的过滤?

最好,

菲利普

最佳答案

您可以通过 any() 方法检查不区分大小写的数据,如下所示:

QDoc qDoc = QDoc.doc;
BooleanBuilder where = new BooleanBuilder();
where.and(qDoc.tags.any().equalsIgnoreCase("Tag name to filter for"));

这对我有用。

关于java - 数组中的 QueryDSL 不区分大小写的过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58001604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com