/**
  * Sets the default property values for the properties the entity manager supports and which are
  * not already explicitly set.
  */
 private void setDefaultProperties() {
   if (properties.get(AvailableSettings.FLUSH_MODE) == null) {
     properties.put(AvailableSettings.FLUSH_MODE, getSession().getFlushMode().toString());
   }
   if (properties.get(AvailableSettings.LOCK_SCOPE) == null) {
     this.properties.put(AvailableSettings.LOCK_SCOPE, PessimisticLockScope.EXTENDED.name());
   }
   if (properties.get(AvailableSettings.LOCK_TIMEOUT) == null) {
     properties.put(AvailableSettings.LOCK_TIMEOUT, LockOptions.WAIT_FOREVER);
   }
   if (properties.get(AvailableSettings.SHARED_CACHE_RETRIEVE_MODE) == null) {
     properties.put(
         AvailableSettings.SHARED_CACHE_RETRIEVE_MODE, CacheModeHelper.DEFAULT_RETRIEVE_MODE);
   }
   if (properties.get(AvailableSettings.SHARED_CACHE_STORE_MODE) == null) {
     properties.put(AvailableSettings.SHARED_CACHE_STORE_MODE, CacheModeHelper.DEFAULT_STORE_MODE);
   }
 }
  private void setLockOptions(Map<String, Object> props, LockOptions options) {
    Object lockScope = props.get(AvailableSettings.LOCK_SCOPE);
    if (lockScope instanceof String
        && PessimisticLockScope.valueOf((String) lockScope) == PessimisticLockScope.EXTENDED) {
      options.setScope(true);
    } else if (lockScope instanceof PessimisticLockScope) {
      boolean extended = PessimisticLockScope.EXTENDED.equals((PessimisticLockScope) lockScope);
      options.setScope(extended);
    } else if (lockScope != null) {
      throw new PersistenceException(
          "Unable to parse " + AvailableSettings.LOCK_SCOPE + ": " + lockScope);
    }

    Object lockTimeout = props.get(AvailableSettings.LOCK_TIMEOUT);
    int timeout = 0;
    boolean timeoutSet = false;
    if (lockTimeout instanceof String) {
      timeout = Integer.parseInt((String) lockTimeout);
      timeoutSet = true;
    } else if (lockTimeout instanceof Number) {
      timeout = ((Number) lockTimeout).intValue();
      timeoutSet = true;
    } else if (lockTimeout != null) {
      throw new PersistenceException(
          "Unable to parse " + AvailableSettings.LOCK_TIMEOUT + ": " + lockTimeout);
    }
    if (timeoutSet) {
      if (timeout < 0) {
        options.setTimeOut(LockOptions.WAIT_FOREVER);
      } else if (timeout == 0) {
        options.setTimeOut(LockOptions.NO_WAIT);
      } else {
        options.setTimeOut(timeout);
      }
    }
  }