From 1344e362efaa5aaf530b3db560da786a18f6ae41 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/entities/CalendarExceptionType.java | 7 +++++++ .../web/exceptionDays/CalendarExceptionTypeModel.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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 dd0a143a1..1fd468735 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. @@ -172,7 +174,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 {