public PmlEdmLevelSend updateImpl(
      com.sgs.portlet.pmllevelsend.model.PmlEdmLevelSend pmlEdmLevelSend, boolean merge)
      throws SystemException {
    Session session = null;

    try {
      session = openSession();

      if (merge) {
        session.merge(pmlEdmLevelSend);
      } else {
        if (pmlEdmLevelSend.isNew()) {
          session.save(pmlEdmLevelSend);
        }
      }

      session.flush();

      pmlEdmLevelSend.setNew(false);

      return pmlEdmLevelSend;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);

      FinderCacheUtil.clearCache(PmlEdmLevelSend.class.getName());
    }
  }
  public PmlEdmLevelSend create(int levelSendId) {
    PmlEdmLevelSend pmlEdmLevelSend = new PmlEdmLevelSendImpl();

    pmlEdmLevelSend.setNew(true);
    pmlEdmLevelSend.setPrimaryKey(levelSendId);

    return pmlEdmLevelSend;
  }
  /**
   * Add, update, or merge, the entity. This method also calls the model listeners to trigger the
   * proper events associated with adding, deleting, or updating an entity.
   *
   * @param pmlEdmLevelSend the entity to add, update, or merge
   * @param merge boolean value for whether to merge the entity. The default value is false. Setting
   *     merge to true is more expensive and should only be true when pmlEdmLevelSend is transient.
   *     See LEP-5473 for a detailed discussion of this method.
   * @return true if the portlet can be displayed via Ajax
   */
  public PmlEdmLevelSend update(PmlEdmLevelSend pmlEdmLevelSend, boolean merge)
      throws SystemException {
    boolean isNew = pmlEdmLevelSend.isNew();

    if (_listeners.length > 0) {
      for (ModelListener listener : _listeners) {
        if (isNew) {
          listener.onBeforeCreate(pmlEdmLevelSend);
        } else {
          listener.onBeforeUpdate(pmlEdmLevelSend);
        }
      }
    }

    pmlEdmLevelSend = updateImpl(pmlEdmLevelSend, merge);

    if (_listeners.length > 0) {
      for (ModelListener listener : _listeners) {
        if (isNew) {
          listener.onAfterCreate(pmlEdmLevelSend);
        } else {
          listener.onAfterUpdate(pmlEdmLevelSend);
        }
      }
    }

    return pmlEdmLevelSend;
  }