New to hibernate development but I've done some searching and haven't found the answer so I'll throw it out to the gurus.
I'm attempting to add a record to a table hosted in a DB2 database. The mapping I have is:
when I attempt to save a DBCivicAddress object I get the following:
2009-02-18 15:52:27,000 DEBUG [JDBCExceptionReporter] - could not get next sequence value [values nextval for SQ_CIVIC_ADDRESS]
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -142, SQLSTATE: 42612, SQLERRMC: null
The exception message above shows the SQL that is being attempted and it doesn't seem to be a well formed INSERT. I've manually tried a well formed INSERT using the NEXTVAL FOR SQ_CIVIC_ADDRESS to generate the id and it works fine. Conversely attempting "values nextval for SQ_CIVIC_ADDRESS] fails with the -142 error code that hibernate is reporting.
Any ideas on what may be wrong? The NEXTVAL FOR is supported by DB2 so I can only think that the -142 error being reported is referring to the "values" statement, which doesn't seem to make sense by itself and should be wrapped by an insert statement.
Which version of DB2 are you using...
We had used the DB2 version 9.5 GA and there seemed to be no such problem..although we were generating the sequence in a a similar way...
Are you using the older versions...like version 8...
Anyways, the quote mentioned by Javid should fix the problem...
The guy on this post said he had to create his own Dialect
posted 11 years ago
Thanks guys. Extending the DB2 dialect did the trick.
My pie came with a little toothpic holding up this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!