private Map < String , Object > documentToPackableMap ( Map < String , Object > document ) { if ( compatibleValues ) { try { return jsonMapper . readValue ( jsonMapper . writeValueAsBytes ( document ) , new TypeReference < Map < String , Object > > ( ) { } ) ; } catch ( Exception e ) { throw new RuntimeException ( "Cannot convert document to json and back to Map " + e . getMessage ( ) ) ; } } /** * A document in MongoDB has a special field "_id" of type ObjectId * This object is not "packable" by Neo4jPacker so it must be converted to a value that Neo4j can deal with * * If the document is not null we simply override the ObjectId instance with its string representation */ if ( document != null ) { Object objectId = document . get ( "_id" ) ; if ( objectId != null ) { document . put ( "_id" , objectId . toString ( ) ) ; } } return document ; }
It translates a MongoDB document into a Map where the _id field is not an ObjectId but a simple String representation of it