The solution proposed in: https://stackoverflow.com/a/11138229/1270045 works pretty fine in java but i am in kotlin. How can that be done here that i pass a predicate array to the criteria builder written in kotlin?
So its about writing this in kotlin that i can be passed on:
cq.select(customer).where(predicates.toArray(new Predicate[]{}));
My example code:
val predicates = mutableListOf<Predicate>()
if (XYZ != null) {
val XYZPath = element.get<Long>("XYZ")
predicates.add(criteriaBuilder.equal(XYZPath, XYZ))
}
criteriaQuery.select(element)
.where(criteriaBuilder.or(???))
Thanks to marstran for your help that solved it:
criteriaQuery.select(element)
.where(criteriaBuilder.or(*predicates.toTypedArray()))