Package org.hibernate.ogm.grid

Examples of org.hibernate.ogm.grid.EntityKey


  }

  @Override
  public void lock(Serializable id, Object version, Object object, int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException {
    MapDatastoreProvider dataStore = getProvider( session );
    EntityKey key = EntityKeyBuilder.fromData(
        lockable.getRootTableName(),
        lockable.getRootTableIdentifierColumnNames(),
        identifierGridType,
        id,
        session );
View Full Code Here


   * @param associationKey identify the type of the relationship
   * @param rowKey identify the relationship
   * @return the corresponding relationship
   */
  public Relationship findRelationship(AssociationKey associationKey, RowKey rowKey) {
    EntityKey targetKey = rowKey.getEntityKey();
    EntityKey entityKey = associationKey.getEntityKey();
    Map<String, Object> parameters = new HashMap<String, Object>();
    StringBuilder query = new StringBuilder( "MATCH" );
    appendNodePattern( "o", entityKey, parameters, query, ENTITY );
    query.append( " - " );
    query.append( relationshipCypher( associationKey, rowKey, parameters ) );
View Full Code Here

   * MATCH (n) - [r:collectionRole { 'rowkey_column_name': {0}}] - (x:EMBEDDED)
   * DELETE r, x
   * </pre>
   */
  public void remove(AssociationKey associationKey, RowKey rowKey) {
    EntityKey targetKey = rowKey.getEntityKey();
    Map<String, Object> parameters = new HashMap<String, Object>();
    StringBuilder query = new StringBuilder( "MATCH " );
    appendNodePattern( associationKey.getEntityKey(), parameters, query, ENTITY );
    query.append( " - ");
    query.append( relationshipCypher( associationKey, rowKey, parameters ) );
View Full Code Here

  private TupleAsMapResultSet getResultSet(Serializable id, SessionImplementor session) {
    //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

    if ( collectionMetadataKey == null ) {
      final Object[] columnValues = getKeyColumnValues();
      collectionMetadataKey = new AssociationKey( tableName, keyColumnNames, columnValues );
      // We have a collection on the main side
      if (collectionPersister != null) {
        EntityKey entityKey;
        // we are explicitly looking to update the non owning side
        if ( inverse ) {
          //look for the other side of the collection, build the key of the other side's entity
          OgmEntityPersister elementPersister = (OgmEntityPersister) collectionPersister.getElementPersister();
          entityKey = EntityKeyBuilder.fromPersister(
              elementPersister,
              (Serializable) key,
              session
          );
          collectionMetadataKey.setCollectionRole( buildCollectionRole(collectionPersister) );
        }
        else {
          //we are on the right side, use the association property
          collectionMetadataKey.setCollectionRole( getUnqualifiedRole( collectionPersister ) );
          entityKey = EntityKeyBuilder.fromPersister(
              (OgmEntityPersister) collectionPersister.getOwnerEntityPersister(),
              (Serializable) key,
              session
          );
        }
        collectionMetadataKey.setOwnerEntityKey( entityKey );
        //TODO add information on the collection type, set, map, bag, list etc

        AssociationKind type = collectionPersister.getElementType().isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED;
        collectionMetadataKey.setAssociationKind( type );
        collectionMetadataKey.setRowKeyColumnNames( collectionPersister.getRowKeyColumnNames() );
      }
      // We have a to-one on the main side
      else if ( propertyType != null ) {
        collectionMetadataKey.setAssociationKind( propertyType.isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED );
        if ( propertyType instanceof EntityType ) {
          EntityType entityType = (EntityType) propertyType;
          OgmEntityPersister associatedPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( session.getFactory() );
          EntityKey entityKey = new EntityKey(
              associatedPersister.getTableName(),
              associatedPersister.getIdentifierColumnNames(),
              columnValues
          );
          collectionMetadataKey.setOwnerEntityKey( entityKey );
View Full Code Here

  }

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

  }

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

    }
    return values;
  }

  private Tuple getResultsetById(Serializable id, SessionImplementor session) {
    final EntityKey key = EntityKeyBuilder.fromPersister( this, id, session );
    final Tuple resultset = gridDialect.getTuple( key, this.getTupleContext() );
    return resultset;
  }
View Full Code Here

    /*
     * We get the value from the grid and compare the version values before putting the next version in
     * Contrary to the database version, there is
     * TODO should we use cache.replace() it seems more expensive to pass the resultset around "just" the atomicity of the operation
     */
    final EntityKey key = EntityKeyBuilder.fromPersister( this, id, session );
    final Tuple resultset = gridDialect.getTuple( key, getTupleContext() );
    checkVersionAndRaiseSOSE( id, currentVersion, session, resultset );
    gridVersionType.nullSafeSet( resultset, nextVersion, new String[] { getVersionColumnName() }, session );
    gridDialect.updateTuple( resultset, key, getTupleContext() );
    return nextVersion;
View Full Code Here

    }

    for ( int j = 0; j < span; j++ ) {
      // Now update only the tables with dirty properties (and the table with the version number)
      if ( tableUpdateNeeded[j] ) {
        final EntityKey key = EntityKeyBuilder.fromPersister( this, id, session );
        Tuple resultset = gridDialect.getTuple( key, this.getTupleContext() );
        final boolean useVersion = j == 0 && isVersioned();

        resultset = createNewResultSetIfNull( key, resultset, id, session );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.grid.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.