-->
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.  [ 1 post ] 
Author Message
 Post subject: Could not deserialize - Formula
PostPosted: Wed Mar 14, 2012 4:11 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 10:51 pm
Posts: 29
Location: sydney australia
Hibernate version: 3.6.0.Final

I just solved a very poorly handled and documented problem and figured someone else may benefit from the post.

I was experimenting with a formula to do a count:
Code:
   @Formula("(SELECT count(*) FROM my_joined_table pl WHERE pl.parent_id=parent_id)")
   private Number joinedCount;


And kept getting the exception:

Code:
org.hibernate.type.SerializationException: could not deserialize
   at org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
   at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:306)
   at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:130)
   at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:116)
   at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:39)
   at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:62)
   at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
   at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
   at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:249)
   at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:229)
   at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:330)
   at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2265)
   at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1527)
   at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1455)
   at org.hibernate.loader.Loader.getRow(Loader.java:1355)
   at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:611)
   at org.hibernate.loader.Loader.doQuery(Loader.java:829)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
   at org.hibernate.loader.Loader.doList(Loader.java:2533)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
   at org.hibernate.loader.Loader.list(Loader.java:2271)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1716)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)
   ...
Caused by: java.io.EOFException
   at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2298)
   at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2767)
   at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:799)
   at java.io.ObjectInputStream.<init>(ObjectInputStream.java:298)
   at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:328)
   at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:318)
   at org.hibernate.util.SerializationHelper.doDeserialize(SerializationHelper.java:237)
   ... 51 more


Changing the type from Number to Long seemed to solve the issue:
Code:
   @Formula("(SELECT count(*) FROM my_joined_table pl WHERE pl.parent_id=parent_id)")
   private Long joinedCount;


p.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.