Hey, I'm back again, with another funky problem.
Same situation with the autogenerated composite id (working like a champ thanks to Gavin's Debugging Fu) but I'm having a problem adding a <timestamp> or <version> element to the composite id class. I can add a property of type timestamp just fine, but when I use a <timestamp> or <version> element I get exceptions related to a null SQL statement being sent to the database.
This does not happen when I have a timestamp on a mapped class with a regular id.
Here's the debug trace. I'm using MySQL with the 3.0.8 JDBC driver.
Code:
13:22:19,836 DEBUG NormalizedEntityPersister:676 - Updating entity: [com.foo.bar.data.menu.HeirarchyItem#com.foo.bar.data.sites.CompositeSiteID@4a5c78[]]
13:22:19,838 DEBUG NormalizedEntityPersister:677 - Existing version: Tue Sep 09 13:21:27 CDT 2003 -> New version: 2003-09-09 13:21:43.094
13:22:19,838 DEBUG BatcherImpl:192 - about to open: 0 open PreparedStatements, 0 open ResultSets
13:22:19,839 DEBUG BatcherImpl:226 - prepared statement get: update base_site_data_objects set timestamp=? where generated_id=? and site=? and timestamp=?
Hibernate: update base_site_data_objects set timestamp=? where generated_id=? and site=? and timestamp=?
13:22:19,841 DEBUG BatcherImpl:232 - preparing statement
13:22:19,842 DEBUG BatcherImpl:192 - about to open: 1 open PreparedStatements, 0 open ResultSets
13:22:19,844 DEBUG BatcherImpl:226 - prepared statement get: null
Hibernate: null
13:22:19,845 DEBUG BatcherImpl:232 - preparing statement
13:22:19,854 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
13:22:19,859 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: S1009
13:22:19,862 ERROR JDBCExceptionReporter:46 - SQL String can not be NULL
13:22:19,864 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
13:22:19,867 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: S1009
13:22:19,871 ERROR JDBCExceptionReporter:46 - SQL String can not be NULL
13:22:19,872 DEBUG BatcherImpl:199 - done closing: 1 open PreparedStatements, 0 open ResultSets
13:22:19,873 DEBUG BatcherImpl:245 - closing statement
13:22:19,880 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
13:22:19,881 WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: S1009
13:22:19,884 ERROR JDBCExceptionReporter:46 - SQL String can not be NULL
13:22:19,885 ERROR JDBCExceptionReporter:38 - could not delete: [com.foo.bar.data.menu.HeirarchyItem#com.foo.bar.data.sites.CompositeSiteID@4a5c78[]]
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
13:22:19,889 ERROR SessionImpl:2242 - Could not synchronize database state with session
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
rethrown as
net.sf.hibernate.JDBCException: could not delete: [com.foo.bar.data.menu.HeirarchyItem#com.foo.bar.data.sites.CompositeSiteID@4a5c78[]]: SQL String can not be NULL
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:710)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
Caused by: java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
... 7 more
Exception in thread "main" java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
rethrown as net.sf.hibernate.JDBCException: could not delete: [com.foo.bar.data.menu.HeirarchyItem#com.foo.bar.data.sites.CompositeSiteID@4a5c78[]]: SQL String can not be NULL
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:710)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:669)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:38)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2278)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2235)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2178)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:56)
at HibernateTest.main(HibernateTest.java:531)
Caused by: java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:115)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1293)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:233)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:687)
... 7 more