Package org.hibernate.ogm.model.spi

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


    Contracts.assertParameterNotNull( relationshipType, "relationshipType" );

    for ( Relationship relationship : relationships( ownerNode, associationKey, relationshipType ) ) {
      Neo4jTupleAssociationSnapshot snapshot = new Neo4jTupleAssociationSnapshot( relationship, associationKey, associatedEntityKeyMetadata );
      RowKey rowKey = convert( associationKey, snapshot );
      tuples.put( rowKey, new Tuple( snapshot ) );
    }
  }
View Full Code Here


    }
  }

  @Override
  public Tuple get(RowKey rowKey) {
    Tuple tuple = tuples.get( rowKey );
    return tuple;
  }
View Full Code Here

  public Tuple next() {
    return convert( iterator.next() );
  }

  protected Tuple convert(Map<String, Object> next) {
    return new Tuple( new MapTupleSnapshot( next ) );
  }
View Full Code Here

  @Override
  public Tuple getTuple(EntityKey key, TupleContext tupleContext) {
    EntityDocument entity = getDataStore().getEntity( Identifier.createEntityId( key ) );
    if ( entity != null ) {
      return new Tuple( new CouchDBTupleSnapshot( entity.getProperties() ) );
    }

    return null;
  }
View Full Code Here

    return null;
  }

  @Override
  public Tuple createTuple(EntityKey key, TupleContext tupleContext) {
    return new Tuple( new CouchDBTupleSnapshot( key ) );
  }
View Full Code Here

  private List<Object> getAssociationRows(Association association, AssociationKey associationKey) {
    List<Object> rows = new ArrayList<Object>();

    for ( RowKey rowKey : association.getKeys() ) {
      Tuple tuple = association.get( rowKey );

      String[] columnsToPersist = associationKey.getMetadata().getColumnsWithoutKeyColumns( tuple.getColumnNames() );

      // return value itself if there is only a single column to store
      if ( columnsToPersist.length == 1 ) {
        Object row = tuple.get( columnsToPersist[0] );
        rows.add( row );
      }
      else {
        Map<String, Object> row = new HashMap<String, Object>( columnsToPersist.length );
        for ( String columnName : columnsToPersist ) {
          row.put( columnName, tuple.get( columnName ) );
        }

        rows.add( row );
      }
    }
View Full Code Here

  @Test
  public void createTupleShouldReturnANewTuple() {

    EntityKey key = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    Tuple createdTuple = dialect.createTuple( key, emptyTupleContext() );

    int actualIdValue = (Integer) createdTuple.get( "age" );
    assertThat( actualIdValue ).isEqualTo( 36 );
  }
View Full Code Here

  }

  @Test
  public void getTupleShouldReturnTheSearchedOne() {
    EntityKey key = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    Tuple createdTuple = dialect.createTuple( key, emptyTupleContext() );

    dialect.insertOrUpdateTuple( key, createdTuple, emptyTupleContext() );

    Tuple actualTuple = dialect.getTuple( key, emptyTupleContext() );

    assertThat( actualTuple.get( "id" ) ).isEqualTo( createdTuple.get( "id" ) );
  }
View Full Code Here

  @Test
  public void updateTupleShouldAddTheNewColumnValue() {

    EntityKey key = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    Tuple createdTuple = dialect.createTuple( key, emptyTupleContext() );
    createdTuple.put( "name", "and" );

    dialect.insertOrUpdateTuple( key, createdTuple, emptyTupleContext() );

    Tuple tuple = dialect.getTuple( key, emptyTupleContext() );
    assertThat( (String) tuple.get( "name" ) ).isEqualTo( "and" );
  }
View Full Code Here

  public void updateAnAssociationShouldAddATuple() {
    String tableName = "user_address";
    String[] rowKeyColumnNames = new String[] { "user_id", "addresses_id" };
    Object[] rowKeyColumnValues = new Object[] { "Emmanuel", 1 };
    EntityKey entityKey = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    Tuple tuple = dialect.createTuple( entityKey, emptyTupleContext() );
    dialect.insertOrUpdateTuple( entityKey, tuple, emptyTupleContext() );

    AssociationKey key = createAssociationKey(
        entityKey, "addresses", "user_address", new String[] { "user_id" }, new Object[] { "Emmanuel" }, rowKeyColumnNames
    );
    Association createAssociation = dialect.createAssociation( key, emptyAssociationContext() );

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "user_id", "Emmanuel" );
    properties.put( "addresses_id", 1 );
    Tuple associationTuple = new Tuple( new CouchDBTupleSnapshot( properties ) );

    RowKey rowKey = new RowKey( rowKeyColumnNames, rowKeyColumnValues );
    createAssociation.put( rowKey, associationTuple );
    dialect.insertOrUpdateAssociation( key, createAssociation, emptyAssociationContext() );
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.