code: private <E> Object onPreChecks(E entity, PersistenceDelegator delegator)
      {
          // pre validation.
          // check if entity is Null or with Invalid meta data!
          Object id = null;
  
          EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(delegator.getKunderaMetadata(),
                  entity.getClass());
          id = PropertyAccessorHelper.getId(entity, entityMetadata);
  
          // set id, in case of auto generation and still not set.
  
          if (ObjectGraphUtils.onAutoGenerateId((Field) entityMetadata.getIdAttribute().getJavaMember(), id))
          {
              id = new IdGenerator().generateAndSetId(entity, entityMetadata, delegator, delegator.getKunderaMetadata());
          }
  
          // check if id is set or not.
          new PrimaryKeyNullCheck<Object>().validate(id);
  
          validator.validate(entity, delegator.getKunderaMetadata());
  
          // }
  
          return id;
      }
docs: On pre checks before generating graph. performed checks: <li>Check if
  entity is valid.</li> <li>generated and set id in case
  {@link GeneratedValue} is present and not set.</li> <li>Check if primary
  key is not null.</li>
  
  
  @param entity
  entity
  @param client
  client
  @return entity id