Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
JPA Filter @OneToMany (List)
Hello my Name ist Dennis and i run into an problem.
I have an Entity with the name planung thats holds an list and looks like
@OneToMany( targetEntity=Arbeitsschritt.class)
private List<Arbeitsschritt> arbeitsschritte = new LinkedList<Arbeitsschritt>();
now i try to filter the data by list size,thats means i would see only planungs entity's with an list size from zero.
I think it ist possible with an native JPQL query with the isEmpty, statment.
I tryed to code an own filter which implements Container.Filter, but than the framework raies an Filterconverter errror.
has anybody an nice tipp, hoq to solve my problem
thanks
So i found an solution, i guess thats a bit hacky. but it works!
i found the Querying with the Criteria API Articel in the Vaadin Doc:
https://vaadin.com/docs/-/part/framework/jpacontainer/jpacontainer-filtering-criteria-api.html
For understanding:
planungen = JPAContainer with the Entity which holds an List-object
verbergeGeplante = Checkbox (if Valuechange planung is Rereshing)
arbeitsschritte = is the List property from the Entity
I recode it to
planungen.getEntityProvider().setQueryModifierDelegate(new DefaultQueryModifierDelegate() {
@Override
public void filtersWillBeAdded(CriteriaBuilder criteriaBuilder, CriteriaQuery<?> query,
List<Predicate> predicates) {
if (verbergeGeplante.getValue()) {
Root<?> fromPlanung = query.getRoots().iterator().next();
Path<List<Arbeitsschritt>> arbeitsschritte = fromPlanung
.<List<Arbeitsschritt>> get("arbeitsschritte");
predicates.add(criteriaBuilder.isEmpty(arbeitsschritte));
}
}
});
thanks