Hi all,
for a column "value" of hibernate type "serializable"
<property name="value" column="value" type="serializable"/>
I implemented an accessor like this:
public Serializable getSerializableValue()
{
///return new String("DUMMY Generic Serialized Value.");
if ( value == null )
return null;
Serializable s = (Serializable)value;
assert s != null;
return s;
}
If I decomment the DUMMY line, everything is working.
The code I actually need raises the SerializationException as listed below.
Does anybody know, if the serializable type works with MySQL?
Thanks for the moment,
Tom
Hibernate version: 2.1
Mapping documents:
<class name="com.bmw.fkat.persistence.mapping.GenericValueDBO" table="GenericValue">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="native"/>
</id>
<version name="modificationCounter" column="modificationCounter" type="long"/>
<property name="valueAsString" column="valueAsString" type="string"/>
<property name="initializedByDefault" column="initializedByDefault" type="boolean"/>
<property name="value" column="value" type="serializable"/>
<property name="importDate" column="importDate" type="timestamp"/>
<property name="changeDate" column="changeDate" type="timestamp"/>
</class>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Hibernate: select genericval0_.id as id0_, genericval0_.modificationCounter as modifica2_0_, genericval0_.valueAsString as valueAsS3_0_, genericval0_.initializedByDefault as initiali4_0_, genericval0_.value as value0_, genericval0_.importDate as importDate0_, genericval0_.changeDate as changeDate0_ from GenericValue genericval0_ where genericval0_.id=?
com.bmw.fkat.persistence.InfrastructureException: net.sf.hibernate.type.SerializationException: could not deserialize
at com.bmw.fkat.persistence.hibernate.HibernateBaseDAO.findById(HibernateBaseDAO.java:76)
at com.bmw.fkat.persistence.dao.DAO.findDBObjectById(DAO.java:186)
at com.bmw.fkat.persistence.bao.AbstractBAO.findBOById(AbstractBAO.java:118)
at com.bmw.fkat.persistence.bao.CatalogBAO.findCatalogById(CatalogBAO.java:38)
at com.bmw.fkat.tools.CatalogConsoleReader.main(CatalogConsoleReader.java:49)
Caused by: net.sf.hibernate.type.SerializationException: could not deserialize
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:197)
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:220)
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:73)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:38)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:686)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:627)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:586)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:501)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2117)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1991)
at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1953)
at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:69)
at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:204)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2205)
at net.sf.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:315)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:990)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:965)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:83)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3268)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3123)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2117)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1991)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl.java:1927)
at com.bmw.fkat.persistence.hibernate.HibernateBaseDAO.findById(HibernateBaseDAO.java:72)
... 4 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2165)
at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:2900)
at java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2701)
at java.io.ObjectInputStream.readString(ObjectInputStream.java:1536)
at java.io.ObjectInputStream.readTypeString(ObjectInputStream.java:1344)
at java.io.ObjectStreamClass.readNonProxy(ObjectStreamClass.java:540)
at java.io.ObjectInputStream.readClassDescriptor(ObjectInputStream.java:762)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1503)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:190)
... 48 more
Name and version of the database you are using:
MySQL 4.1
The generated SQL (show_sql=true):
Hibernate: select genericval0_.id as id0_, genericval0_.modificationCounter as modifica2_0_, genericval0_.valueAsString as valueAsS3_0_, genericval0_.initializedByDefault as initiali4_0_, genericval0_.value as value0_, genericval0_.importDate as importDate0_, genericval0_.changeDate as changeDate0_ from GenericValue genericval0_ where genericval0_.id=?
Debug level Hibernate log excerpt:
|