-->
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.  [ 4 posts ] 
Author Message
 Post subject: hibernate3 cglib ClassCastException
PostPosted: Mon May 09, 2005 2:31 pm 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="com.myadbox.bo">
<class name="User" table="df_user" dynamic-update="true">
<cache usage="read-write"/>
<id
column="user_id"
name="Id"
type="java.lang.Long"
>
<generator class="identity" />
</id>

<property
column="username"
length="25"
name="Username"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="com.myadbox.bo">
<joined-subclass name="MessageBoxOwner"
table="message_box_owner"
extends="com.myadbox.bo.User">
<key column="message_box_owner_id" />

<many-to-one
name="MessageBox"
class="MessageBox"
column="message_box_id"
not-null="true"
/>
</joined-subclass>
</hibernate-mapping>


I recive a ClassCastException when trying to perform the following operation on an object which I *know* to be a MessageBoxOwner. In fact, if I examine the class with Eclipse at runtime, I can see that it has a MessageBox associated with it. Could somebody tell me how I could perform the following operation?

MessageBox mb = ((MessageBoxOwner) user).getMessageBox();

Without receiving the following error?

java.lang.ClassCastException: com.myadbox.bo.User$$EnhancerByCGLIB$$46f9c9d

Thank you very much for your time.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 11:42 am 
Newbie

Joined: Mon Oct 04, 2004 4:25 pm
Posts: 7
I am having this same problem, too. This type of thing was working in Hibernate 2, so what gives?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 12:25 pm 
Newbie

Joined: Mon Oct 04, 2004 4:25 pm
Posts: 7
Hmm, looks like there's plenty of information on this already in the forum. Search on ClassCastException and EnhancerByCGLIB and you'll get the scoop (which isn't going to make you happy, most likely).

Good luck.

--
Phil


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 5:28 pm 
Beginner
Beginner

Joined: Mon May 24, 2004 7:39 pm
Posts: 37
Location: Charlotte
Thank you very much, Phil. That was the information I needed.

Joe


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