I am getting the below error when I try and insert a row in a table that has a column called modified_dt in the format of Timestamp.
Hibernate is generating the date in the following format.
'27 June 2005 16:51:12'
However, when I run the following query to find out the format of the timestamp in DB2...
'SELECT current timestamp FROM sysibm.sysdummy1'
I get the following back.
Jun 28, 2005 12:12:32 PM 508001
When I go to the Confiruation Assistant it tells me that the datetime is in the format associated with the country code (DEF).
I am wondering if this is a problem with Hibernate, as it seems to be generating the incorrect Timestamp format for the DB2 database. I know that we can change the Timestamp format but why should we have to do this, should Hibernate not be able to figure this out.
Here is the DB2 Create Table SQL.
Create table contact (
contact_ref Bigint NOT NULL,
tzone_type Integer,
lang_type Integer,
contact_title Varchar(20),
contact_job_title Varchar(50),
contact_dept Varchar(50),
contact_name Varchar(50) NOT NULL,
contact_phone Varchar(40) NOT NULL,
contact_phone2 Varchar(40),
contact_mobile Varchar(40),
contact_fax Varchar(40),
contact_email Varchar(50) NOT NULL UNIQUE,
contact_addr1 Varchar(50),
contact_addr2 Varchar(50),
contact_addr3 Varchar(50),
contact_addr4 Varchar(50),
contact_comment Varchar(254),
modified_dt Timestamp NOT NULL)
Hibernate version:
2.0
Mapping documents:
n/a
Code between sessionFactory.openSession() and session.close():
n/a
Full stack trace of any exception that occurs:
2005-06-27 16:51:14,327 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 2;DB2ADMIN.CONTACT
22007 Invalid datetime format. The syntax of the string representation of a datetime value is incorrect.
at com.ibm.db2.jcc.b.id.d(id.java:1385)
at com.ibm.db2.jcc.c.fb.l(fb.java:366)
at com.ibm.db2.jcc.c.fb.a(fb.java:64)
at com.ibm.db2.jcc.c.s.a(s.java:48)
at com.ibm.db2.jcc.c.xb.c(xb.java:266)
at com.ibm.db2.jcc.b.jd.ab(jd.java:1684)
at com.ibm.db2.jcc.b.jd.a(jd.java:2253)
at com.ibm.db2.jcc.b.jd.W(jd.java:537)
at com.ibm.db2.jcc.b.jd.executeUpdate(jd.java:520)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.avaya.crystal.ejb.common.BaseSessionBean.add(BaseSessionBean.java:209)
at com.avaya.crystal.ejb.provisioning.company.CompanySessionBean.add(CompanySessionBean.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:854)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:775)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
Db2 v8.1.7.445
The generated SQL (show_sql=true):
insert into contact (contact_name, contact_email, contact_phone, contact_phone2, contact_mobile, contact_fax, contact_addr1, contact_addr2, contact_addr3,
contact_addr4, contact_title, contact_job_title, contact_dept, contact_comment, modified_dt, tzone_type, lang_type, contact_ref) values
('CSV Company 0',
'csv@company0.com', '1234557770', null, null, null, null, null, null, null, null, null, null, null, '27 June 2005 16:51:12', 1, 1, 1)
Debug level Hibernate log excerpt:
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.impl.BatcherImpl - about to open: 0 open PreparedStatements, 0 open ResultSets
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.SQL -
insert into contact (contact_name, contact_email, contact_phone, contact_phone2, contact_mobile, contact_fax, contact_addr1, contact_addr2, contact_addr3,
contact_addr4, contact_title, contact_job_title, contact_dept, contact_comment, modified_dt, tzone_type, lang_type, contact_ref) values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.impl.BatcherImpl - preparing statement
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.persister.EntityPersister - Dehydrating entity: [com.avaya.crystal.dataobjects.Contact#1]
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding 'CSV Company 0' to parameter: 1
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding
'csv@company0.com' to parameter: 2
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding '1234557770' to parameter: 3
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 4
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 5
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 6
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 7
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 8
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 9
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 10
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 11
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 12
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 13
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.StringType - binding null to parameter: 14
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.TimestampType - binding '27 June 2005 16:51:12' to parameter: 15
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.engine.Cascades - id unsaved-value strategy NULL
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.LongType - binding '1' to parameter: 16
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.engine.Cascades - id unsaved-value strategy NULL
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.LongType - binding '1' to parameter: 17
2005-06-27 16:51:14,317 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.type.LongType - binding '1' to parameter: 18
2005-06-27 16:51:14,327 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.impl.BatcherImpl - done closing: 0 open PreparedStatements, 0 open ResultSets
2005-06-27 16:51:14,327 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.impl.BatcherImpl - closing statement
2005-06-27 16:51:14,327 [RMI TCP Connection(6)-10.121.10.157] DEBUG net.sf.hibernate.util.JDBCExceptionReporter - SQL Exception
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: 2;DB2ADMIN.CONTACT
22007 Invalid datetime format. The syntax of the string representation of a datetime value is incorrect.
at com.ibm.db2.jcc.b.id.d(id.java:1385)
at com.ibm.db2.jcc.c.fb.l(fb.java:366)
at com.ibm.db2.jcc.c.fb.a(fb.java:64)
at com.ibm.db2.jcc.c.s.a(s.java:48)
at com.ibm.db2.jcc.c.xb.c(xb.java:266)
at com.ibm.db2.jcc.b.jd.ab(jd.java:1684)
at com.ibm.db2.jcc.b.jd.a(jd.java:2253)
at com.ibm.db2.jcc.b.jd.W(jd.java:537)
at com.ibm.db2.jcc.b.jd.executeUpdate(jd.java:520)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2367)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at com.avaya.crystal.ejb.common.BaseSessionBean.add(BaseSessionBean.java:209)
at com.avaya.crystal.ejb.provisioning.company.CompanySessionBean.add(CompanySessionBean.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:854)
at sun.reflect.GeneratedMethodAccessor81.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:242)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:775)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)