HIBERNATE  XML
Índice dos Fóruns » Java Avançado
Autor Mensagem
marthian_2
JavaBaby
[Avatar]

Membro desde: 24/09/2007 12:44:38
Mensagens: 92
Offline

Pessoal olhem essa hbm.xml . ta dando um erro quando quero excluir um contato. O program pula a linha q exclue o endereco aí quando vai excluir o contato, é obvio q vai dar erro, pq o endereco esta associado ao contato. tem q colocar essa associaçao no xml? no banco ja tem... Quando eu clico pra exluir um contato q nao tem endereco ele exclui blz



<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE hibernate-mapping

PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


<hibernate-mapping package="com.googlepages.tacianosilva.agenda.to">


<class name="EnderecoTO" table="Endereco">


<!-- Identificador da classe -->


<id name="id" type="integer" column="ID">

<generator class="identity"/>

</id>




<!-- Propriedades da classe -->


<property

name="logradouro"

column="LOGRADOURO"

type="string"

not-null="true"

length="50" />


<property

name="bairro"

column="BAIRRO"

type="string"

length="50" />


<property

name="cep"

column="CEP"

type="string"

length="9" />


<property

name="complemento"

column="COMPLEMENTO"

type="string"

length="30" />


<property

name="numero"

column="NUMERO"

type="integer"/>


<property

name="id_contato"

column="ID_CONTATO"

type="integer"/>


</class>


</hibernate-mapping>


Olha o techo do pragram q exclui
AgendaBO agenda = new AgendaBO();
c = (agenda.buscarContato(jtNome1.getText()));
em=agenda.buscarEndereco(c.getId());
agenda.removerEndereco(em);
agenda.removerContato(c);



Aparece esse erro:

org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:249)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:144)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:29
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:33
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.googlepages.tacianosilva.agenda.dao.ContatoDAO.remover(ContatoDAO.java:56)
at com.googlepages.tacianosilva.agenda.bo.AgendaBO.removerContato(AgendaBO.java:29)
at com.googlepages.tacianosilva.agenda.Agenda$3.mouseClicked(Agenda.java:386)

aí aparece isso aqui:
Hibernate: /* from ContatoTO where nome='Maria' */ select contatoto0_.ID as ID0_, contatoto0_.NOME as NOME0_, contatoto0_.NASCIMENTO as NASCIMENTO0_ from Contato contatoto0_ where contatoto0_.NOME='Maria'

Hibernate: /* from EnderecoTO where id_contato=5 */ select enderecoto0_.ID as ID1_, enderecoto0_.LOGRADOURO as LOGRADOURO1_, enderecoto0_.BAIRRO as BAIRRO1_, enderecoto0_.CEP as CEP1_, enderecoto0_.COMPLEMENTO as COMPLEME5_1_, enderecoto0_.NUMERO as NUMERO1_, enderecoto0_.ID_CONTATO as ID7_1_ from Endereco enderecoto0_ where enderecoto0_.ID_CONTATO=5

Hibernate: /* delete com.googlepages.tacianosilva.agenda.to.ContatoTO */ delete from Contato where ID=?

Ou seja ta pulando a linha q exclui o endereco.

Pessoal desculpem aí pelo tamanho do post!!!
Alguem pode me ajudar?
[MSN]
 
Índice dos Fóruns » Java Avançado
Ir para:   
Powered by JForum 2.1.8 © JForum Team