use of org.jaffa.persistence.exceptions.CommitFailedException in project jaffa-framework by jaffa-projects.
the class UOW method commit.
/**
* Objects that have been added, objects that have been deleted,
* and objects that have been updated, will all be persisted via
* an invocation of this method.
* Note: After a successful commit, this object will free up its connection to the database,
* and will no longer be available.
*
* @throws AddFailedException if any error occurs during the addition of objects to the persistent store.
* @throws UpdateFailedException if any error occurs while updating the objects of the persistent store.
* @throws DeleteFailedException if any error occurs while deleting the objects of the persistent store.
* @throws CommitFailedException if any error occurs during the commit.
*/
public void commit() throws AddFailedException, UpdateFailedException, DeleteFailedException, CommitFailedException {
ensureActiveState();
Collection deletes = m_engine.getDeletes();
if (deletes != null) {
if (m_messagingEngine == null) {
try {
m_messagingEngine = MessagingEngineFactory.newInstance(this);
} catch (FrameworkException e) {
// failed creating the messaging engine, do not fail the overall commit
} catch (ApplicationExceptions applicationExceptions) {
// failed creating the messaging engine, do not fail the overall commit
}
}
if (m_messagingEngine != null) {
m_messagingEngine.prepareDeletesForCommit(deletes);
}
}
// commit the persistence engine
m_engine.commit();
// commit the messaging engine
if (m_messagingEngine != null) {
try {
m_messagingEngine.commit();
} catch (Exception e) {
log.fatal("The database transaction has been committed. Exception raised while sending Message(s) to the JMS system", e);
throw new CommitFailedException(null, e);
}
}
close();
}
Aggregations