Hi All,
I am new to Hibernate (3.2) and facing the following issue.
I have two POJO classes with a parent -child relationship between them.
I have the corresponding mappingfiles also.The save funstionalty works fine but when I try to retrieve the data it gives a
java.lang.ClassCastException: org.hibernate.collection.AbstractPersistentCollection$SetProxy
Can anybody please help?Thanks in advance.
Attaching java/mapping files for reference.
Shaiju
public class StoreRequestHVO implements Serializable {
private int storerequestid;
private Date sr_date;
private String creator;
private String status;
Map sr_materials=new HashMap();
public StoreRequestHVO() {
}
//And the get/set methods
}
---------------------
public class SR_Material implements Serializable{
private int srdetails_id;
private int mat_id;
private String matName
public SR_Material() {
}
//and get/set method
}
---------------------------------
// StoreRequest.hbm.cfg
<?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 auto-import="true">
<class name="com.vo.StoreRequestHVO" table="storerequest" >
<id name="storerequestid" column="SR_ID">
<generator class="increment"/>
</id>
<property name="sr_date" column="SRDATE" type="date"/>
<property name="creator" column="CREATOR"/>
<property name="status" column="STATUS"/>
<map name="sr_materials" cascade="all" fetch="join">
<key column="sr_id"/>
<map-key formula="sr_id" type="integer"/>
<one-to-many class="com.vo.SR_Material"/>
</map>
</class>
</hibernate-mapping>
//
----------------
<?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 auto-import="true">
<class name="com.vo.SR_Material" table="SR_DETAIL" >
<id name="srdetails_id" column="SRDETAIL_ID">
<generator class="increment"/>
</id>
<property name="mat_id" column="MAT_ID"/>
<!-- <property name="STOREREQUESTID" column="SR_ID"/> -->
<property name="qty" column="QUANTITY"/>
</class>
</hibernate-mapping>
Expecting a solution---------
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
[code][/code]