Ejemplo n.º 1
0
  /**
   * Stores the object in the database. If the object is new, it inserts it; otherwise an update is
   * performed. This method is meant to be used as part of a transaction, otherwise use the save()
   * method and the connection details will be handled internally
   */
  public void save(Connection con) throws TorqueException {
    if (!alreadyInSave) {
      alreadyInSave = true;

      // If this object has been modified, then save it to the database.
      if (isModified()) {
        if (isNew()) {
          MediatypePeer.doInsert((Mediatype) this, con);
          setNew(false);
        } else {
          MediatypePeer.doUpdate((Mediatype) this, con);
        }

        if (isCacheOnSave()) {
          MediatypeManager.putInstance(this);
        }
      }

      if (collPortletMediatypes != null) {
        for (int i = 0; i < collPortletMediatypes.size(); i++) {
          ((PortletMediatype) collPortletMediatypes.get(i)).save(con);
        }
      }
      alreadyInSave = false;
    }
  }