-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unexplainable ClassCastException
PostPosted: Mon Apr 03, 2006 4:04 pm 
Newbie

Joined: Tue Mar 01, 2005 4:13 pm
Posts: 7
I'm getting a cast exception when doing a Hibernate query to the DB.
I just can't understand it. The getClass().getName() method returns
the correct type. However, I just can't seem to cast to the appropriate type.

Thanks in advance.


Hibernate version: 3.1.3

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

<hibernate-mapping>
<class name="com.test.UserInfo">
<id name="Key" column="primaryKey" type="string" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property name="name"/>
<property name="id"/>
<list name="docRecipients" cascade="save-update,delete">
<key column="parentId" not-null="true"/>
<list-index column="listIndex"/>
<one-to-many class="com.test.DocumentRecipient"/>
</list>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
SessionFactory sessFact = (SessionFactory)ctx.lookup("hibSessionFactory");


sess = sessFact.openSession();

Object obj =
sess.createQuery("from UserInfo where name = :userName")
.setString("userName","kjc").list().get(0);

logger.info("object isA.." + obj.getClass().getName());
//: Note: The above statement correctly prints out
//: com.test.UserInfo
UserInfo uInfo = (UserInfo) obj;





Full stack trace of any exception that occurs:
13:57:20,965 ERROR [UIPortal] java.lang.ClassCastException
13:57:20,966 INFO [STDOUT] java.lang.ClassCastException
13:57:20,968 INFO [STDOUT] at com.test.UIPortal.getUser(Unknown Source)



Name and version of the database you are using:
MySQL 5.0.1


The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 5:05 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Could you please post logs at debug level?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject: ClassCastException explained
PostPosted: Tue Apr 04, 2006 1:22 pm 
Newbie

Joined: Tue Mar 01, 2005 4:13 pm
Posts: 7
I resolved this issue. I had a deployed sar which had overlapping clases with the classes in my deployed war. In other words. a Class loader issue reared its ugly head.

Thanks.


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