Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0
Full stack trace of any exception that occurs: Caused by: org.hibernate.NonUniqueObjectException: a different object
with the same identifier value was already associated with the session:
[B#1]
Name and version of the database you are using: postgresql-8.2
I have two objects: A and B:
===============================
class A {
private B b;
private ArrayList blist;
public void setB(B b) {
this.b = b;
}
public void addB(B b) {
blist.add(b);
}
}
===============================
Well..., I'm loading that objects from data base like this:
===============================
A a = new A();
sessionFactory.openSession();
b1 = servico.getB(1);
a.setB(b1);
session.close();
//Faço um monte de coisa... bla bla bla...
sessionFactory.openSession();
b1 = servico.getB(1);
a.addB(b1);
session.close();
//Faço um monte de coisa... bla bla bla...
sessionFactory.openSession();
servico.gravaA(a);
session.close();
===============================
At line "servico.gravaA(a);" an exception was generated:
===============================
Caused by: org.hibernate.NonUniqueObjectException: a different object
with the same identifier value was already associated with the session:
[B#1]
===============================
So..., what's going on and How can I fix this?
Thank you
Cristiano