suppose i have a sequence, called TEST_SEQ
what would be the correct way of selecting its next value ?
this does not work:
select next value for TEST_SEQ
probably because it expects a “FROM” clause.
looking at HSQLDialect.getSequenceNextValString() in hibernate i see this:
"select next value for " + sequenceName + " from dual_" + sequenceName
which in my case would result in something like:
select next value for TEST_SEQ from dual_TEST_SEQ
which does not work for 2.0.0-rc8 (i only assume this works in pre-2.0 versions – havent verified)
I’ve come across a solution that involves creating a simple table with 1 row called DUAL, in which case this will work (oracle style):
select next value for TEST_SEQ from DUAL
but hsqldb does not come with this table out of the box, and im not sure how i can get hibernate to generate such a table on “first boot”.
Im thinking there has to be a way to get the next value for a sequence out of the box and im just missing it.
any ideas ?
While the documentation says:
the "correct" way (because simpler, because not involving a table like a dumb DUAL table that HSQLDB doesn’t have) would be:
This appeared in 1.7.2 and this is actually how Hibernate handles sequences in the
HSQLDialectof "recent" versions of Hibernate Core (seeHHH-2839).And indeed, this is what I see in the
HSQLDialectofhibernate-core-3.3.0.SP1.jar:So my advice is: upgrade to a newer version of Hibernate, you are very likely using Hibernate Core 3.2.5 or prior.