Hi,
I'm doing some sort of experiment with Hibernate, and I've found a problem I can't solve.
The class I'm trying to persist has a java.lang.Serializable attribute, and I've mapped it to a property of type serializable.
The test application stores some BigInteger and String values succesfully. The problem arises when storing a little bean class with 4 attributes using Apache Derby 10.2.2.0:
Code:
13:21:45,783 WARN JDBCExceptionReporter:77 - SQL Error: -1, SQLState: 22001
13:21:45,783 ERROR JDBCExceptionReporter:78 - A truncation error was encountered trying to shrink VARCHAR () FOR BIT DATA 'XX-RESOLVE-XX' to length 255.
13:21:45,798 ERROR AbstractFlushingEventListener:301 - Could not synchronize database state with session
org.hibernate.exception.DataException: could not insert: [com.gridsystems.checkpointing.CheckPoint]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2217)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2610)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at ...
Caused by: java.sql.SQLException: A truncation error was encountered trying to shrink VARCHAR () FOR BIT DATA 'XX-RESOLVE-XX' to length 255.
at org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2197)
... 12 more
Caused by: org.apache.derby.client.am.SqlException: A truncation error was encountered trying to shrink VARCHAR () FOR BIT DATA 'XX-RESOLVE-XX' to length 255.
at org.apache.derby.client.am.Statement.completeExecute(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(Unknown Source)
at org.apache.derby.client.net.NetStatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.StatementReply.readExecute(Unknown Source)
at org.apache.derby.client.net.NetPreparedStatement.readExecute_(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.readExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.flowExecute(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.executeUpdateX(Unknown Source)
... 15 more
Hibernate version:3.2.1
Mapping documents:Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="xxx.yyy.zzz.CheckPoint" table="CHECKPOINTS">
<composite-id name="id" class="xxx.yyy.zzz.CheckPointID">
<key-property name="taskName"></key-property>
<key-property name="microtaskID"></key-property>
</composite-id>
<property name="data" type="serializable"></property>
</class>
</hibernate-mapping>
Name and version of the database you are using:Apache Derby 10.2.2.0
The generated SQL (show_sql=true):Code:
Hibernate: insert into CHECKPOINTS (data, taskName, microtaskID) values (?, ?, ?)
13:21:45,689 DEBUG SerializableType:80 - binding '2c6d8085f3f280a6e3efedaee7f2e9e4f3f9f3f4e5edf3aee3e8e5e3ebf0efe9eef4e9eee7aed4e5f3f4c2e5e1eec9602e462c3b2098828084da808ce2efefece5e1eec6e9e5ece4c98088e9eef4c6e9e5ece4db8090f3f4f2e9eee7c1f2f2e1f9c6e9e5ece4f48093dbcceae1f6e1afece1eee7afd3f4f2e9eee7bbcc808bf3f4f2e9eee7c6e9e5ece4f48092cceae1f6e1afece1eee7afd3f4f2e9eee7bbf8f081808080e3f5f28093dbcceae1f6e1aeece1eee7aed3f4f2e9eee7bb2d52d667699dfbc7828080f8f080808082f4809cedf9a0e6e9f2f3f4a0f3f4f2e9eee7a0e9eea0f4e8e5a0e1f2f2e1f9f4809dedf9a0f3e5e3efeee4a0f3f4f2e9eee7a0e9eea0f4e8e5a0e1f2f2e1f9f48089edf9a0d3f4f2e9eee7' to parameter: 1
13:21:45,704 DEBUG StringType:80 - binding 'a' to parameter: 2
13:21:45,704 DEBUG StringType:80 - binding 'b' to parameter: 3
The same code works perfectly when using HSQLDB 1.8.0.
Am I doing something wrong?
Any help will be appreciated.