-->
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' exception for 1-to-1 map to subclass
PostPosted: Tue Oct 04, 2005 7:57 am 
Newbie

Joined: Fri May 27, 2005 7:37 am
Posts: 6
Hello,
I have a persistant problem which I can find few previous relevant postings about.

It happens when hibernate accesses a particular relationship in the object tree. I have several subclasses of a class - PageElement (using the subclass tag for a table-per-heirarchy inheritance mapping) each which has a one-to-one relationship with another class, (a different class for each, but only one pair is shown here). This has been done using many-to-one at both ends. This mapping works fine when I use it to build the POJOs and the schema, but not when mapping from the db. Whilst running the debug the variables indicate that the instance of the class held by the subclass, in this case Text, is null. Actually it's value is shown as:

Text$$EnhancerByCGLIB$$1ce77531

but it's member variables are all null. So when it's method is then called, a Hibernate exception is thrown. The logged mesage is:

ERROR framework:76 - could not deserialize.

Stepping through the error it seems to have something to do with the mySQL dialect, and other postings seemed to indicate that there could be a column inaccuracy given by certain db drivers. I am using mysql-connector-java-3.1.6-bin.jar.

Is there a known problem with the O/R mapping from the db using this driver? ANd what can I do to have this kind of mapping (one-to-one to a child class) and get it to deserialize properly?

Thanks for your time,
BT.

[b]Hibernate version:[/b] 3

[b]Mapping documents:[/b]

1:
<hibernate-mapping>
<class name="hibernate.PageElement" table="PAGE_ELEMENT">

<meta attribute="class-description">
Represents an XML element for the page - question, image or text
@author Benn Tilby
</meta>

<id name="id" type="int" column="pageElement_id">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

<discriminator column="type" type="string" />

<property name="position" type="byte" not-null="true"/>

<subclass name="hibernate.TextPageElement" discriminator-value="TEXT" lazy="false">
<many-to-one name="text" class="hibernate.Text" column="text_id" />
</subclass>

<subclass name="hibernate.ImagePageElement" discriminator-value="IMAGE" lazy="false">
<many-to-one name="image" class="hibernate.Image" column="image_id" />
</subclass>
</class>
</hibernate-mapping>

2:
<hibernate-mapping>
<class name="hibernate.Text" table="TEXT">
<meta attribute="class-description">
Represents an XML title or subtitle tag
@author Benn Tilby
</meta>

<id name="id" type="int" column="text_id">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>

<many-to-one name="pageElement" class="hibernate.TextPageElement" column="pageElement_id" />

<property name="text" type="string" not-null="true"/>

<property name="html_id" type="byte" />

<property name="hidden" type="true_false" />

</class>
</hibernate-mapping>


[b]Full stack trace of any exception that occurs:[/b]
12:33:12,031 ERROR framework:76 - could not deserialize

[b]Name and version of the database you are using:[/b]
MySQL 4.1
Driver: mysql-connector-java-3.1.6-bin.jar

[b]The generated SQL (show_sql=true):[/b]
Hibernate: select pages0_.survey_id as survey2_1_, pages0_.page_id as page1_1_, pages0_.page_id as page1_0_, pages0_.survey_id as survey2_1_0_, pages0_.position as position1_0_, pages0_.previous_button as previous4_1_0_, pages0_.validation as validation1_0_, pages0_.jump_script as jump6_1_0_ from PAGE pages0_ where pages0_.survey_id=? order by pages0_.position
Hibernate: select pageelemen0_.page_id as page3_1_, pageelemen0_.pageElement_id as pageElem1_1_, pageelemen0_.pageElement_id as pageElem1_0_, pageelemen0_.page_id as page3_2_0_, pageelemen0_.position as position2_0_, pageelemen0_.question_id as question5_2_0_, pageelemen0_.text_id as text6_2_0_, pageelemen0_.image_id as image7_2_0_, pageelemen0_.type as type0_ from PAGE_ELEMENT pageelemen0_ where pageelemen0_.page_id=? order by pageelemen0_.position
Hibernate: select text0_.text_id as text1_1_, text0_.pageElement_id as pageElem2_4_1_, text0_.questionElement as question3_4_1_, text0_.type as type4_1_, text0_.text as text4_1_, text0_.align as align4_1_, text0_.html_id as html7_4_1_, text0_.hidden as hidden4_1_, textpageel1_.pageElement_id as pageElem1_0_, textpageel1_.page_id as page3_2_0_, textpageel1_.position as position2_0_, textpageel1_.text_id as text6_2_0_ from TEXT text0_ left outer join PAGE_ELEMENT textpageel1_ on text0_.pageElement_id=textpageel1_.pageElement_id where text0_.text_id=?
Hibernate: select text0_.text_id as text1_1_, text0_.pageElement_id as pageElem2_4_1_, text0_.questionElement as question3_4_1_, text0_.type as type4_1_, text0_.text as text4_1_, text0_.align as align4_1_, text0_.html_id as html7_4_1_, text0_.hidden as hidden4_1_, textpageel1_.pageElement_id as pageElem1_0_, textpageel1_.page_id as page3_2_0_, textpageel1_.position as position2_0_, textpageel1_.text_id as text6_2_0_ from TEXT text0_ left outer join PAGE_ELEMENT textpageel1_ on text0_.pageElement_id=textpageel1_.pageElement_id where text0_.text_id=?


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.