Hi everybody,
When persisting a mapped object that has a String containing a single quote ' into the HSQLDB, the quote does not get escaped. The insert statement therefore fails...
I'm using the org.hibernate.dialect.HSQLDialect in my hibernate.cfg.xml, which according to it's javadoc should work with HSQL 1.8; also using the standard JDBC driver which comes with HSQLDB org.hsqldb.jdbcDriver.
For better logging, I use the JDBC "redirector" P6Spy, so I thought the problem comes from there, but after switching back to the direct "un-redirected" JDBC driver, the problem remained.
According the all the forum posts I found in the forum and the documentation, the JDBC driver should take care of escaping. Is there an updated version of the JDBC driver, or any other workaround?
And just if somebody is wondering: YES I'm using named parameters, since I just use session.save(myObject) ...
Any help with this problem, would be highly appreciated since I don't want to inspect all my objects if their strings contain single quotes...
Markus
Hibernate version: Hibernate 3.3.1.GA
Mapping documents: none, using annotations
Code between sessionFactory.openSession() and session.close():
Transaction tx=session.openSession();
session.save(myObject);
tx.commit();
Full stack trace of any exception that occurs:
[2008-11-06 00:53:31,447] WARN (JDBCExceptionReporter.java:100) - SQL Error: 0, SQLState: null
[2008-11-06 00:53:31,448] ERROR (JDBCExceptionReporter.java:101) - failed batch
[2008-11-06 00:53:31,449] ERROR (AbstractFlushingEventListener.java:324) - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at tk.korbel.thetvdb.api.LocalTvDbManager.performUpdate(LocalTvDbManager.java:192)
at tk.korbel.tvshoworganizer.Api_Test.main(Api_Test.java:21)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more
[2008-11-06 00:53:31,452] ERROR (Api_Test.java:23) - Error during API testing...
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at tk.korbel.thetvdb.api.LocalTvDbManager.performUpdate(LocalTvDbManager.java:192)
at tk.korbel.tvshoworganizer.Api_Test.main(Api_Test.java:21)
Caused by: java.sql.BatchUpdateException: failed batch
at org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more
Name and version of the database you are using: HSQLDB 1.8.0.10
The generated SQL (show_sql=true):
Hibernate: insert into series (series_actors, series_added, series_added_by, series_airs_dayofweek, series_airs_time, series_banner, series_content_rating, series_fanart, series_first_aired, series_genre, series_imdb_id, language_abbreviation, series_last_updated, series_name, series_network, series_overview, series_poster, series_rating, series_runtime, series_status, series_zap2it_id, series_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt: INFO
|