Luigi,
Actually would you be able to provide the exact query statement you have in
your repo. The reason it fails in this test is because the query looks
like this:
@Query("select s from Simple s")
public abstract QueryResult<Simple> queryAll();
Whereas the identifier is expecting e, in order to work with QueryResult.
A similar problem happens with the named query when I change the identifier.
There's a couple of thoughts I had.
1. We can introduce an attribute in query (or even a hint) that says what
the identifier is in "select s from Something s". This would be more
robust and configurable, but introduce a burden.
2. Update documentation to clarify that "e" should be used as your query
identifier by default.
John
On Wed, Mar 30, 2016 at 7:50 PM John D. Ament <[email protected]> wrote:
> Thank you Luigi!
> I'm able to reproduce, I'll create a ticket.
>
> John
>
>
> On Wed, Mar 30, 2016 at 4:59 AM Luigi Bitonti <[email protected]> wrote:
>
>> Hi John,
>>
>> If you add the following test to QueryResultTest.java in
>> deltaspike-data-module:
>>
>> @Test
>> public void should_sort_all_result()
>> {
>> List<Simple> result = repo.queryAll()
>> .orderDesc(Simple_.counter)
>> .orderAsc(Simple_.id)
>> .getResultList();
>> }
>>
>> You'll get the following error:
>>
>> Tests in error:
>>
>> should_sort_all_result(org.apache.deltaspike.data.impl.QueryResultTest):
>> org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path:
>> 'e.counter' [select s from org.apache.deltaspike.data.test.domain.Simple s
>> order by e.counter DESC,e.id ASC]
>>
>> This is an overly simplistic case that could be worked around by using
>> 'e' as an alias in queryAll (instead of 's'), but in more complex case with
>> joins and order by clauses that use associated entities there's no
>> workaround that I can see.
>>
>> I tried (briefly I must confess) to work around this by creating an
>> alternative QueryBuilderFactory that could then allow me to avoid using
>> WrappedQueryBuilder, DefaultQueryResult and (ultimately)
>> OrderByQueryStringPostProcessor but code duplication made the solution
>> rather ugly, so I gave up and decided to ask.
>>
>> Cheers,
>> Luigi
>>
>> On Wednesday, March 30, 2016 12:32 AM, John D. Ament <
>> [email protected]> wrote:
>>
>>
>> Luigi,
>>
>> Do you happen to have a test that can reproduce this?
>>
>> John
>>
>> On Tue, Mar 29, 2016 at 5:20 PM Luigi Bitonti <[email protected]>
>> wrote:
>>
>> Hi all,
>> I am having issues with using the orderAsc and orderDesc methods on
>> QueryResult as the order by clause always ends up having an "e." prepended
>> to its sort-by properties (e.g "...order by e.i.date_from" instead of
>> "...order by i.date_from". Is there any way to avoid that from happening?I
>> am using Deltaspike 1.4.2 but from what I can see in the
>> OrderByQueryStringPostProcessor source this is still the case in 1.5.4 and
>> also current git master.
>> Many thanks,Luigi
>>
>>
>>
>>