Package org.hibernate.ogm.model.key.spi

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


    Assertions.assertThat( 1 ).isEqualTo( queue.size() );
  }

  private EntityKey entityKey() {
    EntityKeyMetadata keyMetadata = new EntityKeyMetadata( "MetadataTable", new String[] {} );
    EntityKey key = new EntityKey( keyMetadata, new Object[] {} );
    return key;
  }
View Full Code Here


        throw new AssertionFailure( "Unrecognized associationKind: " + associationKey.getMetadata().getAssociationKind() );
    }
  }

  private Relationship createRelationshipWithEmbeddedNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey entityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node embeddedNode = entityQueries.get( entityKey.getMetadata() ).createEmbedded( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = createRelationshipWithTargetNode( associationKey, associationRow, embeddedNode );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }

  private Relationship findOrCreateRelationshipWithEntityNode(AssociationKey associationKey, Tuple associationRow, AssociatedEntityKeyMetadata associatedEntityKeyMetadata) {
    EntityKey targetEntityKey = getEntityKey( associationRow, associatedEntityKeyMetadata );
    Node targetNode = entityQueries.get( targetEntityKey.getMetadata() ).findEntity( executionEngine, targetEntityKey.getColumnValues() );
    return createRelationshipWithTargetNode( associationKey, associationRow, targetNode );
  }
View Full Code Here

      relationship.setProperty( propertyName, propertyValue );
    }
  }

  private Relationship createRelationshipWithTargetNode(AssociationKey associationKey, Tuple associationRow, Node targetNode) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node ownerNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    Relationship relationship = ownerNode.createRelationshipTo( targetNode, withName( associationKey.getMetadata().getCollectionRole() ) );
    applyProperties( associationKey, associationRow, relationship );
    return relationship;
  }
View Full Code Here

    return relationship;
  }

  @Override
  public Association getAssociation(AssociationKey associationKey, AssociationContext associationContext) {
    EntityKey entityKey = associationKey.getEntityKey();
    Node entityNode = entityQueries.get( entityKey.getMetadata() ).findEntity( executionEngine, entityKey.getColumnValues() );
    GraphLogger.log( "Found owner node: %1$s", entityNode );
    if ( entityNode == null ) {
      return null;
    }
    return new Association(
View Full Code Here

      String associationRole = tupleContext.getRole( operation.getColumn() );

      if ( !processedAssociationRoles.contains( associationRole ) ) {
        processedAssociationRoles.add( associationRole );

        EntityKey targetKey = getEntityKey( tuple, tupleContext.getAssociatedEntityKeyMetadata( operation.getColumn() ) );

        // delete the previous relationship if there is one; for a to-one association, the relationship won't have any
        // properties, so the type is uniquely identifying it
        Iterator<Relationship> relationships = node.getRelationships( withName( associationRole ) ).iterator();
        if ( relationships.hasNext() ) {
          relationships.next().delete();
        }

        // create a new relationship
        Node targetNode = entityQueries.get( targetKey.getMetadata() ).findEntity( executionEngine, targetKey.getColumnValues() );
        node.createRelationshipTo( targetNode, withName( associationRole ) );
      }
    }
  }
View Full Code Here

    for ( String associationKeyColumn : associatedEntityKeyMetadata.getAssociationKeyColumns() ) {
      columnValues[i] = tuple.get( associationKeyColumn );
      i++;
    }

    return new EntityKey( associatedEntityKeyMetadata.getEntityKeyMetadata(), columnValues );
  }
View Full Code Here

      queue.close();
    }
  }

  private void executeBatchRemove(Map<DBCollection, BatchInsertionTask> inserts, RemoveTupleOperation tupleOperation) {
    EntityKey entityKey = tupleOperation.getEntityKey();
    DBCollection collection = getCollection( entityKey );
    BatchInsertionTask batchedInserts = inserts.get( collection );

    if ( batchedInserts != null && batchedInserts.containsKey( entityKey ) ) {
      batchedInserts.remove( entityKey );
View Full Code Here

      removeTuple( entityKey, tupleOperation.getTupleContext() );
    }
  }

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

    if ( INSERT == snapshot.getOperationType() && columnNamesAllowBatchInsert( tupleOperation ) ) {
View Full Code Here

  @Override
  public void lock(Serializable id, Object version, Object object, int timeout, SessionImplementor session)
      throws StaleObjectStateException, JDBCException {
    AdvancedCache advCache = getProvider( session ).getCache( ENTITY_STORE ).getAdvancedCache();
    EntityKey key = EntityKeyBuilder.fromData(
        ( (OgmEntityPersister) lockable).getRootEntityKeyMetadata(),
        identifierGridType,
        id,
        session );
    advCache.lock( key );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.model.key.spi.EntityKey

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.