Package org.hibernate.ogm.model.spi

Examples of org.hibernate.ogm.model.spi.Tuple


    return queue != null && queue.contains( key );
  }

  @Override
  public Tuple createTuple(EntityKeyMetadata entityKeyMetadata, TupleContext tupleContext) {
    return new Tuple( new MongoDBTupleSnapshot( new BasicDBObject(), entityKeyMetadata, SnapshotType.INSERT ) );
  }
View Full Code Here


  }

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

  public void forEachTuple(ModelConsumer 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, UPDATE ) ) );
      }
    }
  }
View Full Code Here

  }

  private ClosableIterator<Tuple> doCount(MongoDBQueryDescriptor query, DBCollection collection) {
    long count = collection.count( query.getCriteria() );
    MapTupleSnapshot snapshot = new MapTupleSnapshot( Collections.<String, Object>singletonMap( "n", count ) );
    return CollectionHelper.newClosableIterator( Collections.singletonList( new Tuple( snapshot ) ) );
  }
View Full Code Here

    }
  }

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

    if ( INSERT == snapshot.getSnapshotType() ) {
      prepareForInsert( inserts, snapshot, entityKey, tuple, writeConcern );
View Full Code Here

  private void addNavigationalInformationForInverseSide(int propertyIndex, AssociationKeyMetadata associationKeyMetadata, Object[] newColumnValue) {
    AssociationPersister associationPersister = createAssociationPersister( propertyIndex, associationKeyMetadata, newColumnValue );

    RowKey rowKey = getInverseRowKey( associationKeyMetadata, newColumnValue );

    Tuple associationRow = new Tuple();
    for ( String column : rowKey.getColumnNames() ) {
      associationRow.put( column, rowKey.getColumnValue( column ) );
    }
    associationPersister.getAssociation().put( rowKey, associationRow );

    associationPersister.flushToDatastore();
  }
View Full Code Here

   * @param associationKeyMetadata meta-data for the inverse association of interest
   * @param associationColumnValues the column values identifying the entity on the inverse side of the association
   * @return the row key of the inverse association
   */
  private RowKey getInverseRowKey(AssociationKeyMetadata associationKeyMetadata, Object[] associationColumnValues) {
    Tuple rowKeyValues = new Tuple();

    // add the fk column
    for (int index = 0 ; index < associationKeyMetadata.getColumnNames().length ; index++) {
      rowKeyValues.put( associationKeyMetadata.getColumnNames()[index], associationColumnValues[index] );
    }

    // add the id column
    persister.getGridIdentifierType().nullSafeSet( rowKeyValues, id, persister.getIdentifierColumnNames(), session );

View Full Code Here

  // At the moment we only support the case where one entity type is returned
  private List<Object> listOfEntities(SessionImplementor session, Type[] resultTypes, ClosableIterator<Tuple> tuples) {
    List<Object> results = new ArrayList<Object>();
    Class<?> returnedClass = resultTypes[0].getReturnedClass();
    while ( tuples.hasNext() ) {
      Tuple tuple = tuples.next();
      OgmLoader loader = createLoader( session, returnedClass );
      results.add( entity( session, tuple, loader ) );
    }
    return results;
  }
View Full Code Here

  // At the moment we only support the case where one entity type is returned
  private List<Object> listOfEntities(SessionImplementor session, Type[] resultTypes, ClosableIterator<Tuple> tuples) {
    List<Object> results = new ArrayList<Object>();
    Class<?> returnedClass = resultTypes[0].getReturnedClass();
    while ( tuples.hasNext() ) {
      Tuple tuple = tuples.next();
      OgmLoader loader = createLoader( session, returnedClass );
      results.add( entity( session, tuple, loader ) );
    }
    return results;
  }
View Full Code Here

  }

  private List<Object> listOfArrays(SessionImplementor session, Iterator<Tuple> tuples) {
    List<Object> results = new ArrayList<Object>();
    while ( tuples.hasNext() ) {
      Tuple tuple = tuples.next();
      Object[] entry = new Object[queryReturnTypes.length];

      int i = 0;
      for ( Type type : queryReturnTypes ) {
        GridType gridType = typeTranslator.getType( type );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.spi.Tuple

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.