Enumeration enumeration = objectsToDelete.keys();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
if (objectsToStore.containsKey(key)) {
throw new YPersistenceException("Object with key [" + key + "] present in both Delete and Insert cache");
}
if (objectsToUpdate.containsKey(key)) {
throw new YPersistenceException("Object with key [" + key + "] present in both Delete and Update cache");
}
}
}
// Check for insert and updates
{
Enumeration enumeration = objectsToUpdate.keys();
while (enumeration.hasMoreElements()) {
String key = (String) enumeration.nextElement();
if (objectsToStore.containsKey(key)) {
objectsToStore.put(key, objectsToUpdate.get(key));
objectsToUpdate.remove(key);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("POST DUPLICATE CHECK");
dump();
}
}
try
{
if (LAZY_UPDATES)
{
// Action object deletions
{
Enumeration enumeration = objectsToDelete.elements();
while (enumeration.hasMoreElements()) {
removeData(enumeration.nextElement());
}
}
// Action object insertions - Note that we MUST insert the identifers first to cater for database RI rules
{
{
Enumeration enumeration = objectsToStore.elements();
while (enumeration.hasMoreElements()) {
Object obj = enumeration.nextElement();
if (obj instanceof P_YIdentifier) {
storeData(obj);
}
}
}
{
Enumeration enumeration = objectsToStore.elements();
while (enumeration.hasMoreElements()) {
Object obj = enumeration.nextElement();
if (obj instanceof P_YIdentifier) {
// Null action
} else {
storeData(obj);
}
}
}
}
// Action object updates
{
Enumeration enumeration = objectsToUpdate.elements();
while (enumeration.hasMoreElements()) {
updateData(enumeration.nextElement());
}
}
}
// Commit
getTransaction().commit();
} catch (Exception e1) {
logger.fatal("Failure to commit transactional session - Rolling Back Transaction", e1);
try {
getTransaction().rollback();
} catch (Exception e2) {
throw new YPersistenceException("Failure to rollback transactional session", e2);
}
throw new YPersistenceException("Failure to commit transactional session", e1);
} finally {
transaction = null;
if (getSession() != null) {
try {
getSession().close();