@Override
  public HRClient updateImpl(com.liferay.hr.model.HRClient hrClient, boolean merge)
      throws SystemException {
    hrClient = toUnwrappedModel(hrClient);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, hrClient, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        HRClientModelImpl.ENTITY_CACHE_ENABLED,
        HRClientImpl.class,
        hrClient.getPrimaryKey(),
        hrClient);

    return hrClient;
  }
  @Override
  protected HRClient removeImpl(HRClient hrClient) throws SystemException {
    hrClient = toUnwrappedModel(hrClient);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, hrClient);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);

    EntityCacheUtil.removeResult(
        HRClientModelImpl.ENTITY_CACHE_ENABLED, HRClientImpl.class, hrClient.getPrimaryKey());

    return hrClient;
  }
  /**
   * Clears the cache for the h r client.
   *
   * <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(HRClient hrClient) {
    EntityCacheUtil.removeResult(
        HRClientModelImpl.ENTITY_CACHE_ENABLED, HRClientImpl.class, hrClient.getPrimaryKey());

    FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL, FINDER_ARGS_EMPTY);
  }
  /**
   * Caches the h r client in the entity cache if it is enabled.
   *
   * @param hrClient the h r client
   */
  public void cacheResult(HRClient hrClient) {
    EntityCacheUtil.putResult(
        HRClientModelImpl.ENTITY_CACHE_ENABLED,
        HRClientImpl.class,
        hrClient.getPrimaryKey(),
        hrClient);

    hrClient.resetOriginalValues();
  }
 /**
  * Caches the h r clients in the entity cache if it is enabled.
  *
  * @param hrClients the h r clients
  */
 public void cacheResult(List<HRClient> hrClients) {
   for (HRClient hrClient : hrClients) {
     if (EntityCacheUtil.getResult(
             HRClientModelImpl.ENTITY_CACHE_ENABLED, HRClientImpl.class, hrClient.getPrimaryKey())
         == null) {
       cacheResult(hrClient);
     }
   }
 }
  protected HRClient toUnwrappedModel(HRClient hrClient) {
    if (hrClient instanceof HRClientImpl) {
      return hrClient;
    }

    HRClientImpl hrClientImpl = new HRClientImpl();

    hrClientImpl.setNew(hrClient.isNew());
    hrClientImpl.setPrimaryKey(hrClient.getPrimaryKey());

    hrClientImpl.setHrClientId(hrClient.getHrClientId());
    hrClientImpl.setGroupId(hrClient.getGroupId());
    hrClientImpl.setCompanyId(hrClient.getCompanyId());
    hrClientImpl.setUserId(hrClient.getUserId());
    hrClientImpl.setUserName(hrClient.getUserName());
    hrClientImpl.setCreateDate(hrClient.getCreateDate());
    hrClientImpl.setModifiedDate(hrClient.getModifiedDate());
    hrClientImpl.setName(hrClient.getName());
    hrClientImpl.setDescription(hrClient.getDescription());

    return hrClientImpl;
  }