-->
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: java.lang.ClassCastException
PostPosted: Fri Jun 11, 2004 9:36 am 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
i've an app that adds and removes items from a JList.
When the app opens up, the are allready several items in that JList:
a
b
c
If i add item d and then persist it and after that i try to delete it, i get that error msg, but if i try to delete any other item from the JList, it works perfectly ok.
I'm using hibernate2.1.3, MySql 4.0.12 nt and sdk1.4.2_04.
the code i use to add:
Code:
//...
        Detalhe detalhe = new Detalhe();
        String nova = (String) visual.lstTipificada.getSelectedValue();
        detalhe.setEstrategia(nova);
        rel.getTurma().adicionarDetalhe(detalhe);
//...

The code i use to delete:
Code:
//...
        Detalhe detalhe = (Detalhe) visual.lstDetalhe.getSelectedValue();// ERROR here
        rel.getTurma().removerDetalhe(detalhe);
//...

the code i use to update:
Code:
//...
        sess.saveOrUpdate(rel);
        sess.flush();
        sess.refresh(rel);
        t.commit();
        HibernateUtil.closeSession();

I have an object Relatorio that is composed of two objs: Turma and Disciplinas.
Turma has a child called Detalhe
And its a detalhe i'm trying to delete.
My mappings:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name = "relatorio.Relatorio" table = "relatorios">
<id name = "id" column = "id" unsaved-value = "null">
<generator class = "increment" />
</id>
    <many-to-one name = "turma" column = "rel_turmas" class = "relatorio.Turma"
        cascade="all">
    </many-to-one>
    <many-to-one name = "mat" column = "rel_mat" class = "relatorio.Disciplina"
        cascade="all">
    </many-to-one>
    <many-to-one name = "pt" column = "rel_pt" class = "relatorio.Disciplina"
        cascade="all">
    </many-to-one>
        <many-to-one name = "cn" column = "rel_cn" class = "relatorio.Disciplina"
        cascade="all">
    </many-to-one>
  </class>
</hibernate-mapping>


[code]<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name = "relatorio.Turma" table = "turmas">
<id name = "id" column = "id" unsaved-value = "null">
<generator class = "increment" />
</id>
<property name = "turma" column = "turma" />
<property name = "ano" column = "ano" />
<property name = "masculinos" column = "masculinos" />
<property name = "femininos" column = "femininos" />
<!--
retirei lazy = true para poder fechar a sess


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.