Hi,
I am receiving a SerializationException (during deserialization) when trying to load an object in Hibernate 3.0.1. I am using Oracle 10g. The class I have is very simple:
Code:
public class ResourceAttribute {
private String name;
private String value;
private Serializable data;
...
public Serializable getData() { return data; }
public void setData(Serializable data) { this.data = data; }
}
and the mapping for it:
Code:
<class
name="ResourceAttribute"
table="resource_attribute">
<id name="id" type="integer">
<generator class="sequence">
<param name="sequence">resource_attribute_seq</param>
</generator>
</id>
<property name="name"/>
<property name="value"/>
<property name="data" type="serializable"/>
</class>
right now I am just testing, so I successfully have an Integer object committed to the database:
Code:
ResourceAttribute ra = new ResourceAttribute();
ra.setData(new Integer(613));
Using SQL*Plus, I verify that the insert was successful (I can't view the data column however, its a BLOB)
So, apparently serialization is successful, its just when Hibernate tries to deserialize that I get the error.
The stack trace is listed below.
I have set use_streams_for_binary for true, and batch_size to 0, according to suggestions from other posts on this forum.
Any help is greatly appreciated!
David
Code:
Hit uncaught exception org.hibernate.type.SerializationException
org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:211)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:234)
at org.hibernate.type.SerializableType.fromBytes(SerializableType.java:78)
at org.hibernate.type.SerializableType.get(SerializableType.java:39)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:80)
at org.hibernate.persister.entity.BasicEntityPersister.hydrate(BasicEntityPersister.java:1699)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:925)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:876)
at org.hibernate.loader.Loader.getRow(Loader.java:789)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:295)
at org.hibernate.loader.Loader.doQuery(Loader.java:389)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1367)
at org.hibernate.loader.collection.OneToManyLoader.initialize(OneToManyLoader.java:107)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:171)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:48)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:134)
at edu.baylor.csi4335.HibernateUtil.main(HibernateUtil.java:53)
Caused by: java.io.StreamCorruptedException: invalid stream header
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:246)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:203)
... 22 more