We have a Stateless Session bean (using CMT) that first saves (saveOrUpdate) an object graph with Hibernate and then calls an external system in the same transaction. If the external system throws an exception, the db insertion is rolled back, but the new domain objects in the object graph has gotten their identifier fields updated by Hibernate.
Are there any ways of resetting these identifier fields, that is, can I hook into Hibernate's transaction handling so I can do something like (pseudo code):
Code:
for(domainObject : newDomainObjects)
{
getPersister(domainObject).resetIdentifier(...)
}
when the transaction rolls back?
Regards,
Stig Kleppe-Jørgensen