JPAContainer problem with Or-Filter

Hi Folks,
when using JPAContainer with the Or-Filter, i get the same Items multiple times in the filtered container.
Here’s my sample code:

Test Entities:

public class TestEntity {
    private Integer id;
    private Collection<TestEntity2> testEntities2 = new HashSet<TestEntity2>();

    private String someField;


public class TestEntity2 {
    private Integer id;
    private String someField;


Test Code:

// Create containers for the 2 entity-types
JPAContainer container = JPAContainerFactory.make(TestEntity.class, …pu…);
JPAContainer container2 = JPAContainerFactory.make(TestEntity2.class, …pu…);

// Create entities
TestEntity testEntity = new TestEntity();
// Add and retrieve to have Object with id set
TestEntity2 testEntity2ToAdd1 = container2.getItem(
container2.addEntity(new TestEntity2())).getEntity();
TestEntity2 testEntity2ToAdd2 = container2.getItem(
container2.addEntity(new TestEntity2())).getEntity();

// Add to collection

// Add to the container

// Create an Or-filter for the just created TestEntity2-entities
Or or = new Or(
new Compare.Equal(“”, testEntity2ToAdd1.getId()),
new Compare.Equal(“”, testEntity2ToAdd2.getId()));

// Add the filter

// Will output the ID of testEntity 3x
[/code]This is the SQL-Statement created:
SELECT t0.ID FROM TESTENTITY_TESTENTITY2 t4, TESTENTITY_TESTENTITY2 t3, TESTENTITY2 t2, TESTENTITY2 t1, TESTENTITY t0 WHERE (((t1.ID = ?) OR (t2.ID = ?)) AND (((t3.TestEntity_ID = t0.ID) AND (t1.ID = t3.testEntities2_ID)) AND ((t4.TestEntity_ID = t0.ID) AND (t2.ID = t4.testEntities2_ID)))) ORDER BY t0.ID ASC

I am no SQL-Expert, but this select statement looks pretty odd to me.

If i add a third entity to the collection and append it to the Or-filter, testEntity is 19x in the container.
I tried Collection, Set and List as type of “testEntities2”.

Am i doing somethig wrong or is this a Bug?

The And-filter seems to work, allthough the SQL-Statement looks odd too…

Environment info:

Should be the newest version of all used libs

Thank you,

I worked around the problem by setting an QueryModifierDelegate an always make the queries distinct.
But i would be really interested if i found a bug or just having some faulty reasoning here.

Ok my workaround does not work properly… If you call container.size() you get of course still the “wrong” result and for example the table component is not usable…
Any help would be really appreciated!
I plan to move away from JPAContainer (because even some Vaadin Devs don’t like it) but for now i have to stick with it.