Como o hibernate associa um objeto a uma sessão?

1 resposta
F
another object with the same id was already associated with the session: [geral.cadastros.cidade.vo.Cidade#4]

Esse foi o erro ao tentar excluir um objeto.

1 Resposta

ricardolecheta

FAQ do Hibernate.

Hibernate throws: Another object was associated with this id

For a particular session, there may be at most one object that represents a particular database row. So, if you already loaded an object with a particular identifier, you can’t then try to associate a different object with the same identifier by calling update().

If you absolutely must do this, evict() the original instance first - but it is much better to simply avoid this situation.

O Hibernate faz cache, veja se já nao existe um objeto com o mesmo id no cache da session. Veja os metodos session.contais(obj) e session.evict(obj)

Criado 20 de abril de 2004
Ultima resposta 20 de abr. de 2004
Respostas 1
Participantes 2