Package com.mongodb

Examples of com.mongodb.BasicDBObject


    golfPlayer.put( "handicap", 0.1 );
    return golfPlayer;
  }

  private BasicDBList getPlayedCoursesAssociationEmbedded() {
    BasicDBObject bepplePeachRef = new BasicDBObject();
    bepplePeachRef.put( "playedCourses_id", 1L );

    BasicDBList playedCourses = new BasicDBList();
    playedCourses.add( bepplePeachRef );

    return playedCourses;
View Full Code Here


    return playedCourses;
  }

  private BasicDBObject getPlayedCoursesAssociationAsDocument() {
    BasicDBObject id = new BasicDBObject();
    id.put( "golfPlayer_id", 1L );
    id.put( "table", "GolfPlayer_GolfCourse" );

    BasicDBObject row = new BasicDBObject();
    row.put( "playedCourses_id", 1L );

    BasicDBList rows = new BasicDBList();
    rows.add( row );

    BasicDBObject association = new BasicDBObject();
    association.put( "_id", id );
    association.put( "rows", rows );
    return association;
  }
View Full Code Here

        if ( field == null ) {
          if ( index == size - 1 ) {
            field = value;
          }
          else {
            field = new BasicDBObject();
          }
          parent.put( node, field );
        }
      }
    }
View Full Code Here

    this.dbObject = document;
  }

  //not for embedded
  public DBObject getQueryObject() {
    DBObject query = new BasicDBObject();
    query.put( MongoDBDialect.ID_FIELDNAME, dbObject.get( MongoDBDialect.ID_FIELDNAME ) );
    return query;
  }
View Full Code Here

  protected void addExtraColumn() {
    MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) super.getService( DatastoreProvider.class );
    DB database = provider.getDatabase();
    DBCollection collection = database.getCollection( "Project" );

    BasicDBObject query = new BasicDBObject( 1 );
    query.put( "_id", "projectID" );

    BasicDBObject updater = new BasicDBObject( 1 );
    updater.put( "$push", new BasicDBObject( "extraColumn", 1 ) );
    collection.update( query, updater );
  }
View Full Code Here

  protected void addExtraColumn() {
    MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) super.getService( DatastoreProvider.class );
    DB database = provider.getDatabase();
    DBCollection collection = database.getCollection( "Associations" );

    final BasicDBObject idObject = new BasicDBObject( 2 );
    idObject.append( "Project_id", "projectID" );
    idObject.append( "table", "Project_Module" );

    BasicDBObject query = new BasicDBObject( 1 );
    query.put( "_id", idObject );

    BasicDBObject updater = new BasicDBObject( 1 );
    updater.put( "$push", new BasicDBObject( "extraColumn", 1 ) );
    collection.update( query, updater );
  }
View Full Code Here

  }

  @Test
  public void shouldApplyConfiguredWriteConcernForUpdateOfEmbeddedAssociation() {
    // given a persisted player with one associated golf course
    BasicDBObject player = getPlayer();
    player.put( "playedCourses", getPlayedCoursesAssociationEmbedded() );

    MockMongoClient mockClient = mockClient()
        .insert( "GolfPlayer", player )
        .insert( "GolfCourse", getGolfCourse() )
        .build();
View Full Code Here

  }

  @Test
  public void shouldApplyConfiguredWriteConcernForRemovalOfEmbeddedAssociation() {
    // given a persisted player with one associated golf course
    BasicDBObject player = getPlayer();
    player.put( "playedCourses", getPlayedCoursesAssociationEmbedded() );

    MockMongoClient mockClient = mockClient()
        .insert( "GolfPlayer", player )
        .insert( "GolfCourse", getGolfCourse() )
        .build();
View Full Code Here

    sessions = configuration.buildSessionFactory();
  }

  private BasicDBObject getGolfCourse() {
    BasicDBObject bepplePeach = new BasicDBObject();
    bepplePeach.put( "_id", 1L );
    bepplePeach.put( "name", "Bepple Peach" );
    return bepplePeach;
  }
View Full Code Here

    bepplePeach.put( "name", "Bepple Peach" );
    return bepplePeach;
  }

  private BasicDBObject getPlayer() {
    BasicDBObject golfPlayer = new BasicDBObject();
    golfPlayer.put( "_id", 1L );
    golfPlayer.put( "name", "Ben" );
    golfPlayer.put( "handicap", 0.1 );
    return golfPlayer;
  }
View Full Code Here

TOP

Related Classes of com.mongodb.BasicDBObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.