code: public GridFSInputFile getGFSInputFileFromEntity(GridFS gfs, EntityMetadata m, Object entity,
              KunderaMetadata kunderaMetadata, boolean isUpdate)
      {
          MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                  .getMetamodel(m.getPersistenceUnit());
          EntityType entityType = metaModel.entity(m.getEntityClazz());
          GridFSInputFile gridFSInputFile = null;
  
          DBObject gfsMetadata = new BasicDBObject();
  
          Set<Attribute> columns = entityType.getAttributes();
          for (Attribute column : columns)
          {
              boolean isLob = ((Field) column.getJavaMember()).getAnnotation(Lob.class) != null;
              if (isLob)
              {
                  gridFSInputFile = createGFSInputFile(gfs, entity, (Field) column.getJavaMember());
                  gridFSInputFile.setFilename(column.getName());
              }
              else
              {
                  if (isUpdate && column.getName().equals(m.getIdAttribute().getName()))
                  {
                      gfsMetadata.put(((AbstractAttribute) column).getJPAColumnName(), new ObjectId());
                  }
                  else
                      DocumentObjectMapper.extractFieldValue(entity, gfsMetadata, column);
              }
          }
          gridFSInputFile.setMetaData(gfsMetadata);
          return gridFSInputFile;
      }
docs: Gets the GFSInputFile from entity.
  
  @param gfs
  the gfs
  @param m
  the m
  @param entity
  the entity
  @param kunderaMetadata
  the kundera metadata
  @return the GFS iuput file from entity