Package org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl

Examples of org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument


    return null;
  }

  @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


    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

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    CouchDBAssociation couchDBAssociation = null;

    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity != null && owningEntity.getProperties().containsKey( key.getCollectionRole() ) ) {
        couchDBAssociation = CouchDBAssociation.fromEmbeddedAssociation( owningEntity, key.getCollectionRole() );
      }
    }
    else {
      AssociationDocument association = getDataStore().getAssociation( Identifier.createAssociationId( key ) );
View Full Code Here

  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    CouchDBAssociation couchDBAssociation = null;

    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity == null ) {
        owningEntity = (EntityDocument) getDataStore().saveDocument( new EntityDocument( key.getEntityKey() ) );
      }

      couchDBAssociation = CouchDBAssociation.fromEmbeddedAssociation( owningEntity, key.getCollectionRole() );
    }
    else {
View Full Code Here

  }

  @Override
  public void removeAssociation(AssociationKey key, AssociationContext associationContext) {
    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity != null ) {
        owningEntity.removeAssociation( key.getCollectionRole() );
        getDataStore().saveDocument( owningEntity );
      }
    }
    else {
      removeDocumentIfPresent( Identifier.createAssociationId( key ) );
View Full Code Here

    return null;
  }

  @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

    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

  @Override
  public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    CouchDBAssociation couchDBAssociation = null;

    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity != null && owningEntity.getProperties().containsKey( key.getCollectionRole() ) ) {
        couchDBAssociation = CouchDBAssociation.fromEmbeddedAssociation( owningEntity, key.getCollectionRole() );
      }
    }
    else {
      AssociationDocument association = getDataStore().getAssociation( Identifier.createAssociationId( key ) );
View Full Code Here

  @Override
  public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    CouchDBAssociation couchDBAssociation = null;

    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity == null ) {
        owningEntity = (EntityDocument) getDataStore().saveDocument( new EntityDocument( key.getEntityKey() ) );
      }

      couchDBAssociation = CouchDBAssociation.fromEmbeddedAssociation( owningEntity, key.getCollectionRole() );
    }
    else {
View Full Code Here

  }

  @Override
  public void removeAssociation(AssociationKey key, AssociationContext associationContext) {
    if ( isStoredInEntityStructure( key, associationContext ) ) {
      EntityDocument owningEntity = getDataStore().getEntity( Identifier.createEntityId( key.getEntityKey() ) );
      if ( owningEntity != null ) {
        owningEntity.removeAssociation( key.getCollectionRole() );
        getDataStore().saveDocument( owningEntity );
      }
    }
    else {
      removeDocumentIfPresent( Identifier.createAssociationId( key ) );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument

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.