Assume me having a table of cats with plenty of columns. I am trying to do equivalent of this query in QueryDsl:
select * from cat where (cat.pattern, cat.breed) in (('calico', 'Siberian'), ('grey', 'Siamese'), ('tabby', 'Maine Coon'));
In Java I have this class for parametrizing my cats:
class CatParameters {
public String pattern;
public String breed;
}
And this method (unfortunately incorrect) to fetch cats from database:
public List<CatDto> getCatsByParameters(List<CatParameters> params) {
// something like this
QCat cat = QCat.cat;
return query.from(cat)
.where(Expressions.list(cat.pattern, cat.breed).in(params))
.list(ConstructorExpression.create(CatDto.class, cat.field1, cat.field2, cat.field3, .../* etc */))
}
This obviously leads to an error "Cannot resolve method 'in(java.util.List<my.package.name.Cat>)'"
.
So how can I query some cats with (colX, colY) being in list of java objects with those properties?
UPD: I have found this question on fairly similar topic with subquery instead of collection, yet I wonder if there is a way to do it with collection (or maybe somehow create List<Tuple> from List<CatProperties>).