Search code examples
javaquerydsl

when to use ListPath (querydsl)?


I have a current code that use listPath, but I encounter problems to understand it in order to add changes.

I didn't find useful informations when searching in google.

Any explanation when and how to use it ?


Solution

  • You can for example join a ListPath

    Given the entity metamodel:

    @Generated("com.querydsl.codegen.EntitySerializer")
    public class QCat extends EntityPathBase<Cat> {
        // Other fields omitted for brevity
    
        public final ListPath<Cat, QCat> kittens = this.<Cat, QCat>createList("kittens", Cat.class, QCat.class, PathInits.DIRECT2);
    

    You could for example do:

    query().from(cat, cats)
               .innerJoin(cat.kittens, kitten).where(kitten.name.eq("Kitty"))
               .select(cat).fetch();