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(
        ( (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

              propertyColumnNames,
              includeColumns[propertyIndex],
              session
          );
    Object[] columnValues = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( tuple, rowKeyColumnNames );
    EntityKey targetKey = associationPersister.createTargetKey( rowKeyColumnNames, columnValues );
    final RowKey rowKey = new RowKey( persister.getTableName(), rowKeyColumnNames, columnValues, targetKey );

    Tuple assocEntryTuple = associationPersister.createAndPutAssociationTuple( rowKey );
    for ( String column : tuple.getColumnNames() ) {
      assocEntryTuple.put( column, tuple.get( column ) );
View Full Code Here

  private AssociationKey getAssociationKey() {
    if ( associationKey == null ) {
      final Object[] columnValues = getKeyColumnValues();
      String collectionRole = null;
      EntityKey ownerEntityKey = null;
      AssociationKind associationKind = null;

      // 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
          );
          collectionRole = buildCollectionRole( collectionPersister );
        }
        else {
          //we are on the right side, use the association property
          collectionRole = getUnqualifiedRole( collectionPersister );
          entityKey = EntityKeyBuilder.fromPersister(
              (OgmEntityPersister) collectionPersister.getOwnerEntityPersister(),
              (Serializable) key,
              session
          );
        }
        ownerEntityKey = entityKey;
        //TODO add information on the collection type, set, map, bag, list etc

        AssociationKind type = collectionPersister.getElementType().isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED_COLLECTION;
        associationKind = type;
      }
      // We have a to-one on the main side
      else if ( propertyType != null ) {
        associationKind = propertyType.isEntityType() ? AssociationKind.ASSOCIATION : AssociationKind.EMBEDDED_COLLECTION;
        if ( propertyType instanceof EntityType ) {
          EntityType entityType = (EntityType) propertyType;
          OgmEntityPersister associatedPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( session.getFactory() );
          EntityKey entityKey = new EntityKey(
              associatedPersister.getEntityKeyMetadata(),
              columnValues
          );
          ownerEntityKey = entityKey;
          collectionRole = getCollectionRoleFromToOne( associatedPersister );
View Full Code Here

    return AssociationKind.EMBEDDED_COLLECTION == associationKey.getAssociationKind()
        && associationKey.getMetadata().getRowKeyIndexColumnNames().length > 0;
  }

  private static EntityKey targeKeyForEmbeddedWithIndex(AssociationKey associationKey) {
    return new EntityKey( new EntityKeyMetadata( associationKey.getTable(), ArrayHelper.EMPTY_STRING_ARRAY ), ArrayHelper.EMPTY_OBJECT_ARRAY );
  }
View Full Code Here

        // The RowKey does not contain the value of the target side of the association, it means we are on the
        // owner side.
        return null;
      }
    }
    return new EntityKey( associationKey.getMetadata().getRowKeyEntityKeyMetadata(), targetKeyColumnValues );
  }
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

        if ( j == 0 && isVersioned() ) {
          log.trace( "Version: " + Versioning.getVersion( fields, this ) );
        }
      }

      final EntityKey key = EntityKeyBuilder.fromPersister( this, id, session );
      Tuple resultset = gridDialect.getTuple( key, this.getTupleContext() );
      // add the discriminator
      if ( j == 0 ) {
        if (resultset != null) {
          throw new HibernateException( "trying to insert an already existing entity: "
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.