-->
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: classcast exception on load
PostPosted: Tue May 23, 2006 5:14 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
i have a situation like
UserAccount has one to many relationship to Introducers , Nominee etc
and also one to one relationship to AccountDetail which is an abstract class .
AccountDetails has two subclasses SavingDetail and CheckingDetail

i am getting a casting exception when i try to load using session.load(). it works fine when using session.get()

someone please provide me an explanation

Hibernate version:
3.1
Mapping documents:
<hibernate-mapping package="test">
<class name="AccountDetails" table="acct_details" abstract="true">
<id name="id" column="ACC_DTEAIL_ID" type="long" unsaved-value="null">
<generator class="sequence">
<param name="sequence">acct_details_counter</param>
</generator>
</id>

<many-to-one name="account" class="UserAccount" unique="true"></many-to-one>

<joined-subclass name="SavingAccountDetails" table="acct_details_sb" extends="AccountDetails">
<key column="ACC_DETAIL_ID"></key>

<many-to-one name="introducer" class="test.AcctIntroducer" unique="false" cascade="save-update"></many-to-one>


<set name="nominees" cascade="save-update">
<key column="ACC_DETAIL_ID"></key>
<one-to-many class="test.AcctNominee"/>
</set>



<set name="operators" cascade="save-update">
<key column="ACC_DETAIL_ID"></key>
<one-to-many class="test.AcctOperator"/>
</set>

</joined-subclass>

<jonied-subclass /> //for checking detail

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Code:
Session session = factory.openSession();

        try {
            Transaction t = session.beginTransaction();
            SavingAccountDetails accountDetails = (SavingAccountDetails) session.load(AccountDetails.class, 16L);
            System.out.println(accountDetails);
            t.commit();
           
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            session.close();
        }


Full stack trace of any exception that occurs:
java.lang.ClassCastException: test.AccountDetails$$EnhancerByCGLIB$$fa33619f
at test.AccountDetailsTest.main(AccountDetailsTest.java:26)

Name and version of the database you are using:
PostgreSQL 7.4

_________________
sHeRiN
thanks for your ratings ...... :)


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.