Stored Procedure invocation gets 'top 2' embedded by SQLServerDialect

Description

I have an entity class, annotated with Named Native Queries that invoke stored procedures

I then later invoke that named query to retrieve a value from the database

However, this query fails with an error returned from the JDBC driver layer, indicating "{" is invalid. Upon further investigation, it turned out that the SQLServerDialect class is injecting "top 2" into the middle of the call, resulting in the following SQL

The problem is in the function 'getLimitString()' within the SQLServerDialect class. It blindly assumes that the incoming SQL has either "select" or "select distinct", and inserts "top " + the current limit count into the SQL string.

I've worked around the problem temporarily by creating my own subclass of SQLServerDialect that overrides that method and looks for the presence of "{call", and if it finds it, returns the SQL string back unmodified (thereby not imposing a limit). I'm sure there is probably something better that can be done....

Environment

Hibernate 3.3.2/3.3.1 connection to a SQL Server database

Activity

Show:
Steve Ebersole
March 22, 2011, 6:09 AM

Bulk closing stale resolved issues

Duplicate

Assignee

Gail Badner

Reporter

Eduard Martinescu

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major