-->
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.  [ 4 posts ] 
Author Message
 Post subject: Why this Exception?
PostPosted: Sat Dec 27, 2003 11:21 pm 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
I have three bens: Setor, Quadra, Lote . Setor has two collection attributes: quadra and lote. Quadra has one collection attribute: lote. I'm using java.util.Collection to handle such collections, but i'm gettig this Exception:

java.lang.ClassCastException
at net.sf.hibernate.type.SetType.wrap(SetType.java:27)
at net.sf.hibernate.impl.SessionImpl.wrap(SessionImpl.java:2519)
at net.sf.hibernate.impl.SessionImpl.wrap(SessionImpl.java:2459)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:708)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605)

This is the piece of code where this is happening:

quadra.setLotes(lotes);

where quadra is an instance of bean Quadra, setLotes is the mutator method of the lotes collection attribute in Quadra, and lotes (inside the brackets) is a collection of Lote.

This is a piece of the mapping file for the Setor class:

<set name="lotes" inverse="true" cascade="all">
<key column="id_setor"/>
<one-to-many class="beans.Lote"/>
</set>


<set name="quadras" inverse="true" cascade="all">
<key column="id_setor"/>
<one-to-many class="beans.Quadra"/>
</set>

So, why am I getting that excepetion ?

Thanks

_________________
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2003 11:39 pm 
Beginner
Beginner

Joined: Sun Dec 21, 2003 11:19 pm
Posts: 22
Location: Kentucky, USA
Ot


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 27, 2003 11:48 pm 
Beginner
Beginner

Joined: Sun Dec 21, 2003 11:19 pm
Posts: 22
Location: Kentucky, USA
In addition to using Middlegen you might want to check out the round trip tools offered as part of the Hibernate extensions. These allow you to start with a DB, use Middlegen to generate hbm and hbm2java to create a java class file. The class file will "work" with the mapping and database but might not be the exact functionality you need but it is a good starting point. Check out http://hibernate.org/102.html

HTH,
Timothy Vogel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 28, 2003 1:04 am 
Regular
Regular

Joined: Thu Dec 25, 2003 12:33 am
Posts: 58
Location: Campina Grande, Brasil
Your advide just fits what I've done some minutes ago. I've substituted every java.util.Collection for a java.util.Set , and it works fine now. I'm also new to Hibernate, and the deeper I go in my project, the more I notice how full of possibilities this tool is.

Thanks a lot for the help. I'm gonna try MiddleGen ;)

_________________
Ot


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