Package org.hibernate.ogm.datastore.mongodb.dialect.impl

Examples of org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot


    }
    return dbObject;
  }

  private DBObject objectForUpdate(Tuple tuple, EntityKey key, DBObject idObject) {
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tuple.getSnapshot();

    BasicDBObject updater = new BasicDBObject();
    for ( TupleOperation operation : tuple.getOperations() ) {
      String column = operation.getColumn();
      if ( notInIdField( snapshot, column ) ) {
View Full Code Here


  }

  private void executeBatchUpdate(Map<DBCollection, BatchInsertionTask> inserts, UpdateTupleOperation tupleOperation) {
    EntityKey entityKey = tupleOperation.getEntityKey();
    Tuple tuple = tupleOperation.getTuple();
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tupleOperation.getTuple().getSnapshot();
    WriteConcern writeConcern = getWriteConcern( tupleOperation.getTupleContext() );

    if ( INSERT == snapshot.getOperationType() && columnNamesAllowBatchInsert( tupleOperation ) ) {
      prepareForInsert( inserts, snapshot, entityKey, tuple, writeConcern );
    }
    else {
      // Object already exists in the db or has invalid fields:
      updateTuple( tuple, entityKey, tupleOperation.getTupleContext() );
View Full Code Here

          keyMetaData.getTable(),
          keyMetaData.getColumnNames(),
          new Object[] { dbObject.get( MongoDBDialect.ID_FIELDNAME ) }
          );

      return new Tuple( new MongoDBTupleSnapshot( dbObject, rowKey, SnapshotType.SELECT) );
    }
View Full Code Here

    }

    @Override
    public Tuple next() {
      DBObject dbObject = cursor.next();
      return new Tuple( new MongoDBTupleSnapshot( dbObject, metadata ) );
    }
View Full Code Here

  public void forEachTuple(Consumer consumer, EntityKeyMetadata... entityKeyMetadatas) {
    DB db = provider.getDatabase();
    for ( EntityKeyMetadata entityKeyMetadata : entityKeyMetadatas ) {
      DBCollection collection = db.getCollection( entityKeyMetadata.getTable() );
      for ( DBObject dbObject : collection.find() ) {
        consumer.consume( new Tuple( new MongoDBTupleSnapshot( dbObject, entityKeyMetadata) ) );
      }
    }
  }
View Full Code Here

  @Override
  public Tuple getTuple(EntityKey key, TupleContext tupleContext) {
    DBObject found = this.getObject( key, tupleContext );
    if ( found != null ) {
      return new Tuple( new MongoDBTupleSnapshot( found, key, UPDATE ) );
    }
    else if ( isInTheQueue( key, tupleContext ) ) {
      // The key has not been inserted in the db but it is in the queue
      return new Tuple( new MongoDBTupleSnapshot( prepareIdObject( key ), key, INSERT ) );
    }
    else {
      return null;
    }
  }
View Full Code Here

  }

  @Override
  public Tuple createTuple(EntityKey key) {
    DBObject toSave = this.prepareIdObject( key );
    return new Tuple( new MongoDBTupleSnapshot( toSave, key, SnapshotType.INSERT ) );
  }
View Full Code Here

    getCollection( key ).update( idObject, updater, true, false );
  }

  // Creates a dbObject that can be pass to the mongoDB batch insert function
  private DBObject objectForInsert(Tuple tuple, EntityKey key, BasicDBObject dbObject) {
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tuple.getSnapshot();
    for ( TupleOperation operation : tuple.getOperations() ) {
      String column = operation.getColumn();
      if ( notInIdField( snapshot, column ) ) {
        switch ( operation.getType() ) {
          case PUT_NULL:
View Full Code Here

    }
    return dbObject;
  }

  private DBObject objectForUpdate(Tuple tuple, EntityKey key, DBObject idObject) {
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tuple.getSnapshot();

    BasicDBObject updater = new BasicDBObject();
    for ( TupleOperation operation : tuple.getOperations() ) {
      String column = operation.getColumn();
      if ( notInIdField( snapshot, column ) ) {
View Full Code Here

  }

  private void executeBatchUpdate(Map<DBCollection, Map<DBObject, DBObject>> inserts, UpdateTupleOperation tupleOperation) {
    EntityKey entityKey = tupleOperation.getEntityKey();
    Tuple tuple = tupleOperation.getTuple();
    MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) tupleOperation.getTuple().getSnapshot();
    if ( INSERT == snapshot.getOperationType() && columnNamesAllowBatchInsert( tupleOperation ) ) {
      prepareForInsert( inserts, snapshot, entityKey, tuple );
    }
    else {
      // Object already exists in the db or has invalid fields:
      updateTuple( tuple, entityKey );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.datastore.mongodb.dialect.impl.MongoDBTupleSnapshot

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.