Skip to content

Using 'order by' gives InvalidSortExpression #20

@ChristianTellefsen

Description

@ChristianTellefsen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions