static Map < String , DBObject > getDocumentFromObject ( Metamodel metaModel , Object obj , Set < Attribute > columns , String tableName ) throws PropertyAccessException { Map < String , DBObject > embeddedObjects = new HashMap < String , DBObject > ( ) ; // BasicDBObject dBObj = new BasicDBObject(); for ( Attribute column : columns ) { String collectionName = ( ( AbstractAttribute ) column ) . getTableName ( ) != null ? ( ( AbstractAttribute ) column ) . getTableName ( ) : tableName ; DBObject dbObject = embeddedObjects . get ( collectionName ) ; if ( dbObject == null ) { dbObject = new BasicDBObject ( ) ; embeddedObjects . put ( collectionName , dbObject ) ; } if ( ( ( MetamodelImpl ) metaModel ) . isEmbeddable ( ( ( AbstractAttribute ) column ) . getBindableJavaType ( ) ) ) { DefaultMongoDBDataHandler handler = new DefaultMongoDBDataHandler ( ) ; // handler.onEmbeddable(column, obj, metaModel, dBObj, // collectionName); handler . onEmbeddable ( column , obj , metaModel , dbObject , collectionName ) ; } else { extractFieldValue ( obj , dbObject , column ) ; } } return embeddedObjects ; }
Creates a MongoDB document object wrt a given Java object . columns in the document correspond Columns provided as List .