-->
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.  [ 9 posts ] 
Author Message
 Post subject: SerializationException after upgrade to 3.1/ann 3.1b7
PostPosted: Wed Dec 14, 2005 12:13 pm 
Newbie

Joined: Sat Oct 08, 2005 9:59 am
Posts: 3
Hi,

I could use some help with this mapping, It used to work just fine before I upgraded. I can't figure out why it can't read the column since if I run it by myself in psql it works just fine ( formula0_3_= 1).

I'd appreciate any help since I'll soon be bald from pulling my hair out.

regards
/Magnus Sjöstrand

The objects in question are:
Code:
@Entity ( access = AccessType.FIELD )
@SequenceGenerator (
      name = "SEQ_STORE",
      sequenceName="label_id_seq"
)
public class Label implements Serializable, BaseBO {
   @Id ( generate = GeneratorType.SEQUENCE, generator="SEQ_STORE" )
   private int               id;
   private String            name;
   @OneToMany ( mappedBy="label" )
   @MapKey ( name="language")
   private Map<Language,LabelValue>   values;
}

@Entity ( access = AccessType.FIELD )
public class LabelValue implements Serializable, BaseBO {
   @Id
   private int               id;
   @ManyToOne
   @JoinColumn ( name="labelid" )
   Label                  label;
   @ManyToOne
   @JoinColumn ( name="languageId" )
   private Language         language;
   private String            value;
}

public class Language implements BaseBO, Labelable, Serializable {
   @Id ( generate = GeneratorType.SEQUENCE, generator="SEQ_STORE" )
   private int         id;
   @ManyToOne
   @JoinColumn ( name="labelId" )
   private Label      label;
   @Column ( unique = true )
   private String      iso;
}


Hibernate version: 3.1, annotations 3.1b7

Full stack trace of any exception that occurs:
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:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:650)
at org.hibernate.collection.PersistentMap.readFrom(PersistentMap.java:222)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:994)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:635)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1919)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1627)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readElementByIndex(AbstractPersistentCollection.java:161)
at org.hibernate.collection.PersistentMap.get(PersistentMap.java:127)
at com.snusk.data.Label.getValue(Label.java:48)
at com.snusk.BaseAction.sortByLabel(BaseAction.java:116)
at com.snusk.PersonalSettingsAction.view(PersonalSettingsAction.java:65)
at com.snusk.PersonalSettingsAction.unspecified(PersonalSettingsAction.java:206)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:256)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.snusk.EncodingFilter.doFilter(EncodingFilter.java:20)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.snusk.HibernateFilter.doFilter(HibernateFilter.java:47)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:744)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:674)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:866)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2232)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2698)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:750)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
at org.hibernate.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:246)
at org.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:203)
... 57 more

Name and version of the database you are using:
Postgresql 8.1

The generated SQL (show_sql=true):
select values0_.labelid as labelid3_, values0_.id as id3_, values0_.languageId as formula0_3_, values0_.id as id9_2_, values0_.labelid as labelid9_2_, values0_.languageId as languageId9_2_, values0_.value as value9_2_, language1_.id as id10_0_, language1_.labelId as labelId10_0_, language1_.iso as iso10_0_, label2_.id as id8_1_, label2_.name as name8_1_ from LabelValue values0_ left outer join Language language1_ on values0_.languageId=language1_.id left outer join Label label2_ on language1_.labelId=label2_.id where values0_.labelid=?

Debug level Hibernate log excerpt:
17:05:06,043 DEBUG StatefulPersistenceContext:820 - initializing non-lazy collections
17:05:06,044 DEBUG DefaultInitializeCollectionEventListener:41 - initializing collection [com.snusk.data.Label.values#35]
17:05:06,045 DEBUG DefaultInitializeCollectionEventListener:47 - checking second-level cache
17:05:06,045 DEBUG DefaultInitializeCollectionEventListener:59 - collection not cached
17:05:06,045 DEBUG Loader:1911 - loading collection: [com.snusk.data.Label.values#35]
17:05:06,046 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:05:06,046 DEBUG SQL:346 - select values0_.labelid as labelid3_, values0_.id as id3_, values0_.languageId as formula0_3_, values0_.id as id9_2_, values0_.labelid as labelid9_2_, values0_.languageId as languageId9_2_, values0_.value as value9_2_, language1_.id as id10_0_, language1_.labelId as labelId10_0_, language1_.iso as iso10_0_, label2_.id as id8_1_, label2_.name as name8_1_ from LabelValue values0_ left outer join Language language1_ on values0_.languageId=language1_.id left outer join Label label2_ on language1_.labelId=label2_.id where values0_.labelid=?
17:05:06,047 DEBUG AbstractBatcher:424 - preparing statement
17:05:06,052 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
17:05:06,053 DEBUG Loader:1040 - result set contains (possibly empty) collection: [com.snusk.data.Label.values#35]
17:05:06,056 DEBUG CollectionLoadContext:84 - uninitialized collection: initializing
17:05:06,057 DEBUG Loader:682 - processing result set
17:05:06,057 DEBUG Loader:687 - result set row: 0
17:05:06,058 DEBUG Loader:1164 - result row: EntityKey[com.snusk.data.Language#1], EntityKey[com.snusk.data.Label#1], EntityKey[com.snusk.data.LabelValue#35]
17:05:06,059 DEBUG Loader:1347 - Initializing object from ResultSet: [com.snusk.data.Language#1]
17:05:06,059 DEBUG AbstractEntityPersister:1860 - Hydrating entity: [com.snusk.data.Language#1]
17:05:06,060 DEBUG Loader:1347 - Initializing object from ResultSet: [com.snusk.data.Label#1]
17:05:06,077 DEBUG AbstractEntityPersister:1860 - Hydrating entity: [com.snusk.data.Label#1]
17:05:06,077 DEBUG Loader:1347 - Initializing object from ResultSet: [com.snusk.data.LabelValue#35]
17:05:06,078 DEBUG AbstractEntityPersister:1860 - Hydrating entity: [com.snusk.data.LabelValue#35]
17:05:06,079 DEBUG Loader:972 - found row of collection: [com.snusk.data.Label.values#35]
17:05:06,079 DEBUG CollectionLoadContext:112 - reading row
17:05:06,079 DEBUG DefaultLoadEventListener:153 - loading entity: [com.snusk.data.LabelValue#35]
17:05:06,080 DEBUG DefaultLoadEventListener:304 - attempting to resolve: [com.snusk.data.LabelValue#35]
17:05:06,081 DEBUG DefaultLoadEventListener:313 - resolved object in session cache: [com.snusk.data.LabelValue#35]
17:05:06,081 DEBUG SerializationHelper:198 - Starting deserialization of object
17:05:06,087 INFO SerializableType:132 - could not read column value from result set: formula0_3_
17:05:06,088 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
17:05:06,089 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:05:06,089 DEBUG AbstractBatcher:470 - closing statement
17:05:06,090 WARN RequestProcessor:516 - Unhandled Exception thrown: class org.hibernate.type.SerializationException[/code]
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 3:22 pm 
Newbie

Joined: Tue Oct 11, 2005 1:59 pm
Posts: 4
Any news on this?

I've just installed JBoss 4.0.4RC1 with the latest EJB3 included, and I get the same error in every situation where a Map is used with an Entity as key.

I have almost identical code to yours above (I also have a Label with a Map<Language,Translation> translations; field here, and Language is an entity as well), but I also have other beans with ManyToOne relationsships that use @Mapkey

The problem is the @Mapkey property if the key itself is an entity.

If you change the Map to a List it works. If you use a ManyToOne relationsship (i.e. Language is a single field proprety of Label in the above case), it works.

It seems the "formula" code is broken. And the same as in the original poster: If I take the used SQL query from the DEBUG log and call it in SQLYog, I get valid results.

This just worked with the EJB3 version included in JBoss 4.0.3SP1.

(MySQL 4.1.11 on Windows XP here)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:39 pm 
Newbie

Joined: Tue Oct 11, 2005 1:59 pm
Posts: 4
ok, I downloaded the latest HEAD from CVS and added some debug output.

Code:
22:29:40,293 INFO  [STDOUT] Hibernate: select label0_.id as id3_, label0_.identifier as identifier3_ from label label0_ order by label0_.identifier
22:29:40,573 INFO  [STDOUT] Loading collection:[de.rheuma_online.rheumatool.common.Label.translations#18]
22:29:40,573 INFO  [STDOUT] Hibernate: select translatio0_.label as label1_, translatio0_.id as id1_, translatio0_.language as formula0_1_, translatio0_.id as id5_0_, transatio0_.label as label5_0_, translatio0_.language as language5_0_, translatio0_.text as text5_0_ from translation translatio0_ where  translatio0_.label=?
22:29:40,583 INFO  [STDOUT] Index Type: org.hibernate.type.SerializableType@1bc3013
22:29:40,583 INFO  [STDOUT] Element Type: org.hibernate.type.ManyToOneType(de.rheuma_online.rheumatool.common.Translation)
22:29:40,593 INFO  [SerializableType] could not read column value from result set: formula0_1_



The "Element/Index Type" stdout are in printed in AbstractCollectionPersister.readIndex();

The error seems to be that Hibernate thinks the column "language" (which is fetched as "formula0_1") holds a _SERIALIZED_ version of the Language class (hence the SerializeableType warning). This is of course wrong, it only holds the primary key.

I'm struck now. I can't figure out where sets the types of the map's index, hence I cannot debug it.

I'm now going to use a workaround in my entity beans (don't use the entity as the map but use the long value), but I'd like to have this bug fixed.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 5:56 pm 
Newbie

Joined: Tue Oct 11, 2005 1:59 pm
Posts: 4
Interestingly enough, persisting to the database works (e.g. when the tables were empty before). But once you saved one "Label" entity to the database, the above error occurs.


Top
 Profile  
 
 Post subject: same problem
PostPosted: Fri Apr 07, 2006 3:39 pm 
Newbie

Joined: Sat Mar 11, 2006 4:15 pm
Posts: 15
I just updated and now I'm getting the same problem too. I traced all the way into the hibernate source to where it reads the values. I have an association:

@ManyToOne(optional=false, fetch=FetchType.LAZY)
@PrimaryKeyJoinColumn
public Response getResponse() {
return response;
}

and for some reason it seems to think that the integer primary key is a serialized object (SerializableType). Interestingly enough, right above this I have:

@ManyToOne(optional=false, fetch=FetchType.LAZY)
@PrimaryKeyJoinColumn
public Question getQuestion() {
return question;
}

But when hibernate reads that one it reads it as an IntegerType which is correct. Whats the deal?


Top
 Profile  
 
 Post subject: Re: same problem
PostPosted: Sun Apr 16, 2006 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hagios17 wrote:
@ManyToOne(optional=false, fetch=FetchType.LAZY)
@PrimaryKeyJoinColumn


does not make any sense

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 21, 2006 1:37 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
3.2.0-CR1(changelog.txt): [ANN-281] - @Mapkey broken if key is Entity

Works great, thanks guys!


Top
 Profile  
 
 Post subject: Re: SerializationException after upgrade to 3.1/ann 3.1b7
PostPosted: Wed Sep 09, 2009 9:28 am 
Newbie

Joined: Wed Sep 09, 2009 9:15 am
Posts: 1
Hey everybody.

I had the very same problem and fixed it.
In my case, I forgot to map a ManyToOne relation.

See an example:
Code:
@Entity
class Employee {

@Id
private Integer id;

@Column(name="company_id")
private Company company;

}

As you could see, I set a column name for the company composition (which is wrong) and I didn't map it as a ManyToOne relation.

So, I just replaced the @Column annotation for:
Code:
@ManyToOne
@JoinColumn(name="company_id")
private Company company;

And everything worked perfectly. Maybe it is the same situation of some of you.

I hope I could help.

Regards,

Marcio Fernandes de Lima
# Sun Certified Java Programmer - SCJP
# Sun Certified Web Component Developer - SCWCD
# MySQL Core Certified

Linked In: http://www.linkedin.com/in/marcioferlan


Top
 Profile  
 
 Post subject: Re: SerializationException after upgrade to 3.1/ann 3.1b7
PostPosted: Mon May 24, 2010 2:53 pm 
Newbie

Joined: Mon May 24, 2010 2:47 pm
Posts: 1
marcioferlan thanks for your reply.

I had the same problem and the reason was that in my hbm.xml file, I forgot to mention many-to-one relationship. Once that was in place everything worked fine.


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