protected EmpPersonalDetails toUnwrappedModel(EmpPersonalDetails empPersonalDetails) {
    if (empPersonalDetails instanceof EmpPersonalDetailsImpl) {
      return empPersonalDetails;
    }

    EmpPersonalDetailsImpl empPersonalDetailsImpl = new EmpPersonalDetailsImpl();

    empPersonalDetailsImpl.setNew(empPersonalDetails.isNew());
    empPersonalDetailsImpl.setPrimaryKey(empPersonalDetails.getPrimaryKey());

    empPersonalDetailsImpl.setEmpPersonalDetailsId(empPersonalDetails.getEmpPersonalDetailsId());
    empPersonalDetailsImpl.setEmployeeId(empPersonalDetails.getEmployeeId());
    empPersonalDetailsImpl.setGroupId(empPersonalDetails.getGroupId());
    empPersonalDetailsImpl.setCompanyId(empPersonalDetails.getCompanyId());
    empPersonalDetailsImpl.setUserId(empPersonalDetails.getUserId());
    empPersonalDetailsImpl.setCreateDate(empPersonalDetails.getCreateDate());
    empPersonalDetailsImpl.setModifiedDate(empPersonalDetails.getModifiedDate());
    empPersonalDetailsImpl.setFirstName(empPersonalDetails.getFirstName());
    empPersonalDetailsImpl.setLastName(empPersonalDetails.getLastName());
    empPersonalDetailsImpl.setMiddleName(empPersonalDetails.getMiddleName());
    empPersonalDetailsImpl.setEmployeeNo(empPersonalDetails.getEmployeeNo());
    empPersonalDetailsImpl.setOtherId(empPersonalDetails.getOtherId());
    empPersonalDetailsImpl.setLicenseNo(empPersonalDetails.getLicenseNo());
    empPersonalDetailsImpl.setLicenseExpDate(empPersonalDetails.getLicenseExpDate());
    empPersonalDetailsImpl.setGender(empPersonalDetails.getGender());
    empPersonalDetailsImpl.setMaritalStatus(empPersonalDetails.getMaritalStatus());
    empPersonalDetailsImpl.setNationalityId(empPersonalDetails.getNationalityId());
    empPersonalDetailsImpl.setDateOfBirth(empPersonalDetails.getDateOfBirth());

    return empPersonalDetailsImpl;
  }
  @Override
  public EmpPersonalDetails updateImpl(
      com.rknowsys.eapp.hrm.model.EmpPersonalDetails empPersonalDetails) throws SystemException {
    empPersonalDetails = toUnwrappedModel(empPersonalDetails);

    boolean isNew = empPersonalDetails.isNew();

    EmpPersonalDetailsModelImpl empPersonalDetailsModelImpl =
        (EmpPersonalDetailsModelImpl) empPersonalDetails;

    Session session = null;

    try {
      session = openSession();

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

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !EmpPersonalDetailsModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((empPersonalDetailsModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMPLOYEEID.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {empPersonalDetailsModelImpl.getOriginalEmployeeId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMPLOYEEID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMPLOYEEID, args);

        args = new Object[] {empPersonalDetailsModelImpl.getEmployeeId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMPLOYEEID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMPLOYEEID, args);
      }
    }

    EntityCacheUtil.putResult(
        EmpPersonalDetailsModelImpl.ENTITY_CACHE_ENABLED,
        EmpPersonalDetailsImpl.class,
        empPersonalDetails.getPrimaryKey(),
        empPersonalDetails);

    return empPersonalDetails;
  }
  /**
   * Clears the cache for the EmpPersonalDetails.
   *
   * <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(EmpPersonalDetails empPersonalDetails) {
    EntityCacheUtil.removeResult(
        EmpPersonalDetailsModelImpl.ENTITY_CACHE_ENABLED,
        EmpPersonalDetailsImpl.class,
        empPersonalDetails.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }
  /**
   * Caches the EmpPersonalDetails in the entity cache if it is enabled.
   *
   * @param empPersonalDetails the EmpPersonalDetails
   */
  @Override
  public void cacheResult(EmpPersonalDetails empPersonalDetails) {
    EntityCacheUtil.putResult(
        EmpPersonalDetailsModelImpl.ENTITY_CACHE_ENABLED,
        EmpPersonalDetailsImpl.class,
        empPersonalDetails.getPrimaryKey(),
        empPersonalDetails);

    empPersonalDetails.resetOriginalValues();
  }
 /**
  * Caches the EmpPersonalDetailses in the entity cache if it is enabled.
  *
  * @param empPersonalDetailses the EmpPersonalDetailses
  */
 @Override
 public void cacheResult(List<EmpPersonalDetails> empPersonalDetailses) {
   for (EmpPersonalDetails empPersonalDetails : empPersonalDetailses) {
     if (EntityCacheUtil.getResult(
             EmpPersonalDetailsModelImpl.ENTITY_CACHE_ENABLED,
             EmpPersonalDetailsImpl.class,
             empPersonalDetails.getPrimaryKey())
         == null) {
       cacheResult(empPersonalDetails);
     } else {
       empPersonalDetails.resetOriginalValues();
     }
   }
 }