@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;
  }
  protected Account toUnwrappedModel(Account account) {
    if (account instanceof AccountImpl) {
      return account;
    }

    AccountImpl accountImpl = new AccountImpl();

    accountImpl.setNew(account.isNew());
    accountImpl.setPrimaryKey(account.getPrimaryKey());

    accountImpl.setAccountId(account.getAccountId());
    accountImpl.setCompanyId(account.getCompanyId());
    accountImpl.setUserId(account.getUserId());
    accountImpl.setUserName(account.getUserName());
    accountImpl.setCreateDate(account.getCreateDate());
    accountImpl.setModifiedDate(account.getModifiedDate());
    accountImpl.setParentAccountId(account.getParentAccountId());
    accountImpl.setName(account.getName());
    accountImpl.setLegalName(account.getLegalName());
    accountImpl.setLegalId(account.getLegalId());
    accountImpl.setLegalType(account.getLegalType());
    accountImpl.setSicCode(account.getSicCode());
    accountImpl.setTickerSymbol(account.getTickerSymbol());
    accountImpl.setIndustry(account.getIndustry());
    accountImpl.setType(account.getType());
    accountImpl.setSize(account.getSize());

    return accountImpl;
  }