-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Error inserting timestamp value in SQL Server 2000 database
PostPosted: Mon Aug 29, 2005 9:01 am 
Newbie

Joined: Mon Aug 29, 2005 8:07 am
Posts: 3
Error inserting a java.sql.Timestamp property. I'm unsing MS SQL Server 2000 with jTDS. The binding timestamp value (canonic date format) seems to be not correctly translated by the JDBC driver. Anyone with experience in jTDS usage?

Hibernate version:
3.0.2
Mapping documents:
<hibernate-mapping default-cascade="save-update" default-lazy="false">
<class name="de.chors.custom.ags.order.OrderImpl" table="AGS_ORDER" dynamic-insert="false" dynamic-update="false">
<id name="id" type="java.lang.Long" unsaved-value="null">
<column name="ID" sql-type="NUMERIC(19,0)"/>
<generator class="native">
</generator>
</id>
<property name="logicalName" type="java.lang.String">
<column name="LOGICAL_NAME" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
</property>
<property name="clientId" type="java.lang.String">
<column name="CLIENT_ID" not-null="true" unique="false" sql-type="VARCHAR(255)"/>
</property>
<property name="orderNumber" type="java.lang.String">
<column name="ORDER_NUMBER" not-null="true" unique="true" sql-type="VARCHAR(255)"/>
</property>
<property name="orderDate" type="java.sql.Timestamp">
<column name="ORDER_DATE" not-null="true" unique="false" sql-type="TIMESTAMP"/>
</property>

<many-to-one name="customer" class="de.chors.custom.ags.customer.CustomerImpl" outer-join="auto" foreign-key="AGS_ORDER_CUSTOMER">
<column name="CUSTOMER_FK" not-null="true" sql-type="NUMERIC(19,0)"/>
</many-to-one>
<set name="orderPositions" order-by="ORDER_FK" lazy="false" outer-join="auto" inverse="false">
<key foreign-key="AGS_ORDER_POS_ORDE">
<column name="ORDER_FK"/>
</key>
<one-to-many class="de.chors.custom.ags.order.OrderPositionImpl"/>
</set>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
2005-08-29 14:47:27,179 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Inserting entity: de.chors.custom.ags.order.OrderImpl (native id)
2005-08-29 14:47:27,179 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-08-29 14:47:27,179 DEBUG [org.hibernate.SQL] insert into AGS_ORDER (LOGICAL_NAME, CLIENT_ID, ORDER_NUMBER, ORDER_DATE, CUSTOMER_FK) values (?, ?, ?, ?, ?)
2005-08-29 14:47:27,179 INFO [STDOUT] Hibernate: insert into AGS_ORDER (LOGICAL_NAME, CLIENT_ID, ORDER_NUMBER, ORDER_DATE, CUSTOMER_FK) values (?, ?, ?, ?, ?)
2005-08-29 14:47:27,179 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-08-29 14:47:27,179 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Dehydrating entity: [de.chors.custom.ags.order.OrderImpl#<null>]
2005-08-29 14:47:27,179 DEBUG [org.hibernate.type.StringType] binding 'de.chors.custom.ags.order.Order' to parameter: 1
2005-08-29 14:47:27,179 DEBUG [org.hibernate.type.StringType] binding 'chors1125312940515' to parameter: 2
2005-08-29 14:47:27,179 DEBUG [org.hibernate.type.StringType] binding '1125319647079' to parameter: 3
2005-08-29 14:47:27,179 DEBUG [org.hibernate.type.TimestampType] binding '2005-08-29 14:47:27' to parameter: 4
2005-08-29 14:47:27,179 DEBUG [org.hibernate.type.LongType] binding '4' to parameter: 5
2005-08-29 14:47:27,239 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-08-29 14:47:27,239 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-08-29 14:47:27,239 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not insert: [de.chors.custom.ags.order.OrderImpl] [insert into AGS_ORDER (LOGICAL_NAME, CLIENT_ID, ORDER_NUMBER, ORDER_DATE, CUSTOMER_FK) values (?, ?, ?, ?, ?)]
java.sql.SQLException: Die implizite Konvertierung von Datentyp datetime in Datentyp timestamp in der sam3.sam.AGS_ORDER-Tabelle, ORDER_DATE-Spalte ist nicht zulässig. Verwenden Sie die CONVERT-Funktion, um diese Abfrage auszuführen.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2754)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2195)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:620)
at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:483)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:445)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:402)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:316)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1749)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2168)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:239)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:159)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:454)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:153)
at org.hibernate.engine.Cascades.cascade(Cascades.java:721)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:860)
at org.hibernate.engine.Cascades.cascade(Cascades.java:739)
at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:362)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:264)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:159)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:454)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:153)
at org.hibernate.engine.Cascades.cascade(Cascades.java:721)
at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:331)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:213)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:159)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:104)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:454)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:449)
at de.chors.custom.ags.test.TestCustomersGenerator.createSampleRetoures(TestCustomersGenerator.java:611)
at de.chors.custom.ags.test.TestCustomersGenerator.getDorisDworatscheckStructure(TestCustomersGenerator.java:542)
at de.chors.custom.ags.test.CustomerSampleTaskDefinition$CustomerSampleTaskStateStrategy.taskStarted(CustomerSampleTaskDefinition.java:123)
at de.chors.sam.sales.task.def.MultiTaskStateStrategy.taskStarted(MultiTaskStateStrategy.java:68)
at de.chors.sam.sales.task.TaskProviderBeanImpl.handleRunTask(TaskProviderBeanImpl.java:504)
at de.chors.sam.sales.task.TaskProviderBeanImpl.handleCreateAndRunTask(TaskProviderBeanImpl.java:412)
at de.chors.sam.sales.task.TaskProviderBean.createAndRunTask(TaskProviderBean.java:73)
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:130)
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:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
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:873)
at sun.reflect.GeneratedMethodAccessor129.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:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
at $Proxy451.createAndRunTask(Unknown Source)
at de.chors.sam.client.editor.sales.task.TaskProviderController.createTask(TaskProviderController.java:302)
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 com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
at javax.faces.component.UICommand.broadcast(UICommand.java:305)
at javax.faces.component.UIData.broadcast(UIData.java:657)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.chors.sam.client.ClientSecurityFilter.doFilter(ClientSecurityFilter.java:67)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.chors.sam.client.CompressionFilter.doFilter(CompressionFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at de.chors.sam.client.DoubleSubmitFilter.doFilter(DoubleSubmitFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:534)
2005-08-29 14:47:27,249 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 260, SQLState: 42000
2005-08-29 14:47:27,249 ERROR [org.hibernate.util.JDBCExceptionReporter] Die implizite Konvertierung von Datentyp datetime in Datentyp timestamp in der sam3.sam.AGS_ORDER-Tabelle, ORDER_DATE-Spalte ist nicht zulässig. Verwenden Sie die CONVERT-Funktion, um diese Abfrage auszuführen.

Name and version of the database you are using:
SQL Server 2000 (sp3)

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Also I tried to user the java.util.Date type, I had the same success.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 9:44 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
Try with

<property name="orderDate" type="timestamp">
<column name="ORDER_DATE" not-null="true" unique="false"/>
</property>

And with the java attribute orderDate of type java.util.Date.

I use this and works in SQL (and Oracle too).
Bye
Alessandro


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 10:35 am 
Newbie

Joined: Mon Aug 29, 2005 8:07 am
Posts: 3
I made the changes

...
<property name="orderDate" type="timestamp">
<column name="ORDER_DATE" not-null="true" unique="false" />
</property>
...

The effect is the same, the canonic form of the timestamp is not accepted by the database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 10:42 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
Strange, this mapping works fine in my program ...
Check regional settings of the OS and those of your program ... have you tried with JBBC directly, without Hibernate?
Alessandro


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 11:36 am 
Newbie

Joined: Mon Aug 29, 2005 8:07 am
Posts: 3
It works - I'm also using AndroMDA to generate the hibernate configuration files and schema scripts ... and I did not regenerate the database schema.

With the correct database column type "datetime" works well.

Thanks
Csaba


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 9:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The TIMESTAMP datatype on SQLServer and Sbase actually has absolutely nothing to do with either dates or times; yes its very poorly named ;)

A TIMESTAMP is actually binary data. Furthermore it's value is explicitly controlled by the database...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.