@Override protected Task removeImpl(Task task) throws SystemException { task = toUnwrappedModel(task); Session session = null; try { session = openSession(); if (!session.contains(task)) { task = (Task) session.get(TaskImpl.class, task.getPrimaryKeyObj()); } if (task != null) { session.delete(task); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (task != null) { clearCache(task); } return task; }