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

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, hrUserTimeOff, merge);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.putResult(
        HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
        HRUserTimeOffImpl.class,
        hrUserTimeOff.getPrimaryKey(),
        hrUserTimeOff);

    return hrUserTimeOff;
  }
  /**
   * Creates a new h r user time off with the primary key. Does not add the h r user time off to the
   * database.
   *
   * @param hrUserTimeOffId the primary key for the new h r user time off
   * @return the new h r user time off
   */
  public HRUserTimeOff create(long hrUserTimeOffId) {
    HRUserTimeOff hrUserTimeOff = new HRUserTimeOffImpl();

    hrUserTimeOff.setNew(true);
    hrUserTimeOff.setPrimaryKey(hrUserTimeOffId);

    return hrUserTimeOff;
  }
  /**
   * Caches the h r user time off in the entity cache if it is enabled.
   *
   * @param hrUserTimeOff the h r user time off
   */
  public void cacheResult(HRUserTimeOff hrUserTimeOff) {
    EntityCacheUtil.putResult(
        HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
        HRUserTimeOffImpl.class,
        hrUserTimeOff.getPrimaryKey(),
        hrUserTimeOff);

    hrUserTimeOff.resetOriginalValues();
  }
 /**
  * Caches the h r user time offs in the entity cache if it is enabled.
  *
  * @param hrUserTimeOffs the h r user time offs
  */
 public void cacheResult(List<HRUserTimeOff> hrUserTimeOffs) {
   for (HRUserTimeOff hrUserTimeOff : hrUserTimeOffs) {
     if (EntityCacheUtil.getResult(
             HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
             HRUserTimeOffImpl.class,
             hrUserTimeOff.getPrimaryKey(),
             this)
         == null) {
       cacheResult(hrUserTimeOff);
     }
   }
 }
  @Override
  protected HRUserTimeOff removeImpl(HRUserTimeOff hrUserTimeOff) throws SystemException {
    hrUserTimeOff = toUnwrappedModel(hrUserTimeOff);

    Session session = null;

    try {
      session = openSession();

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(
        HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
        HRUserTimeOffImpl.class,
        hrUserTimeOff.getPrimaryKey());

    return hrUserTimeOff;
  }
 /**
  * Clears the cache for the h r user time off.
  *
  * <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(HRUserTimeOff hrUserTimeOff) {
   EntityCacheUtil.removeResult(
       HRUserTimeOffModelImpl.ENTITY_CACHE_ENABLED,
       HRUserTimeOffImpl.class,
       hrUserTimeOff.getPrimaryKey());
 }
  protected HRUserTimeOff toUnwrappedModel(HRUserTimeOff hrUserTimeOff) {
    if (hrUserTimeOff instanceof HRUserTimeOffImpl) {
      return hrUserTimeOff;
    }

    HRUserTimeOffImpl hrUserTimeOffImpl = new HRUserTimeOffImpl();

    hrUserTimeOffImpl.setNew(hrUserTimeOff.isNew());
    hrUserTimeOffImpl.setPrimaryKey(hrUserTimeOff.getPrimaryKey());

    hrUserTimeOffImpl.setHrUserTimeOffId(hrUserTimeOff.getHrUserTimeOffId());
    hrUserTimeOffImpl.setGroupId(hrUserTimeOff.getGroupId());
    hrUserTimeOffImpl.setCompanyId(hrUserTimeOff.getCompanyId());
    hrUserTimeOffImpl.setUserId(hrUserTimeOff.getUserId());
    hrUserTimeOffImpl.setUserName(hrUserTimeOff.getUserName());
    hrUserTimeOffImpl.setCreateDate(hrUserTimeOff.getCreateDate());
    hrUserTimeOffImpl.setModifiedDate(hrUserTimeOff.getModifiedDate());
    hrUserTimeOffImpl.setHrTimeOffTypeId(hrUserTimeOff.getHrTimeOffTypeId());
    hrUserTimeOffImpl.setHrUserId(hrUserTimeOff.getHrUserId());
    hrUserTimeOffImpl.setYear(hrUserTimeOff.getYear());
    hrUserTimeOffImpl.setHoursAllowed(hrUserTimeOff.getHoursAllowed());
    hrUserTimeOffImpl.setHoursAccrued(hrUserTimeOff.getHoursAccrued());
    hrUserTimeOffImpl.setHoursCarriedOver(hrUserTimeOff.getHoursCarriedOver());
    hrUserTimeOffImpl.setHoursUsed(hrUserTimeOff.getHoursUsed());

    return hrUserTimeOffImpl;
  }