From d3be77ff43c9d3653dcc9ccbee8bd0baeb099bf0 Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Tue, 10 May 2011 19:31:49 +0200 Subject: [PATCH] [Bug #1006] it catchs HibernateOptimisticLockingFailureException in validator method of the CalendarExceptionType Entity. It is caught in the validator. Otherwise it would be wraped by hibernate and would bypass the automatic handling of OptimisttcLockingFailureExceptions FEA: ItEr74S04BugFixing --- .../business/calendars/daos/CalendarExceptionTypeDAO.java | 1 - .../business/calendars/entities/CalendarExceptionType.java | 7 +++++++ .../web/exceptionDays/CalendarExceptionTypeModel.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/daos/CalendarExceptionTypeDAO.java b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/daos/CalendarExceptionTypeDAO.java index 5e8915005..e9ce22b8f 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/daos/CalendarExceptionTypeDAO.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/daos/CalendarExceptionTypeDAO.java @@ -90,7 +90,6 @@ public class CalendarExceptionTypeDAO extends } @Override - @Transactional(readOnly = true) public CalendarExceptionType findByName(String name) throws InstanceNotFoundException { if (StringUtils.isBlank(name)) { throw new InstanceNotFoundException(null, CalendarExceptionType.class.getName()); diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarExceptionType.java b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarExceptionType.java index 005b0990b..0374df8a5 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarExceptionType.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/calendars/entities/CalendarExceptionType.java @@ -28,6 +28,7 @@ import java.util.EnumMap; import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; +import org.hibernate.NonUniqueResultException; import org.hibernate.validator.AssertTrue; import org.hibernate.validator.NotNull; import org.navalplanner.business.calendars.daos.ICalendarExceptionTypeDAO; @@ -36,6 +37,7 @@ import org.navalplanner.business.common.Registry; import org.navalplanner.business.common.exceptions.InstanceNotFoundException; import org.navalplanner.business.workingday.EffortDuration; import org.navalplanner.business.workingday.EffortDuration.Granularity; +import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException; /** * Type of an exception day. @@ -171,7 +173,12 @@ public class CalendarExceptionType extends IntegrationEntity { return calendarExceptionType.getId().equals(getId()); } catch (InstanceNotFoundException e) { return true; + } catch (NonUniqueResultException e) { + return false; + } catch (HibernateOptimisticLockingFailureException e) { + return true; } + } } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/exceptionDays/CalendarExceptionTypeModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/exceptionDays/CalendarExceptionTypeModel.java index b57cfcdde..ac5eb2256 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/exceptionDays/CalendarExceptionTypeModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/exceptionDays/CalendarExceptionTypeModel.java @@ -48,7 +48,7 @@ import org.zkoss.util.InvalidValueException; */ @Service @Scope(BeanDefinition.SCOPE_PROTOTYPE) -@OnConcurrentModification(goToPage = "/exceptionDays/exceptionDays.zul") +@OnConcurrentModification(goToPage = "/excetiondays/exceptionDays.zul") public class CalendarExceptionTypeModel extends IntegrationEntityModel implements ICalendarExceptionTypeModel {