@Override
  public ShoppingItemField updateImpl(
      com.liferay.portlet.shopping.model.ShoppingItemField shoppingItemField)
      throws SystemException {
    shoppingItemField = toUnwrappedModel(shoppingItemField);

    boolean isNew = shoppingItemField.isNew();

    ShoppingItemFieldModelImpl shoppingItemFieldModelImpl =
        (ShoppingItemFieldModelImpl) shoppingItemField;

    Session session = null;

    try {
      session = openSession();

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

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ShoppingItemFieldModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((shoppingItemFieldModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {Long.valueOf(shoppingItemFieldModelImpl.getOriginalItemId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ITEMID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID, args);

        args = new Object[] {Long.valueOf(shoppingItemFieldModelImpl.getItemId())};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_ITEMID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_ITEMID, args);
      }
    }

    EntityCacheUtil.putResult(
        ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
        ShoppingItemFieldImpl.class,
        shoppingItemField.getPrimaryKey(),
        shoppingItemField);

    return shoppingItemField;
  }
  /**
   * Caches the shopping item field in the entity cache if it is enabled.
   *
   * @param shoppingItemField the shopping item field
   */
  public void cacheResult(ShoppingItemField shoppingItemField) {
    EntityCacheUtil.putResult(
        ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
        ShoppingItemFieldImpl.class,
        shoppingItemField.getPrimaryKey(),
        shoppingItemField);

    shoppingItemField.resetOriginalValues();
  }
  /**
   * Clears the cache for the shopping item field.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(ShoppingItemField shoppingItemField) {
    EntityCacheUtil.removeResult(
        ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
        ShoppingItemFieldImpl.class,
        shoppingItemField.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }
 /**
  * Caches the shopping item fields in the entity cache if it is enabled.
  *
  * @param shoppingItemFields the shopping item fields
  */
 public void cacheResult(List<ShoppingItemField> shoppingItemFields) {
   for (ShoppingItemField shoppingItemField : shoppingItemFields) {
     if (EntityCacheUtil.getResult(
             ShoppingItemFieldModelImpl.ENTITY_CACHE_ENABLED,
             ShoppingItemFieldImpl.class,
             shoppingItemField.getPrimaryKey())
         == null) {
       cacheResult(shoppingItemField);
     } else {
       shoppingItemField.resetOriginalValues();
     }
   }
 }
  protected ShoppingItemField toUnwrappedModel(ShoppingItemField shoppingItemField) {
    if (shoppingItemField instanceof ShoppingItemFieldImpl) {
      return shoppingItemField;
    }

    ShoppingItemFieldImpl shoppingItemFieldImpl = new ShoppingItemFieldImpl();

    shoppingItemFieldImpl.setNew(shoppingItemField.isNew());
    shoppingItemFieldImpl.setPrimaryKey(shoppingItemField.getPrimaryKey());

    shoppingItemFieldImpl.setItemFieldId(shoppingItemField.getItemFieldId());
    shoppingItemFieldImpl.setItemId(shoppingItemField.getItemId());
    shoppingItemFieldImpl.setName(shoppingItemField.getName());
    shoppingItemFieldImpl.setValues(shoppingItemField.getValues());
    shoppingItemFieldImpl.setDescription(shoppingItemField.getDescription());

    return shoppingItemFieldImpl;
  }