Support for older version of mssql #362

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

Comments

Projects
None yet
2 participants
@googol4u

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 15, 2013

Member

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

Member

timowest commented Mar 15, 2013

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

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 15, 2013

Member

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

This follows the hierarchy of Hibernate's Dialect.

Member

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

This comment has been minimized.

Show comment
Hide comment
@googol4u

googol4u 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?

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 21, 2013

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 21, 2013

Member

Released in 3.0.0

Member

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