Code:
TransDetalhaQuadra td = new TransDetalhaQuadra();
Quadra quadra = lote.getQuadra();
Iterator lotes = quadra.getLotes().iterator();
Set novosLotes = new HashSet();
while (lotes.hasNext()) {
Lote l = (Lote) lotes.next();
log.infoCemiterioLog("iter");
if (l.getId() != id.longValue()) {
novosLotes.add(l);
}
}
td.setLotes(novosLotes);
td.setQuadra(quadra);
session.delete(lote);
trans.commit();
session.close();
Look at this fragment carefully, first of all I assume that your quadra and lote is one-to-many bidirectinal relation (since lote.getQuadra(); and quadra.getLotes().iterator())
at some point you can be deleting the lote object
Code:
session.delete(lote);
at the same time you might be adding the same object (as indirectly as it is) to a collection thru the statement
Code:
if (l.getId() != id.longValue()) {
novosLotes.add(l);
}
Hence is the message on one hand you are adding lote to a collection that is probably saved thru a cascade. On the other hand you are deleting the same object that you are trying to save.
Look at your logic carefully. I am sure you will find that the message thrown is thrown so correctly :-)
HTH,
Alex.