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
|