Okay, I'll be honest: I thought I am familiar with JPA on top of ORM solutions, but now when moved to ObjectDB I sometimes encounter, let's say, unexpected behavior and I begin to doubt in my JPA-fu. Sometimes I am not really sure if behavior I encounter with ObjectDB is correct or not, although I am pretty sure it's not consistent with other JPA providers. And here is such case:
List jpqlResult = em.createQuery( "SELECT d FROM Demand d JOIN FETCH d.services WHERE d=:demand") .setParameter("demand", demand).getResultList();
I want this query to find one and only Demand object and fetch its services. Demand object is identified and found correctly, but as it is associated with two services, it's returned twice (both results contain the same instance). I believe that such query should return only one result, with fetched service sub-elements, shouldn't it? I am almost sure (but I did not bother to check, sorry!) that JPA+Hibernate would return only one result. Am I wrong? Is it something specific to ObjectDB? Is it a bug?
This behavior appears with JPQL and with equivalent CriteriaQuery.
Thanks and best regards,
Maciek