I have a field defined as a DATE on a database file (DB2 by the way)
The field is defined in my class as a java.util.Date, and initiliased to a new Date()
When hibernate tries to persist away my date it fails on DB2 with a "Datetime field overflow." DB2 error.
This is because (looking at the hibernate trace) hibernate is trying to put a Timestamptype (which contains seconds) into a DB2 DATE field (which doesn't)
org.hibernate.type.TimestampType - binding '2005-08-22 15:29:53' to parameter: 6
YOu don't get this error in DB2 7.2, nor do you get it in the iSeries version of DB2, but I can understand why the error occurs, because hibernate is plainly trying to add more data into the field than it should be (its just that the other versions of DB2 can cope with this).
Is this a bug in hibernate, and if it is not (or even if it is) what is the work around ?
Hibernate version:
3.0.1
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="net.targetgroup.broker.marketing.Campaign" table="campaign" lazy="false">
<id name="identifier" type="int" column="IDENTIFIER" unsaved-value="-1">
<generator class="native" />
</id>
<version name="recordVersion" type="integer" column="RECORD_VERSION" unsaved-value="null" />
<property name="description" column="DESCRIPTION"/>
<property name="code"/>
<property name="validDate"/>
<property name="expiryDate"/>
<property name="creationTimestamp" column="CREATIONDATE"/>
<property name="creationUserName" column="CREATIONUSER"/>
<property name="active" column="ACTIVE" type="net.targetgroup.util.datatypes.CustomBooleanType"/>
<property name="typicalAPR"/>
<set name="schemes" lazy="false"
inverse="true"
cascade="all-delete-orphan">
<key>
<column name="CAMPAIGN_IDENTIFIER" />
</key>
<one-to-many class="net.targetgroup.broker.marketing.Scheme"/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Version: 0
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.AbstractBatcher - opening JDBC connection
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.JDBCContext - successfully registered Synchronization
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.SQL - insert into campaign (RECORD_VERSION, DESCRIPTION, code, validDate, expiryDate, CREATIONDATE, CREATIONUSER, ACTIVE, typicalAPR, IDENTIFIER) values (?, ?, ?, ?, ?, ?, ?, ?, ?, default)
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.persister.entity.BasicEntityPersister - Dehydrating entity: [net.targetgroup.broker.marketing.Campaign#<null>]
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.IntegerType - binding '0' to parameter: 1
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.StringType - binding 'Adminisitrator' to parameter: 2
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.StringType - binding 'BODE' to parameter: 3
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.TimestampType - binding '2005-11-11 15:29:53' to parameter: 4
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.TimestampType - binding '2006-06-12 15:29:53' to parameter: 5
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.TimestampType - binding '2005-08-22 15:29:53' to parameter: 6
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.StringType - binding null to parameter: 7
2005-08-22 15:29:53,769 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.type.DoubleType - binding '0.0' to parameter: 9
2005-08-22 15:29:54,019 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-08-22 15:29:54,019 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.jdbc.AbstractBatcher - closing statement
2005-08-22 15:29:54,019 [Servlet.Engine.Transports : 1] DEBUG org.hibernate.util.JDBCExceptionReporter - could not insert: [net.targetgroup.broker.marketing.Campaign] [insert into campaign (RECORD_VERSION, DESCRIPTION, code, validDate, expiryDate, CREATIONDATE, CREATIONUSER, ACTIVE, typicalAPR, IDENTIFIER) values (?, ?, ?, ?, ?, ?, ?, ?, ?, default)]
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0114E Datetime field overflow. SQLSTATE=22008
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:469)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1776)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2187)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
Name and version of the database you are using:
IBM DB2 8.1 (PC)
_________________ On the information super B road
|