[hibernate-issues] [Hibernate-JIRA] Created: (EJB-366) Using setMaxResults with a NativeQuery with DB2 generates non-working SQL

Toni Lyytikäinen (JIRA) noreply at atlassian.com
Thu Jun 5 05:42:32 EDT 2008


Using setMaxResults with a NativeQuery with DB2 generates non-working SQL
-------------------------------------------------------------------------

                 Key: EJB-366
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-366
             Project: Hibernate Entity Manager
          Issue Type: Bug
          Components: EntityManager
    Affects Versions: 3.4.0.CR1, 3.3.2.GA
         Environment: Linux 2.6.24, DB2 Express-C V9.5.0.0, Glassfish V2
            Reporter: Toni Lyytikäinen
            Priority: Critical


Creating a simple native query like the following:

Query query=entityManager.createNativeQuery("select t.* from test");

and setting the setMaxResults to some value generates an SQL sentence which is incorrect as it has an extra parenthesis in the beginning:

query.setMaxResults(15);

Log output:
Hibernate: (select * from ( select rownumber() over() as rownumber_, t.* from test t ) as temp_ where rownumber_ <= ?
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -104, SQLState: 42601
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=END-OF-STATEMENT;here rownumber_ <= ?;), DRIVER=3.50.152
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -727, SQLState: 56098
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-104;42601;END-OF-STATEMENT|here rownumber_ <= ?|), DRIVER=3.50.152
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -727, SQLState: 56098
Jun 5, 2008 12:31:05 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-104;42601;END-OF-STATEMENT|here rownumber_ <= ?|), DRIVER=3.50.152

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       




More information about the hibernate-issues mailing list