code: public boolean isValidEntityObject(Object entity, EntityMetadata metadata)
      {
          if (entity == null)
          {
              log.error("Entity to be persisted must not be null, operation failed");
              return false;
          }
  
          Object id = PropertyAccessorHelper.getId(entity, metadata);
          if (id == null)
          {
              log.error("Entity to be persisted can't have Primary key set to null.");
              throw new IllegalArgumentException("Entity to be persisted can't have Primary key set to null.");
              // return false;
          }
          return true;
      }
docs: Validates an entity object for CRUD operations
  
  @param entity
  Instance of entity object
  @return True if entity object is valid, false otherwise