-->
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.  [ 2 posts ] 
Author Message
 Post subject: net.sf.hibernate.type.SerializationException: with MAP
PostPosted: Tue May 04, 2004 4:43 pm 
Newbie

Joined: Mon Mar 01, 2004 9:49 pm
Posts: 13
Hi,
I have a simple one-to-many relationship that I want to map, but getting SerializationException;

My code Looks like this:

Session sess = getHibernateSession();
List resultList = null;
try {
Criteria crit = sess.createCriteria(ItemGroup.class);
resultList = crit.list();
} catch (HibernateException e) {
throw new DaoException("Error Creating Query: getDataOBjects(Query)" + dataObjectClass, e);
} finally {
closeHibernateSession();
}

My mapping looks like this:
<hibernate-mapping>
<class name="ItemGroup" table="item_master">
<id name="itemMasterId" column="item_master_id">
<generator class="assigned"/>
</id>
<one-to-one name="itemGroupRelation" class="ItemGroupRelation"
cascade="all" property-ref="childItemId" />
<map name="childGroupRelationMap" table="item_group" cascade="all-delete-orphan">
<key column="parent_item_master_id"/>
<index column="child_item_master_id" type="integer"/>
<element column="top_parent_item_master_id" type="ItemGroupRelation"/>
</map>
</class>
<class name="ItemGroupRelation" table="item_group">
<id name="groupRelationId" column="item_group_id">
<generator class="native"/>
</id>
<property name="childItemId" column="child_item_master_id"/>
<property name="parentItemId" column="parent_item_master_id"/>
<property name="topParentItemId" column="top_parent_item_master_id"/>
</class>
</hibernate-mapping>

I am getting no error when there are no Children to load i.e. when there are no elements to load into the map. But, if a particular row in item_master has children in item_group table, then getting the following error:
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.collection.AbstractCollectionPersister.readElement(AbstractCollectionPersister.java:363)
at net.sf.hibernate.collection.Map.readFrom(Map.java:200)
at net.sf.hibernate.loader.Loader.readCollectionElement(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:219)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:340)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3089)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:118)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3571)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:223)
at com.vizional.vizid.dao.hibernate.HibernateDao.getDataObjects(HibernateDao.java:138)
... 1 more
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 net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:189)
... 25 more

What am I missing..

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 8:05 pm 
Newbie

Joined: Mon Mar 01, 2004 9:49 pm
Posts: 13
Figured it out. if I use <one-to-many> mapping in my ItemGroup class mapping, problem is solved. I believe <element> is only for primitive types.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.