I've searched the forums for an answer to this question, and all the posts suggest that you identify the sequence in your HBM files to auto-insert the values prior to database insert.
Unfortunately that won't work for what I'm trying to accomplish.
Situation:
I am maintaining an application which in production uses DB2. I need to write unit tests for the database manipulation classes. So to ensure no changes to an actual database, I've written up DBUnit tests backed by a HSQLDB data source.
One of the tables i need to create a test for uses a Sequence for one of the columns in the primary key. With Hibernate HBM files, you can not define a sequence on a column unless it is a single-column PK.
The current, working method uses a straight SQL statment to get the next sequence for the required column. I need to convert this to HQL so it will work for both DB2 & HSQLDB.
Does anyone know how you accomplish this? Currently, when running the command against an HSQLDB I get an SQLException ("Statement does not generate a result set").
Any thoughts?
-B
|