Hi!
I try to do the following:
1. Delete table 'category':
currentSession.createQuery("delete from Catalog").executeUpdate()
2. Re-insert Category data:
currentSession.save(new Catalog(pk));
I get this exception:
Code:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
Obviously, Hibernate doesn't realize that I deleted all catalogs in step 1, and still has category instances in its cache.
I try to flush() after each step, evict() and refresh() the new catalog, whithout success. When I try to refresh() the new catalog to make Hibernate aware that it does not exist in the DB anmore, I get
Code:
org.hibernate.UnresolvableObjectException: No row with the given identifier exists
All of this is executed in a single session in a single transaction, since it is a nightly DB import. I use hibernate-3.1.3.
Any solutions?