From c5e6bbe8c46e031fd9f8339ab7c158f9ee2608f6 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Wed, 14 Mar 2012 13:48:29 +0100 Subject: [PATCH] Bug #1397: Revert a previous commit to avoid the problem Commit 9e4b329791f42a32b9596bf35fcff06005d6380e is reverted and exception IllegalStateException is cached to launch an OptimisticLockingFailureException. FEA: ItEr76S04BugFixing --- .../common/daos/GenericDAOHibernate.java | 9 +-------- .../business/common/daos/IGenericDAO.java | 18 +----------------- .../web/common/ConfigurationModel.java | 11 ++++++++--- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/daos/GenericDAOHibernate.java b/libreplan-business/src/main/java/org/libreplan/business/common/daos/GenericDAOHibernate.java index d8b8637e6..012d30304 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/daos/GenericDAOHibernate.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/daos/GenericDAOHibernate.java @@ -85,21 +85,14 @@ public class GenericDAOHibernate{ public Class getEntityClass(); - public enum Mode { - FLUSH_BEFORE_VALIDATION, AUTOMATIC_FLUSH; - } - /** - * It saves with automatic flush - * - * @see #save(Object, Mode) - */ - public void save(E entity) throws ValidationException; - - /** - *

* It inserts the object passed as a parameter in the ORM session, planning * it for updating (even though it is not modified before or after the call * to this method) or insertion, depending if it is was detached or @@ -63,15 +51,11 @@ public interface IGenericDAO { * executed (if the entity has version control enabled) with the possible * org.springframework.dao.OptimisticLockingFailureException * being thrown. - *

- *

- * - *

* * @throws ValidationException * if the entity has some invalid values */ - public void save(E entity, Mode mode) throws ValidationException; + public void save(E entity) throws ValidationException; /** * Unlike save, it does not execute validations. diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java index 0b2bdb143..d98576983 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java @@ -35,7 +35,6 @@ import org.libreplan.business.calendars.daos.IBaseCalendarDAO; import org.libreplan.business.calendars.entities.BaseCalendar; import org.libreplan.business.common.daos.IConfigurationDAO; import org.libreplan.business.common.daos.IEntitySequenceDAO; -import org.libreplan.business.common.daos.IGenericDAO.Mode; import org.libreplan.business.common.entities.Configuration; import org.libreplan.business.common.entities.EntityNameEnum; import org.libreplan.business.common.entities.EntitySequence; @@ -47,6 +46,7 @@ import org.libreplan.web.common.concurrentdetection.OnConcurrentModification; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; +import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -144,8 +144,13 @@ public class ConfigurationModel implements IConfigurationModel { @Transactional public void confirm() { checkEntitySequences(); - configurationDAO.save(configuration, Mode.FLUSH_BEFORE_VALIDATION); - storeAndRemoveEntitySequences(); + configurationDAO.save(configuration); + try { + storeAndRemoveEntitySequences(); + } catch (IllegalStateException e) { + throw new OptimisticLockingFailureException( + "concurrency problem in entity sequences"); + } } private void checkEntitySequences() {