Hello,
I have got Problems reading the next value on a sequence from a DB2 UDB for iSeries Database with
Hibernate as JPA Provider:
Code:
Query nextvalQuery = em
.createNativeQuery("SELECT NEXTVAL FOR schemaname.sequencename"
+ " FROM SYSIBM.SYSDUMMY1");
Object snr = nextvalQuery.getSingleResult();
Code:
Hibernate:
select
*
from
( select
rownumber() over() as rownumber_,
NEXTVAL FOR schemaname.sequencename
FROM
SYSIBM.SYSDUMMY1 ) as temp_
where
rownumber_ <= ?
2011-01-31 11:43:34,460 WARN [main] org.hibernate.util.JDBCExceptionReporter: SQL Error: -348, SQLState: 428F9
2011-01-31 11:43:34,460 ERROR [main] org.hibernate.util.JDBCExceptionReporter: [SQL0348] Ausdruck NEXT VALUE ist nicht korrekt verwendet.
Translated error message: The expression NEXT VALUE is not used correctly.
When I execute the original query in my SQL Client, everything works find. When I try to execute the subselect generated by Hibernate, the result is fine as well, but when I execute it, with the surrounding query, I get the same error message.
May this be a bug?
best regards,
Andreas