Package org.hibernate.ogm.dialect.batch.spi

Examples of org.hibernate.ogm.dialect.batch.spi.Operation


  public void executeBatch(OperationsQueue queue) {
    OperationsQueue newQueue = new OperationsQueue();
    StringBuilder sb = new StringBuilder();

    if ( !queue.isClosed() ) {
      Operation operation = queue.poll();
      while ( operation != null ) {
        newQueue.add( operation );

        if ( operation instanceof InsertOrUpdateTupleOperation ) {
          sb.append( "InsertOrUpdateTuple(" ).append( ( (InsertOrUpdateTupleOperation) operation ).getEntityKey() ).append( " )" );
View Full Code Here


  }

  @Override
  public void executeBatch(OperationsQueue queue) {
    if ( !queue.isClosed() ) {
      Operation operation = queue.poll();
      Map<DBCollection, BatchInsertionTask> inserts = new HashMap<DBCollection, BatchInsertionTask>();

      List<MongoDBTupleSnapshot> insertSnapshots = new ArrayList<MongoDBTupleSnapshot>();

      while ( operation != null ) {
        if ( operation instanceof InsertOrUpdateTupleOperation ) {
          InsertOrUpdateTupleOperation update = (InsertOrUpdateTupleOperation) operation;
          executeBatchUpdate( inserts, update );
          MongoDBTupleSnapshot snapshot = (MongoDBTupleSnapshot) update.getTuple().getSnapshot();
          if ( snapshot.getSnapshotType() == INSERT ) {
            insertSnapshots.add( snapshot );
          }
        }
        else if ( operation instanceof RemoveTupleOperation ) {
          RemoveTupleOperation tupleOp = (RemoveTupleOperation) operation;
          executeBatchRemove( inserts, tupleOp );
        }
        else if ( operation instanceof InsertOrUpdateAssociationOperation ) {
          InsertOrUpdateAssociationOperation update = (InsertOrUpdateAssociationOperation) operation;
          insertOrUpdateAssociation( update.getAssociationKey(), update.getAssociation(), update.getContext() );
        }
        else if ( operation instanceof RemoveAssociationOperation ) {
          RemoveAssociationOperation remove = (RemoveAssociationOperation) operation;
          removeAssociation( remove.getAssociationKey(), remove.getContext() );
        }
        else {
          throw new UnsupportedOperationException( "Operation not supported on MongoDB: " + operation.getClass().getName() );
        }
        operation = queue.poll();
      }
      flushInserts( inserts );
View Full Code Here

  }

  @Override
  public void executeBatch(OperationsQueue queue) {
    if ( !queue.isClosed() ) {
      Operation operation = queue.poll();
      Map<DBCollection, BatchInsertionTask> inserts = new HashMap<DBCollection, BatchInsertionTask>();
      while ( operation != null ) {
        if ( operation instanceof UpdateTupleOperation ) {
          UpdateTupleOperation update = (UpdateTupleOperation) operation;
          executeBatchUpdate( inserts, update );
        }
        else if ( operation instanceof RemoveTupleOperation ) {
          RemoveTupleOperation tupleOp = (RemoveTupleOperation) operation;
          executeBatchRemove( inserts, tupleOp );
        }
        else if ( operation instanceof UpdateAssociationOperation ) {
          UpdateAssociationOperation update = (UpdateAssociationOperation) operation;
          insertOrUpdateAssociation( update.getAssociationKey(), update.getAssociation(), update.getContext() );
        }
        else if ( operation instanceof RemoveAssociationOperation ) {
          RemoveAssociationOperation remove = (RemoveAssociationOperation) operation;
          removeAssociation( remove.getAssociationKey(), remove.getContext() );
        }
        else {
          throw new UnsupportedOperationException( "Operation not supported on MongoDB: " + operation.getClass().getName() );
        }
        operation = queue.poll();
      }
      flushInserts( inserts );
      queue.close();
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.dialect.batch.spi.Operation

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.