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"?><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”/>
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©;
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:298)
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:338)
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?