-->
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.  [ 2 posts ] 
Author Message
 Post subject: ClassCastException when flushin Parent
PostPosted: Fri Feb 20, 2004 5:11 pm 
Newbie

Joined: Fri Feb 20, 2004 4:56 pm
Posts: 14
Hi all,

Basically as soon as I tried to flush an object (Parent with or without childs) in a one-to-many association Ive Got the following:


21:41:55,392 DEBUG SessionImpl:2321 - Flushing entities and processing referenced collections
java.lang.ClassCastException: java.util.ArrayList
at net.sf.hibernate.type.SetType.wrap(SetType.java:27)
at net.sf.hibernate.impl.WrapVisitor.processArrayOrNewCollection(WrapVisitor.java:73)
at net.sf.hibernate.impl.WrapVisitor.processCollection(WrapVisitor.java:48)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.WrapVisitor.processValues(WrapVisitor.java:86)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2374)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2207)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2186)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at mapping2.Main.main(Main.java:61)
21:41:55,422 DEBUG SessionImpl:546 - closing session

Parent use a collection such as :
private Collection offices = new ArrayList();
With following getter and setter:

/**
* Getter offices
*/

public Collection getOffices() {
return this.offices;
}
/**
* Setter
* @param offices
*/

public void setOffices(Collection office) {
this.offices = office;
}

If some one as an idea, this will help me a lot.
Thx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 5:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
How do you have the offices property mapped in your mapping file for the parent class? I'm going to bet its a <set> mapping? A java.util.ArrayList cannot be cast to the java.util.Set interface.

Either change the mapping to use a list-based mapping element, or change your class to initialize the offices field using HashSet, etc...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.