When I use merge() and delete() of same object under transaction
Code:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
Transaction tnx = session.beginTransaction();
Person p = new Person(10,"aaaa");
session.merge(p.getClass().getName(),p);
session.delete(p.getClass().getName(),p);
tnx.commit();
I get following exception:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.alex.hibernate.Person#10]
Why ???
Thanks,
Alex