4

Consider the following Java class:

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

I have generated a query type QDoc for it because I want to easily filter by case insensitive tag names.

/**
 * 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);

   ...
}

Currently, I accomplish the case sensitive filtering with the following lines of code:

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

How is the case insensitive filtering done for a ListPath<String, StringPath> ?

Best,

Philipp

1 Answer 1

7

You can check case insensitive data via any() method as follows:

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

It works for me.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.