[hibernate-dev] SQLServer getLimitString() refactoring
Łukasz Antoniak
lukasz.antoniak at gmail.com
Thu Jun 14 04:03:43 EDT 2012
Hello Steve/Guenther,
@Steve: Thank you for clear explanation. Will create delegate
interface and come back to you. Not sure if it would be backward
compatible, have to check that :).
> This is because HQL apparently does not support the suppression of the "AS" keyword for aliases, so this query works only by using the Native-SQL api.
In the previous message you wrote:
"Query q = session.createQuery( "select id, description descr, (select
max(id) from MySequence) maximum from Product2 ");
In this case HQL don't adds the "AS" keyword for the "descr" and
"maximum" aliases, so stripAliases-method & co could have problems in
filtering aliases correctly."
I am a little bit confused with your response, since such HQL query
fails. However, your statement regarding native SQL is correct.
> - I expected to find TOP(2) instead of TOP(3).
> Although due the __hibernate_row_nr__ restriction the final result is correct, I find this a little disconcerting..
I don't have my laptop with me right now, but will check that shortly.
> - I hoped that due to the changes in Dialect.class you were already able to implement also HHH-7370
> In front of such complex transformation as it has become now, I believe that HHH-7370 gains importance,
> what do you think about?
I will implement it, sure. Notice that everyone can extend Dialect
class easily. But I somehow disagree that proposed transformation is
more complex then it is now. Simulating DISTINCT with GROUP BY,
stripping aliases etc. can be very fragile. Here we just encapsulate
the original query and add TOP if needed (which actually might improve
performance). Not sure what MS SQL DBA would comment about execution
plan. If I remember correctly, there are situations where Hibernate
does SELECT * FROM ( another_query ).
Best Regards,
Lukasz
More information about the hibernate-dev
mailing list