-->
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.  [ 6 posts ] 
Author Message
 Post subject: deserialization error
PostPosted: Thu Nov 10, 2005 9:56 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
I'm getting this error when I try to do a hibernate select on several tables. The only difference I can see between the tables that work and those that generate this error is that the error ones have some columns that map back to variables that are arrays. Could this be the problem? I couldn't find any information on retrieving array variable data. Help!!

org.hibernate.type.SerializationException: could not deserialize
Caused by: java.io.StreamCorruptedException: invalid stream header


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 9:58 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Post the mapping documents for one that works and one that doesn't.

As a quick guess, you should be looking for <array> in the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 10:22 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
jamie_dainton wrote:
Post the mapping documents for one that works and one that doesn't.

As a quick guess, you should be looking for <array> in the documentation.


This one works:
---------------

<class name="TableOne" table="table_one">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<property name="fd" column="fd"/>
<property name="mge" column="mge"/>
<property name="cr" column="cr"/>
<property name="kae" column="kae"/>
<property name="tsae" column="tsae"/>
<property name="cn" column="cn"/>
</class>

maps to:

private String id;
private boolean fd;
private double mge;
private double cr;
private double kae;
private double tsae;
private String cn;

This one doesn't:
-----------------

<class name="TableTwo" table="table_two">
<id name="id" column="id">
<generator class="assigned"/>
</id>
<property name="fd" column="fd"/>
<property name="mge" column="mge"/>
<property name="cr" column="cr"/>
<property name="kae" column="kae"/>
<property name="tsae" column="tsae"/>
<property name="cn" column="cn"/>
<property name="wavelengthProfile" column="wavelength_profile"/>
</class>

maps to:

private String id;
private boolean fd;
private double mge;
private double cr;
private double kae;
private double tsae;
private String cn;
private double[][] wavelengthProfile;

*** The only difference between the 2 is the last column of the second one.

I'm not sure what you mean by looking at the <array> -- in the documentation?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 10:29 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Code:
<array name="addresses"
        table="PersonAddress"
        cascade="persist">
    <key column="personId"/>
    <list-index column="sortOrder"/>
    <many-to-many column="addressId" class="Address"/>
</array>


That is what I was referring to. How is hibernate meant to know how to map a column to an array if it's not specified in the mapping? The trick is to think how you would represent that data in the database, if you had a double[][], how would you store that data using JDBC? Then work out how the mapping would work. Unfortunately I've not done anything with <array> so I can't help you further.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 10:33 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
Thanks Jamie!!
You have been very helpful! You pointed me in the right direction. Now all I have to do is figure out how to use the <array> tag correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 11:48 am 
Beginner
Beginner

Joined: Thu Oct 20, 2005 1:03 pm
Posts: 38
I just read the documentation for mapping persistent collection-valued fields it says that they have to be declared as an interface type. Does that mean that I can't map a database column stored as a [] to a double[] in the class? Does it have to be declared as Array type in the class in order to use <array>


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