-->
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: ClassCast Exception
PostPosted: Wed May 31, 2006 10:26 am 
Newbie

Joined: Wed May 31, 2006 9:49 am
Posts: 3
Location: Bangalore
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:Parent Table
<hibernate-mapping>
<class name="com.coassectt.dak.business.vo.CreateDakVO" table="dakdetails">
<id name="dakid" column="DAK_ID" type="integer" >
<generator class="native" />
</id>
<property name="subject" type="string">
<column name="DAK_SUBJECT" length="100"/>
</property>
<property name="dateDueBy" type="date">
<column name="DAK__DATE_DUEBY" length="20"/>
</property>
<set name="dakEdit" inverse="true" cascade="all" >
<key>
<column name="DAK_ID" not-null="true" />
</key>
<one-to-many class="com.coassectt.dak.business.vo.EditDakVO" />
</set>
</class>


</hibernate-mapping>

Child Table:
<hibernate-mapping>
<class name="com.coassectt.dak.business.vo.EditDakVO" table="EDITDAK">
<id name="dakEditId" column="DAK_EDIT_ID" type="integer" >
<generator class="native" />
</id>
<property name="department" type="string">
<column name="DE_FORWARDED_TO" length="40"/>
</property>
<property name="fwdDate" type="date">
<column name="DE_FORWARDED_DATE" length="20"/>
</property>
<property name="remarks" type="string">
<column name="DE_COAS_REMARKS" length="255"/>
</property>
<property name="dateDueBy" type="date">
<column name="DE_DATE_DUEBY" length="20"/>
</property>
<many-to-one name="createDak" class="com.coassectt.dak.business.vo.CreateDakVO" >
<column name="DAK_ID" not-null="true" />
</many-to-one>

</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
List dayendReptList=null;
Date today=new Date();
today.setDate(today.getDate()+5);
StringBuffer query = new StringBuffer();
query.append("select editvo.department,editvo.remarks,createVO.subject from com.coassectt.dak.business.vo.CreateDakVO createVO, com.coassectt.dak.business.vo.EditDakVO editvo where createVO.dakid = editvo.createDak.dakid").append(" and ").append("editvo.dateDueBy = '").append(DateUtil.convertDate(DateUtil.formatDate(today))).append("'");
dayendReptList = session.createQuery(query.toString()).list();
Iterator itr = dayendReptList.iterator();
while(itr.hasNext()){
// System.out.println("Class name"+itr.next().getClass().getName());
EditDakVO editDakVO=(EditDakVO)itr.next();//Here it is giving ClasscastException because hql is using two VOs.



Name and version of the database you are using:My SQL

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 10:34 am 
Beginner
Beginner

Joined: Fri May 26, 2006 7:15 am
Posts: 20
Location: Vandavasi, TamilNadu
try to typecast it to Object array type...

_________________
gajini
------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 11:01 am 
Beginner
Beginner

Joined: Tue May 30, 2006 6:03 am
Posts: 20
Location: London
i'm guessing some stuff is missing - ie the sql output and the error...


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 11:33 am 
Newbie

Joined: Wed May 31, 2006 9:49 am
Posts: 3
Location: Bangalore
Thanx A lot Every One I have solved it by putting as Object array.


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.