My question is very simple, I have this ejbSelect and EJB-QL:
java.util.Set ejbSelectStuff(Long objectTypePK, int value)
SELECT DISTINCT Object(rt)
FROM ObjectType ot, IN(ot.relatedTypes) rt
WHERE ot.objectTypePK= ?1
AND ?2 BETWEEN rt.minimum AND rt.maximum
ORDER BY rt.major ASC, rt.minor ASC
(the names have been changed to protect the innocent ;)
Now, the above EJB-QL compiles and runs without complaints, and it returns the correct set of objects. However, the resulting set is in completely random order, not sorted by either rt.major or rt.minor.
I'm using versions 3.2.7 and 4.0.1sp1, same problem on both.
Any idea what's wrong?
Turns out the problem is somehow related to the return type being java.util.Set and not java.util.Collection. For some reason the resulting Set does not retain the ordering.
Anyways, problem solved simply by returning a Collection instead of a Set.