-->
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: ClassCastException: SetType.wrap
PostPosted: Fri Jun 18, 2004 5:19 pm 
Newbie

Joined: Thu Jun 17, 2004 8:27 pm
Posts: 3
Hi,

I have two classes: BomData and BomElementData

BomData contains:

int bomId,
int qty,
Set bomelements

BomElementData contains:

int bomElementId,
int scarpFact,
Bom Bom

Mappings are as follows:

<class name="com.saltare.server.dao.BomData" table="T_BOM" >
<id name="bomId" type="integer" column="BOM_ID">
<generator class="sequence">
<param name="sequence">T_BOM_SEQ</param>
</generator>
</id>
<property name="qty" column="QTY"/>

<set name="bomElements" table="T_BOM_ELEMENT" cascade="none">
<key column="BOM_ID"/>
<one-to-many class="com.saltare.server.dao.BomElementData"/>
</set>

<set name="roles" table="T_ROLE_BOM" lazy="true" inverse="true" >
<key column="BOM_ID"/>
<many-to-many column="ROLE_ID" class="com.saltare.server.dao.RoleData"/>
</set>
</class>


<class name="com.saltare.server.dao.BomElementData" table="T_BOM_ELEMENT" >
<id name="bomElementId" type="integer" column="BOM_ELEMENT_ID">
<generator class="sequence">
<param name="sequence">T_BOM_ELEMENT_SEQ</param>
</generator>
</id>

<property name="qty" column="QTY"/>
<property name="scrapFactor" column="SCRAP_FACTOR"/>

<many-to-one
name="item"
column="ITEM_ID"
class="com.saltare.server.dao.ItemData"
/>
<many-to-one
name="bom"
column="BOM_ID"
class="com.saltare.server.dao.BomData"
/>
</class>


I am getting ClassCastException when i try to create/edit BomData object.
While editing BomData, existing BomElements are deleted using session.remove() and it 's throwing exception at that point. Here is the code that throws exception within editBom() method.

for (Iterator elemIt = bomDAO.getBomElements().iterator(); elemIt.hasNext();) {
BomElementDAO bedao = (BomElementDAOelemIt.next );
getDAOFactory().removeDAO(bedao);
}


Here is the exception stacktrace:


Caused by: java.lang.ClassCastException
at net.sf.hibernate.type.SetType.wrap(SetType.java:27)
at net.sf.hibernate.impl.SessionImpl.wrap(SessionImpl.java:2496)
at net.sf.hibernate.impl.SessionImpl.wrap(SessionImpl.java:2436)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2162)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2020)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2007)
at com.saltare.server.db.hibernate.HibernateDBAccess.closeSession(HibernateDBAccess.java:134)
at com.saltare.ejb.drp.ModelBean.editBom(ModelBean.java:602)

I got struck with this exception since a week, please anyone let me know the solution for this exception.

Thanks in Advance
sanv


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 20, 2004 11:37 am 
Beginner
Beginner

Joined: Thu Aug 28, 2003 3:09 pm
Posts: 39
Location: Brazil
This problem happens when you have some other collection but Set in your associations.

Check if your association is holding a Set or subclass of it.

I hope it helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:58 pm 
Newbie

Joined: Thu Jun 17, 2004 8:27 pm
Posts: 3
Thanks for your reponse.

I have two collections associated with this class. I have declares them as

Set bomElements;
Collection roles;

I mapped both of them as Set in mapping file.

Do i need to declare roles as Set instead of Collection in class ??

Please let me know.

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.