We're creating a simple selection (distinct) including an order clause.
When watching the created criteria in debugger we get the correct expression:
SELECT DISTINCT $1 FROM MyEntity $1 WHERE ((TYPE($1)=class test.MyEntity)) ORDER BY UPPER($1.name) DESC
You can see that in the order by there's correctly a "$1" var. Running this (without the type thing before) in the explorer correctly returns the sorted results.
However, running this with the criteria API produces this error:
Caused by: com.objectdb.o.UserException: Invalid order expression '$2' for distinct results at com.objectdb.o.MSG.d(MSG.java:61) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.l(QNF.java:333) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.n(QNF.java:394) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.k(QNF.java:169) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.z(QNF.java:783) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.k(QNF.java:257) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.B(QNF.java:886) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.k(QNF.java:277) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QNF.j(QNF.java:134) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QRC.E(QRC.java:550) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QRC.v(QRC.java:213) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QRC.u(QRC.java:165) [objectdb-2.4.4_05.jar:] at com.objectdb.o.QRM.U5(QRM.java:248) [objectdb-2.4.4_05.jar:] at com.objectdb.o.MST.U5(MST.java:959) [objectdb-2.4.4_05.jar:] at com.objectdb.o.WRA.U5(WRA.java:291) [objectdb-2.4.4_05.jar:] at com.objectdb.o.WSM.U5(WSM.java:113) [objectdb-2.4.4_05.jar:] at com.objectdb.o.STC.r(STC.java:449) [objectdb-2.4.4_05.jar:] at com.objectdb.o.SHN.aj(SHN.java:489) [objectdb-2.4.4_05.jar:] at com.objectdb.o.SHN.K(SHN.java:156) [objectdb-2.4.4_05.jar:] at com.objectdb.o.HND.run(HND.java:132) [objectdb-2.4.4_05.jar:] ... 1 more
This doesn't make any sense, there might not be any "$2" variable. More strangely, when debugging through the error doesn't error but if you run without debugging through then it happens.
Please advise / fix, this is more than a show stopper, we cannot even sort right now!!