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....
Hibernate 3.3.2/3.3.1 connection to a SQL Server database
Bulk closing stale resolved issues