-->
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: ClassCastException AbstractPersistentCollection
PostPosted: Sun Feb 18, 2007 1:22 pm 
Newbie

Joined: Sun Feb 18, 2007 1:05 pm
Posts: 16
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]


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.