How can I filter JPA container with one-to-many relationship

Hello everyone,
I’m currently working on a vaadin project and stuck with the following problem---------------->
Here’s my RCIEntity class’s one-to-many relationship—

@OneToMany (mappedBy = “rciEntity”)
private Set projectUserRoles;

@OneToMany (mappedBy = "rciEntity")
private Set<RCIUserRole> appartmentUserRoles;


here’s the RCIUserRole class----

private UserAccount userAccount;
private Integer userLevel;

private RCIEntity rciEntity;

now I take a jpa container JPAContainerrciEntityContainer = JPAContainerFactory.make(RCIEntity.class, GroupBuilderApp.PERSISTENCE_UNIT);
How can I filter the rciEntityContainer with RCIUserRole’s userAccount field?
Please help me, this filterring is giving me so much pain, last few days…


did you try filters described in ? If yes, why they don’t suit to you?


Yep I’m using the JoinFilter described in which is working ok.
But now the join filter returning duplicate values in the corresponding JpaContainer, is there any way to not have those duplicate values in the JpaContainer while using the joinFilter??

Thanks in advance…

Did you find a proper solution? I’m stuck in the same situation

Where have you stucked?? Are you getting duplicate values??

I’m using hibernate + jpacontainer on a sqlserver. When I use it normalyy everything is fine, but as soon as I use JoinFilter on a one to many relation I got duplicates. i’m not surprised (even if eclipseLink takes care of the join and the duplicates alnoe, a join normally produces duplicates) but I cannot find a clean way to get rid of them. At the moment I’m looking into the QueyModifierDelegate and I also thought about an “value IN ()” filter but vaadin container apparently hasn’t it?
Any input would be greately appreciated!

Actually there was a bug in Jpacontainer addon with that duplicate issue which I found marked solved in the bug ticket but dont get it work though :(.

Btw now a days vaadin dont encouraged to use jpacontainer for complex thing like we’re talking about that join filter issue. So its better to use JpaContainer for simple cases (e.g showing a simple table).

Well my grid so not that complex, is really just a list of entities from a table where I just want to apply Filter(s).
Nothing fancy, it all works good except when filtering on one to many relationships :frowning:

Ok if your grid shows just the list of entities nothing else (e.g. any other process with those entities while clicking it or something else) then you can use the following code snippet which will show data without any duplicaiton:


checkListContainer.setQueryModifierDelegate(new DefaultQueryModifierDelegate() {
public void filtersWillBeAdded(CriteriaBuilder cb, CriteriaQuery<?> query, List predicates) {
Root item = (Root) query.getRoots().iterator().next();
Join<RCIUserRole, RCIEntity> tagJoinRole = item.join(“rci”).join(“appartmentUserRoles”);
predicates.add(cb.equal(tagJoinRole.get(“userAccount”), GroupBuilderApp.getInstance().getCurrentUserAcc()));