コード例 #1
0
  @Override
  public Account updateImpl(com.liferay.portal.model.Account account) throws SystemException {
    account = toUnwrappedModel(account);

    boolean isNew = account.isNew();

    Session session = null;

    try {
      session = openSession();

      if (account.isNew()) {
        session.save(account);

        account.setNew(false);
      } else {
        session.merge(account);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        AccountModelImpl.ENTITY_CACHE_ENABLED, AccountImpl.class, account.getPrimaryKey(), account);

    return account;
  }
コード例 #2
0
  /**
   * Creates a new account with the primary key. Does not add the account to the database.
   *
   * @param accountId the primary key for the new account
   * @return the new account
   */
  public Account create(long accountId) {
    Account account = new AccountImpl();

    account.setNew(true);
    account.setPrimaryKey(accountId);

    return account;
  }