Dencel wrote:
Note: this code gives an error
Code:
Criteria c = session.createCriteria(FooClass.class)
.add(Restri...)
.createCriteria("bar").add(Restr...);
....
c.createCriteria("bar").addOrder(Order.desc("foobar"));
I may be wrong, but the error is cause by the createCriteria("bar"), 'cause it declares a self join without specifying an alias. Try to just add the order:
Code:
Criteria c = session.createCriteria(FooClass.class)
.add(Restri...)
.createCriteria("bar").add(Restr...);
....
c.addOrder(Order.desc("foobar"));
The problem is that the method addOrder just
adds the order, so if you apply a different order later on the same criteria, the orders will be applied together... uhm, so the only solution seems to be to clone the criteria object... [/b]