Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for older version of mssql #362

Closed
googol4u opened this issue Mar 15, 2013 · 5 comments
Closed

Support for older version of mssql #362

googol4u opened this issue Mar 15, 2013 · 5 comments
Milestone

Comments

@googol4u
Copy link

@googol4u googol4u commented Mar 15, 2013

Please add support for older version of mssql. For example, in mssql 2000, "with...as" and row_number() are not supported. SQL statement generated by query.from(...).limit(5).list(...):

with inner_query as 
(
  select customers.customer_id, customers.customer_name, row_number() over () as row_number
from customers customers
)
select * 
from inner_query
where row_number <= 5

will not work. instead, it should be:

select top 5 customers.customer_id, customers.customer_name from customers

Thanks and regards!

@timowest
Copy link
Member

@timowest timowest commented Mar 15, 2013

How do you want to have limit + offset and offset to behave with MSSQL 2000?

@timowest
Copy link
Member

@timowest timowest commented Mar 15, 2013

Now select top ... is available in SQLServerTemplates and newer limit/offset features are implemented in SQLServer2005Templates.

This follows the hierarchy of Hibernate's Dialect.

@googol4u
Copy link
Author

@googol4u googol4u commented Mar 18, 2013

Thanks!

I think there is no mechanism for offset in older SQL Server.

BTW, I have seen this kind of usage of template in your code:

metadata.addFlag(new QueryFlag(QueryFlag.Position.AFTER_SELECT,
                        Expressions.template(Integer.class, topTemplate, mod.getLimit())));

Where could I found document about how to correctly write template?

@timowest
Copy link
Member

@timowest timowest commented Mar 21, 2013

Tempates are not yet properly documented, since Operations should be preferred.

Template syntax is easy, just Strings with indexed place holders like this "functionX({0}, {1})"

{0} refers to the first argument, and {1} to the second

@timowest
Copy link
Member

@timowest timowest commented Mar 21, 2013

Released in 3.0.0

@timowest timowest closed this Mar 21, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants