@Override
  public ExpandoRow updateImpl(
      com.liferay.portlet.expando.model.ExpandoRow expandoRow, boolean merge)
      throws SystemException {
    expandoRow = toUnwrappedModel(expandoRow);

    boolean isNew = expandoRow.isNew();

    ExpandoRowModelImpl expandoRowModelImpl = (ExpandoRowModelImpl) expandoRow;

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, expandoRow, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        ExpandoRowModelImpl.ENTITY_CACHE_ENABLED,
        ExpandoRowImpl.class,
        expandoRow.getPrimaryKey(),
        expandoRow);

    if (!isNew
        && ((expandoRow.getTableId() != expandoRowModelImpl.getOriginalTableId())
            || (expandoRow.getClassPK() != expandoRowModelImpl.getOriginalClassPK()))) {
      FinderCacheUtil.removeResult(
          FINDER_PATH_FETCH_BY_T_C,
          new Object[] {
            Long.valueOf(expandoRowModelImpl.getOriginalTableId()),
            Long.valueOf(expandoRowModelImpl.getOriginalClassPK())
          });
    }

    if (isNew
        || ((expandoRow.getTableId() != expandoRowModelImpl.getOriginalTableId())
            || (expandoRow.getClassPK() != expandoRowModelImpl.getOriginalClassPK()))) {
      FinderCacheUtil.putResult(
          FINDER_PATH_FETCH_BY_T_C,
          new Object[] {
            Long.valueOf(expandoRow.getTableId()), Long.valueOf(expandoRow.getClassPK())
          },
          expandoRow);
    }

    return expandoRow;
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    ExpandoRow newExpandoRow = addExpandoRow();

    _persistence.clearCache();

    ExpandoRowModelImpl existingExpandoRowModelImpl =
        (ExpandoRowModelImpl) _persistence.findByPrimaryKey(newExpandoRow.getPrimaryKey());

    Assert.assertEquals(
        existingExpandoRowModelImpl.getTableId(), existingExpandoRowModelImpl.getOriginalTableId());
    Assert.assertEquals(
        existingExpandoRowModelImpl.getClassPK(), existingExpandoRowModelImpl.getOriginalClassPK());
  }