From 2851cfa584b60d17c06a1c8c1a669ada1479ac53 Mon Sep 17 00:00:00 2001 From: jakubs <jakubs> Date: Tue, 14 Feb 2012 09:08:20 +0000 Subject: [PATCH] LMS-2767 Add nullCheck in PostRegistrationDAO SVN: 24444 --- .../server/dataaccess/db/PostRegistrationDAO.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/PostRegistrationDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/PostRegistrationDAO.java index fdb8121359f..081c68ec7ae 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/PostRegistrationDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/PostRegistrationDAO.java @@ -43,7 +43,10 @@ public class PostRegistrationDAO extends AbstractGenericEntityDAO<PostRegistrati PostRegistrationPE p = tryFindByDataSet(dataSet); HibernateTemplate template = getHibernateTemplate(); - template.delete(p); + if (p != null) + { + template.delete(p); + } } public PostRegistrationPE tryFindByDataSet(final DataPE dataSet) @@ -52,14 +55,13 @@ public class PostRegistrationDAO extends AbstractGenericEntityDAO<PostRegistrati final Criteria criteria = getSession().createCriteria(getEntityClass()); criteria.add(Restrictions.eq("dataSet", dataSet)); - final PostRegistrationPE experiment = (PostRegistrationPE) criteria.uniqueResult(); + final PostRegistrationPE pr = (PostRegistrationPE) criteria.uniqueResult(); if (operationLog.isDebugEnabled()) { operationLog.debug(String.format( - "Following experiment '%s' has been found for dataSet '%s'.", experiment, - dataSet)); + "Following experiment '%s' has been found for dataSet '%s'.", pr, dataSet)); } - return experiment; + return pr; } public Collection<Long> listDataSetsForPostRegistration() -- GitLab