Package org.hibernate.ogm.datastore.couchdb.dialect.model.impl

Examples of org.hibernate.ogm.datastore.couchdb.dialect.model.impl.CouchDBTupleSnapshot


  @Override
  public Map<String, Object> extractEntityTuple(SessionFactory sessionFactory, EntityKey key) {
    Map<String, Object> tupleMap = new HashMap<String, Object>();
    CouchDBDatastore dataStore = getDataStore( sessionFactory );
    EntityDocument entity = dataStore.getEntity( Identifier.createEntityId( key ) );
    CouchDBTupleSnapshot snapshot = new CouchDBTupleSnapshot( entity.getProperties() );
    Set<String> columnNames = snapshot.getColumnNames();
    for ( String columnName : columnNames ) {
      tupleMap.put( columnName, snapshot.get( columnName ) );
    }
    return tupleMap;
  }
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

    return new Tuple( new CouchDBTupleSnapshot( key ) );
  }

  @Override
  public void insertOrUpdateTuple(EntityKey key, Tuple tuple, TupleContext tupleContext) {
    CouchDBTupleSnapshot snapshot = (CouchDBTupleSnapshot) tuple.getSnapshot();

    String revision = (String) snapshot.get( Document.REVISION_FIELD_NAME );

    // load the latest revision for updates without the revision being present; a warning about
    // this mapping will have been issued at factory start-up
    if ( revision == null && !snapshot.isCreatedOnInsert() ) {
      revision = getDataStore().getCurrentRevision( Identifier.createEntityId( key ), false );
    }

    // this will raise an optimistic locking exception if the revision is either null or not the current one
    getDataStore().saveDocument( new EntityDocument( key, revision, tuple ) );
View Full Code Here

    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

  @JsonIgnore
  public List<Tuple> getTuples() {
    List<Tuple> tuples = new ArrayList<Tuple>( rows.size() );
    if ( rows.size() > 0 ) {
      for ( Row row : rows ) {
        tuples.add( new Tuple( new CouchDBTupleSnapshot( row.getValue().getProperties() ) ) );
      }
    }
    return tuples;
  }
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

    return new Tuple( new CouchDBTupleSnapshot( key ) );
  }

  @Override
  public void updateTuple(Tuple tuple, EntityKey key, TupleContext tupleContext) {
    CouchDBTupleSnapshot snapshot = (CouchDBTupleSnapshot) tuple.getSnapshot();

    String revision = (String) snapshot.get( Document.REVISION_FIELD_NAME );

    // load the latest revision for updates without the revision being present; a warning about
    // this mapping will have been issued at factory start-up
    if ( revision == null && !snapshot.isCreatedOnInsert() ) {
      revision = getDataStore().getCurrentRevision( Identifier.createEntityId( key ), false );
    }

    // this will raise an optimistic locking exception if the revision is either null or not the current one
    getDataStore().saveDocument( new EntityDocument( key, revision, tuple ) );
View Full Code Here

  @JsonIgnore
  public List<Tuple> getTuples() {
    List<Tuple> tuples = new ArrayList<Tuple>( rows.size() );
    if ( rows.size() > 0 ) {
      for ( Row row : rows ) {
        tuples.add( new Tuple( new CouchDBTupleSnapshot( row.getValue().getProperties() ) ) );
      }
    }
    return tuples;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.datastore.couchdb.dialect.model.impl.CouchDBTupleSnapshot

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.