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
DetalheAnd 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