Examples of EntityKey


Examples of org.hibernate.ogm.model.key.spi.EntityKey

  }

  @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

Examples of org.hibernate.ogm.model.key.spi.EntityKey

    assertThat( actualIdValue ).isEqualTo( 36 );
  }

  @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() );
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

    assertThat( actualTuple.get( "id" ) ).isEqualTo( createdTuple.get( "id" ) );
  }

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

    dialect.removeTuple( key, emptyTupleContext() );

    assertThat( new CouchDBTestHelper().getNumberOfEntities( datastoreProvider.getDataStore() ) ).isEqualTo( 0 );
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

  }

  @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() );
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

  public void createAssociationShouldCreateAnEmptyAssociation() {
    Object[] columnValues = { "17" };
    String tableName = "user_address";
    String[] columnNames = { "id" };
    String[] rowKeyColumnNames = new String[] { "id" };
    EntityKey entityKey = createEntityKey( "user", new String[] { "id", "age" }, new Object[] { "17", 36 } );
    String collectionRole = "addresses";

    AssociationKey key = createAssociationKey( entityKey, collectionRole, tableName, columnNames, columnValues, rowKeyColumnNames );

    Association createAssociation = dialect.createAssociation( key, emptyAssociationContext() );
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

  @Test
  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
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

    Association actualAssociation = dialect.getAssociation( key, emptyAssociationContext() );
    assertThat( actualAssociation.get( rowKey ).hashCode() ).isNotNull();
  }

  private EntityKey createEntityKey(String tableName, String[] columnNames, Object[] values) {
    return new EntityKey( new EntityKeyMetadata( tableName, columnNames ), values );
  }
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

        .build();

    AssociationKey associationKey = new AssociationKey(
        metadata,
        new Object[] { "projectID" },
        new EntityKey(
            new EntityKeyMetadata( "Project", new String[] { "id" } ),
            new String[] { "projectID" }
        )
    );
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

    session.delete( hibernateOGM );
    session.close();
  }

  private Tuple getTuple(String collectionName, String id, List<String> selectedColumns) {
    EntityKey key = new EntityKey(
        new EntityKeyMetadata( collectionName, new String[] { MongoDBDialect.ID_FIELDNAME } ),
        new Object[] { id }
    );
    TupleContext tupleContext = new TupleContextImpl(
        selectedColumns,
View Full Code Here

Examples of org.hibernate.ogm.model.key.spi.EntityKey

    //TODO this if won't work when we will support collections inside the entity tuple but that will do for now
    final TupleAsMapResultSet resultset = new TupleAsMapResultSet();
    if ( getEntityPersisters().length > 0 ) {
      OgmEntityPersister persister = getEntityPersisters()[0];
      final EntityKey key = EntityKeyBuilder.fromPersister( persister, id, session );
      Tuple entry = gridDialect.getTuple( key, persister.getTupleContext() );
      if ( entry != null ) {
        resultset.addTuple( entry );
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.