[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
This commit is contained in:
Susana Montes Pedreira 2011-05-10 19:31:49 +02:00
parent 73fbd7b969
commit d3be77ff43
3 changed files with 8 additions and 2 deletions

View file

@ -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());

View file

@ -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;
}
}
}

View file

@ -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 {