public ViewListTitleCompetencies remove(String id)
      throws NoSuchViewListTitleCompetenciesException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ViewListTitleCompetencies viewListTitleCompetencies =
          (ViewListTitleCompetencies) session.get(ViewListTitleCompetenciesImpl.class, id);

      if (viewListTitleCompetencies == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("No ViewListTitleCompetencies exists with the primary key " + id);
        }

        throw new NoSuchViewListTitleCompetenciesException(
            "No ViewListTitleCompetencies exists with the primary key " + id);
      }

      return remove(viewListTitleCompetencies);
    } catch (NoSuchViewListTitleCompetenciesException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Returns the bar with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar, or <code>null</code> if a bar with the primary key could not be found
   */
  @Override
  public Bar fetchByPrimaryKey(Serializable primaryKey) {
    Bar bar =
        (Bar)
            EntityCacheUtil.getResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

    if (bar == _nullBar) {
      return null;
    }

    if (bar == null) {
      Session session = null;

      try {
        session = openSession();

        bar = (Bar) session.get(BarImpl.class, primaryKey);

        if (bar != null) {
          cacheResult(bar);
        } else {
          EntityCacheUtil.putResult(
              BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey, _nullBar);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return bar;
  }
  /**
   * Removes the projects entry with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the projects entry
   * @return the projects entry that was removed
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry remove(Serializable primaryKey)
      throws NoSuchProjectsEntryException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ProjectsEntry projectsEntry =
          (ProjectsEntry) session.get(ProjectsEntryImpl.class, primaryKey);

      if (projectsEntry == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchProjectsEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(projectsEntry);
    } catch (NoSuchProjectsEntryException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the shopping item field with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the shopping item field
   * @return the shopping item field that was removed
   * @throws com.liferay.portlet.shopping.NoSuchItemFieldException if a shopping item field with the
   *     primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ShoppingItemField remove(Serializable primaryKey)
      throws NoSuchItemFieldException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ShoppingItemField shoppingItemField =
          (ShoppingItemField) session.get(ShoppingItemFieldImpl.class, primaryKey);

      if (shoppingItemField == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchItemFieldException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(shoppingItemField);
    } catch (NoSuchItemFieldException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the bar with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar that was removed
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar remove(Serializable primaryKey) throws NoSuchBarException {
    Session session = null;

    try {
      session = openSession();

      Bar bar = (Bar) session.get(BarImpl.class, primaryKey);

      if (bar == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchBarException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(bar);
    } catch (NoSuchBarException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  protected Shard removeImpl(Shard shard) throws SystemException {
    shard = toUnwrappedModel(shard);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(shard)) {
        shard = (Shard) session.get(ShardImpl.class, shard.getPrimaryKeyObj());
      }

      if (shard != null) {
        session.delete(shard);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (shard != null) {
      clearCache(shard);
    }

    return shard;
  }
Exemple #7
0
  @Override
  protected PasswordTracker removeImpl(PasswordTracker passwordTracker) throws SystemException {
    passwordTracker = toUnwrappedModel(passwordTracker);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(passwordTracker)) {
        passwordTracker =
            (PasswordTracker)
                session.get(PasswordTrackerImpl.class, passwordTracker.getPrimaryKeyObj());
      }

      if (passwordTracker != null) {
        session.delete(passwordTracker);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (passwordTracker != null) {
      clearCache(passwordTracker);
    }

    return passwordTracker;
  }
  /**
   * Removes the announcements flag with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the announcements flag
   * @return the announcements flag that was removed
   * @throws com.liferay.portlet.announcements.NoSuchFlagException if a announcements flag with the
   *     primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public AnnouncementsFlag remove(Serializable primaryKey)
      throws NoSuchFlagException, SystemException {
    Session session = null;

    try {
      session = openSession();

      AnnouncementsFlag announcementsFlag =
          (AnnouncementsFlag) session.get(AnnouncementsFlagImpl.class, primaryKey);

      if (announcementsFlag == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchFlagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(announcementsFlag);
    } catch (NoSuchFlagException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  public SoPhongVanBanNoiBo remove(SoPhongVanBanNoiBoPK soPhongVanBanNoiBoPK)
      throws NoSuchSoPhongVanBanNoiBoException, SystemException {
    Session session = null;

    try {
      session = openSession();

      SoPhongVanBanNoiBo soPhongVanBanNoiBo =
          (SoPhongVanBanNoiBo) session.get(SoPhongVanBanNoiBoImpl.class, soPhongVanBanNoiBoPK);

      if (soPhongVanBanNoiBo == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("No SoPhongVanBanNoiBo exists with the primary key " + soPhongVanBanNoiBoPK);
        }

        throw new NoSuchSoPhongVanBanNoiBoException(
            "No SoPhongVanBanNoiBo exists with the primary key " + soPhongVanBanNoiBoPK);
      }

      return remove(soPhongVanBanNoiBo);
    } catch (NoSuchSoPhongVanBanNoiBoException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the social equity history with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param equityHistoryId the primary key of the social equity history
   * @return the social equity history that was removed
   * @throws com.liferay.portlet.social.NoSuchEquityHistoryException if a social equity history with
   *     the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  public SocialEquityHistory remove(long equityHistoryId)
      throws NoSuchEquityHistoryException, SystemException {
    Session session = null;

    try {
      session = openSession();

      SocialEquityHistory socialEquityHistory =
          (SocialEquityHistory)
              session.get(SocialEquityHistoryImpl.class, Long.valueOf(equityHistoryId));

      if (socialEquityHistory == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + equityHistoryId);
        }

        throw new NoSuchEquityHistoryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + equityHistoryId);
      }

      return socialEquityHistoryPersistence.remove(socialEquityHistory);
    } catch (NoSuchEquityHistoryException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  protected ListType removeImpl(ListType listType) {
    listType = toUnwrappedModel(listType);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(listType)) {
        listType = (ListType) session.get(ListTypeImpl.class, listType.getPrimaryKeyObj());
      }

      if (listType != null) {
        session.delete(listType);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (listType != null) {
      clearCache(listType);
    }

    return listType;
  }
  @Override
  protected Semester removeImpl(Semester semester) {
    semester = toUnwrappedModel(semester);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(semester)) {
        semester = (Semester) session.get(SemesterImpl.class, semester.getPrimaryKeyObj());
      }

      if (semester != null) {
        session.delete(semester);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (semester != null) {
      clearCache(semester);
    }

    return semester;
  }
  public ViewListTitleCompetencies fetchByPrimaryKey(String id) throws SystemException {
    ViewListTitleCompetencies viewListTitleCompetencies =
        (ViewListTitleCompetencies)
            EntityCacheUtil.getResult(
                ViewListTitleCompetenciesModelImpl.ENTITY_CACHE_ENABLED,
                ViewListTitleCompetenciesImpl.class,
                id,
                this);

    if (viewListTitleCompetencies == null) {
      Session session = null;

      try {
        session = openSession();

        viewListTitleCompetencies =
            (ViewListTitleCompetencies) session.get(ViewListTitleCompetenciesImpl.class, id);
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (viewListTitleCompetencies != null) {
          cacheResult(viewListTitleCompetencies);
        }

        closeSession(session);
      }
    }

    return viewListTitleCompetencies;
  }
  protected ViewListTitleCompetencies removeImpl(
      ViewListTitleCompetencies viewListTitleCompetencies) throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (viewListTitleCompetencies.isCachedModel() || BatchSessionUtil.isEnabled()) {
        Object staleObject =
            session.get(
                ViewListTitleCompetenciesImpl.class, viewListTitleCompetencies.getPrimaryKeyObj());

        if (staleObject != null) {
          session.evict(staleObject);
        }
      }

      session.delete(viewListTitleCompetencies);

      session.flush();
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        ViewListTitleCompetenciesModelImpl.ENTITY_CACHE_ENABLED,
        ViewListTitleCompetenciesImpl.class,
        viewListTitleCompetencies.getPrimaryKey());

    return viewListTitleCompetencies;
  }
  /**
   * Removes the tra cuu thu tuc hanh chinh with the primary key from the database. Also notifies
   * the appropriate model listeners.
   *
   * @param primaryKey the primary key of the tra cuu thu tuc hanh chinh
   * @return the tra cuu thu tuc hanh chinh that was removed
   * @throws org.oep.cmon.dao.touchscreen.NoSuchTraCuuThuTucHanhChinhException if a tra cuu thu tuc
   *     hanh chinh with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public TraCuuThuTucHanhChinh remove(Serializable primaryKey)
      throws NoSuchTraCuuThuTucHanhChinhException, SystemException {
    Session session = null;

    try {
      session = openSession();

      TraCuuThuTucHanhChinh traCuuThuTucHanhChinh =
          (TraCuuThuTucHanhChinh) session.get(TraCuuThuTucHanhChinhImpl.class, primaryKey);

      if (traCuuThuTucHanhChinh == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchTraCuuThuTucHanhChinhException(
            _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(traCuuThuTucHanhChinh);
    } catch (NoSuchTraCuuThuTucHanhChinhException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the Tips of the Day Users with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the Tips of the Day Users
   * @return the Tips of the Day Users that was removed
   * @throws com.rivetlogic.NoSuchTipsOfTheDayUsersException if a Tips of the Day Users with the
   *     primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public TipsOfTheDayUsers remove(Serializable primaryKey)
      throws NoSuchTipsOfTheDayUsersException, SystemException {
    Session session = null;

    try {
      session = openSession();

      TipsOfTheDayUsers tipsOfTheDayUsers =
          (TipsOfTheDayUsers) session.get(TipsOfTheDayUsersImpl.class, primaryKey);

      if (tipsOfTheDayUsers == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchTipsOfTheDayUsersException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(tipsOfTheDayUsers);
    } catch (NoSuchTipsOfTheDayUsersException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  protected Asset removeImpl(Asset asset) throws SystemException {
    asset = toUnwrappedModel(asset);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(asset)) {
        asset = (Asset) session.get(AssetImpl.class, asset.getPrimaryKeyObj());
      }

      if (asset != null) {
        session.delete(asset);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (asset != null) {
      clearCache(asset);
    }

    return asset;
  }
  @Override
  protected TipsOfTheDayUsers removeImpl(TipsOfTheDayUsers tipsOfTheDayUsers)
      throws SystemException {
    tipsOfTheDayUsers = toUnwrappedModel(tipsOfTheDayUsers);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(tipsOfTheDayUsers)) {
        tipsOfTheDayUsers =
            (TipsOfTheDayUsers)
                session.get(TipsOfTheDayUsersImpl.class, tipsOfTheDayUsers.getPrimaryKeyObj());
      }

      if (tipsOfTheDayUsers != null) {
        session.delete(tipsOfTheDayUsers);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (tipsOfTheDayUsers != null) {
      clearCache(tipsOfTheDayUsers);
    }

    return tipsOfTheDayUsers;
  }
  /**
   * Removes the ticket with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param ticketId the primary key of the ticket
   * @return the ticket that was removed
   * @throws com.liferay.portal.NoSuchTicketException if a ticket with the primary key could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  public Ticket remove(long ticketId) throws NoSuchTicketException, SystemException {
    Session session = null;

    try {
      session = openSession();

      Ticket ticket = (Ticket) session.get(TicketImpl.class, Long.valueOf(ticketId));

      if (ticket == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + ticketId);
        }

        throw new NoSuchTicketException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + ticketId);
      }

      return ticketPersistence.remove(ticket);
    } catch (NoSuchTicketException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the bar with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param barId the primary key of the bar
   * @return the bar that was removed
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   * @throws SystemException if a system exception occurred
   */
  public Bar remove(long barId) throws NoSuchBarException, SystemException {
    Session session = null;

    try {
      session = openSession();

      Bar bar = (Bar) session.get(BarImpl.class, Long.valueOf(barId));

      if (bar == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + barId);
        }

        throw new NoSuchBarException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + barId);
      }

      return barPersistence.remove(bar);
    } catch (NoSuchBarException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  public PmlEdmLevelSend remove(int levelSendId)
      throws NoSuchPmlEdmLevelSendException, SystemException {
    Session session = null;

    try {
      session = openSession();

      PmlEdmLevelSend pmlEdmLevelSend =
          (PmlEdmLevelSend) session.get(PmlEdmLevelSendImpl.class, new Integer(levelSendId));

      if (pmlEdmLevelSend == null) {
        if (_log.isWarnEnabled()) {
          _log.warn("No PmlEdmLevelSend exists with the primary key " + levelSendId);
        }

        throw new NoSuchPmlEdmLevelSendException(
            "No PmlEdmLevelSend exists with the primary key " + levelSendId);
      }

      return remove(pmlEdmLevelSend);
    } catch (NoSuchPmlEdmLevelSendException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the shopping item price with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the shopping item price
   * @return the shopping item price that was removed
   * @throws NoSuchItemPriceException if a shopping item price with the primary key could not be
   *     found
   */
  @Override
  public ShoppingItemPrice remove(Serializable primaryKey) throws NoSuchItemPriceException {
    Session session = null;

    try {
      session = openSession();

      ShoppingItemPrice shoppingItemPrice =
          (ShoppingItemPrice) session.get(ShoppingItemPriceImpl.class, primaryKey);

      if (shoppingItemPrice == null) {
        if (_log.isDebugEnabled()) {
          _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchItemPriceException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(shoppingItemPrice);
    } catch (NoSuchItemPriceException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  protected ShoppingItemField removeImpl(ShoppingItemField shoppingItemField)
      throws SystemException {
    shoppingItemField = toUnwrappedModel(shoppingItemField);

    Session session = null;

    try {
      session = openSession();

      if (shoppingItemField.isCachedModel()) {
        shoppingItemField =
            (ShoppingItemField)
                session.get(ShoppingItemFieldImpl.class, shoppingItemField.getPrimaryKeyObj());
      }

      session.delete(shoppingItemField);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    clearCache(shoppingItemField);

    return shoppingItemField;
  }
  @Override
  protected ShoppingItemPrice removeImpl(ShoppingItemPrice shoppingItemPrice) {
    shoppingItemPrice = toUnwrappedModel(shoppingItemPrice);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(shoppingItemPrice)) {
        shoppingItemPrice =
            (ShoppingItemPrice)
                session.get(ShoppingItemPriceImpl.class, shoppingItemPrice.getPrimaryKeyObj());
      }

      if (shoppingItemPrice != null) {
        session.delete(shoppingItemPrice);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (shoppingItemPrice != null) {
      clearCache(shoppingItemPrice);
    }

    return shoppingItemPrice;
  }
  @Override
  protected Bar removeImpl(Bar bar) {
    bar = toUnwrappedModel(bar);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(bar)) {
        bar = (Bar) session.get(BarImpl.class, bar.getPrimaryKeyObj());
      }

      if (bar != null) {
        session.delete(bar);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (bar != null) {
      clearCache(bar);
    }

    return bar;
  }
  /**
   * Removes the h r project with the primary key from the database. Also notifies the appropriate
   * model listeners.
   *
   * @param hrProjectId the primary key of the h r project
   * @return the h r project that was removed
   * @throws com.liferay.hr.NoSuchProjectException if a h r project with the primary key could not
   *     be found
   * @throws SystemException if a system exception occurred
   */
  public HRProject remove(long hrProjectId) throws NoSuchProjectException, SystemException {
    Session session = null;

    try {
      session = openSession();

      HRProject hrProject = (HRProject) session.get(HRProjectImpl.class, Long.valueOf(hrProjectId));

      if (hrProject == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + hrProjectId);
        }

        throw new NoSuchProjectException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + hrProjectId);
      }

      return hrProjectPersistence.remove(hrProject);
    } catch (NoSuchProjectException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  /**
   * Removes the class name with the primary key from the database. Also notifies the appropriate
   * model listeners.
   *
   * @param primaryKey the primary key of the class name
   * @return the class name that was removed
   * @throws com.liferay.portal.NoSuchClassNameException if a class name with the primary key could
   *     not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ClassName remove(Serializable primaryKey)
      throws NoSuchClassNameException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ClassName className = (ClassName) session.get(ClassNameImpl.class, primaryKey);

      if (className == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchClassNameException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(className);
    } catch (NoSuchClassNameException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
Exemple #28
0
  private CounterHolder _obtainIncrement(String counterName, long range, long size)
      throws SystemException {

    Session session = null;

    try {
      session = openSession();

      Counter counter = (Counter) session.get(CounterImpl.class, counterName, LockMode.UPGRADE);

      long newValue = counter.getCurrentId();

      if (size > newValue) {
        newValue = size;
      }

      long rangeMax = newValue + range;

      counter.setCurrentId(rangeMax);

      CounterHolder counterHolder = new CounterHolder(newValue, rangeMax);

      session.saveOrUpdate(counter);

      session.flush();

      return counterHolder;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }
  @Override
  protected ProjectsEntry removeImpl(ProjectsEntry projectsEntry) throws SystemException {
    projectsEntry = toUnwrappedModel(projectsEntry);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(projectsEntry)) {
        projectsEntry =
            (ProjectsEntry) session.get(ProjectsEntryImpl.class, projectsEntry.getPrimaryKeyObj());
      }

      if (projectsEntry != null) {
        session.delete(projectsEntry);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (projectsEntry != null) {
      clearCache(projectsEntry);
    }

    return projectsEntry;
  }
  /**
   * Removes the j i r a change item with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param jiraChangeItemId the primary key of the j i r a change item
   * @return the j i r a change item that was removed
   * @throws com.liferay.socialcoding.NoSuchJIRAChangeItemException if a j i r a change item with
   *     the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  public JIRAChangeItem remove(long jiraChangeItemId)
      throws NoSuchJIRAChangeItemException, SystemException {
    Session session = null;

    try {
      session = openSession();

      JIRAChangeItem jiraChangeItem =
          (JIRAChangeItem) session.get(JIRAChangeItemImpl.class, Long.valueOf(jiraChangeItemId));

      if (jiraChangeItem == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + jiraChangeItemId);
        }

        throw new NoSuchJIRAChangeItemException(
            _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + jiraChangeItemId);
      }

      return jiraChangeItemPersistence.remove(jiraChangeItem);
    } catch (NoSuchJIRAChangeItemException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }