-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Order by seems to be broken.
Running a query like this:
Query q = em.createQuery("select e from SomeTable e where e.somefield = :somefield order by e.score desc");
Will send a query like this to Amazon:
[INFO ] com.amazonaws.request: Sending Request: POST http://sdb.amazonaws.com / Parameters: (ConsistentRead: true, Action: Select, Version: 2009-04-15, SelectExpression: select count(*) from SomeDomain-SomeTable where somefield = 'somevalue' order by score desc, )
Which gives this error:
[INFO ] com.amazonaws.request: Received error response: Status Code: 400, AWS Request ID:XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
javax.persistence.PersistenceException: Status Code: 400, AWS Request ID: XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
at com.spaceprogram.simplejpa.query.AbstractQuery.getResultList(AbstractQuery.java:216)
at com.spaceprogram.simplejpa.query.QueryImpl.getCount(QueryImpl.java:369)
at com.spaceprogram.simplejpa.LazyList.size(LazyList.java:75)
Running the exact same query without the 'order by e.score desc' clause works without error. I guess the error might have to do with passing the order by clause to AWS when doing a count.
I'm getting this issue both in the 1.6 snapshot and in the AWS SDK .jar.