|
I'm working on a project using SAP MaxDB. Currently it uses Hibernate 3 with a custom SAPDBDialect to support identity columns (similar to HHH-7324).
While trying to migrate the project to Hibernate 4.2, I'm getting an UnsupportedOperationException from the JDBC driver when trying to save a new object. Stack trace attached.
The cause is the JDBC driver not implementing
java.sql.PreparedStatement#prepareStatement(String sql, int autoGeneratedKeys)
and throwing a
java.lang.UnsupportedOperationException
instead.
IMHO the driver is breaking the contract here, as per java.sql.Connection javadoc, it should only throw (a different Exception) when passed Statement.RETURN_GENERATED_KEYS as parameter, which is not the case here.
Nevertheless, I have no hope that the driver will be fixed anytime soon. Someone else reported the same problem on the SAP forum last year and didn't get any feedback at all: http://scn.sap.com/thread/3415790
The use of
java.sql.PreparedStatement#prepareStatement(String sql, int autoGeneratedKeys)
is hard coded into StatementPreparerImpl. From my understanding, it would be ok to use
java.sql.PreparedStatement#prepareStatement(String sql)
when the autoGeneratedKeys parameter is Statement.NO_GENERATED_KEYS.
Attached is a patch for StatementPreparerImpl which does that and solves the problem for me.
I found no obvious way to provide an alternative StatementPreparer implementation. If there is one, please let me know.
|