Package org.hibernate.ogm.grid

Examples of org.hibernate.ogm.grid.EntityKeyMetadata


   *
   * @return the {@link EntityKeyMetadata} of the entity type selected by this query or {@code null} in case this
   * query does not select exactly one entity type (e.g. in case of scalar values or joins (if supported in future revisions)).
   */
  private EntityKeyMetadata getSingleEntityKeyMetadataOrNull(Type[] queryReturnTypes) {
    EntityKeyMetadata metadata = null;

    for ( Type queryReturn : queryReturnTypes ) {
      if ( queryReturn instanceof EntityType ) {
        if ( metadata != null ) {
          return null;
        }
        EntityType rootReturn = (EntityType) queryReturn;
        OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( rootReturn.getName() );
        metadata = new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
      }
    }

    return metadata;
  }
View Full Code Here


    this.monitor = monitor;
  }

  private EntityKeyMetadata getEntityKeyMetadata() {
    OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( indexedType.getName() );
    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }
View Full Code Here

  @Override
  public void run() {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    try {
      final EntityKeyMetadata keyMetadata = getEntityKeyMetadata();
      final SessionAwareRunnable consumer = new TupleIndexer( indexedType, monitor, sessionFactory, searchFactory, cacheMode, batchBackend, errorHandler );
      gridDialect.forEachTuple( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, consumer ), keyMetadata );
    }
    catch ( RuntimeException re ) {
      // being this an async thread we want to make sure everything is somehow reported
View Full Code Here

  private void doAddPropertyMetadata(int tableIndex, int propertyIndex, Object[] newColumnValue) {

    String[] propertyColumnNames = persister.getPropertyColumnNames( propertyIndex );
    String[] rowKeyColumnNames = buildRowKeyColumnNamesForStarToOne( persister, propertyColumnNames );
    String tableName =  persister.getTableName( tableIndex );
    EntityKeyMetadata targetEntityKeyMetadata = persister.createTargetEntityKeyMetadatata( tableName, propertyColumnNames, rowKeyColumnNames );

    AssociationKeyMetadata associationKeyMetadata = new AssociationKeyMetadata(
        tableName,
        propertyColumnNames,
        rowKeyColumnNames,
        EMPTY_STRING_ARRAY,
        targetEntityKeyMetadata,
        targetEntityKeyMetadata.getColumnNames()
    );

    AssociationPersister associationPersister = new AssociationPersister(
          persister.getPropertyTypes()[propertyIndex].getReturnedClass()
        )
View Full Code Here

                    int propertyIndex,
                    Object[] oldColumnValue) {
    String[] propertyColumnNames = persister.getPropertyColumnNames( propertyIndex );
    String[] rowKeyColumnNames = buildRowKeyColumnNamesForStarToOne( persister, propertyColumnNames );
    String tableName =  persister.getTableName( tableIndex );
    EntityKeyMetadata targetEntityKeyMetadata = persister.createTargetEntityKeyMetadatata( tableName, propertyColumnNames, rowKeyColumnNames );

    AssociationKeyMetadata associationKeyMetadata = new AssociationKeyMetadata(
        tableName,
        propertyColumnNames,
        rowKeyColumnNames,
        EMPTY_STRING_ARRAY,
        targetEntityKeyMetadata,
        targetEntityKeyMetadata.getColumnNames()
    );

    AssociationPersister associationPersister = new AssociationPersister(
          persister.getPropertyTypes()[propertyIndex].getReturnedClass()
        )
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

    if ( discriminator.getColumnName() != null ) {
      columnNames.add( discriminator.getColumnName() );
    }
    this.tupleContext = new TupleContext( columnNames, optionsService.context().getEntityOptions( getMappedClass() ) );
    jpaEntityName = persistentClass.getJpaEntityName();
    entityKeyMetadata = new EntityKeyMetadata( getTableName(), getIdentifierColumnNames() );
    //load unique key association key metadata
    associationKeyMetadataPerPropertyName = new HashMap<String,AssociationKeyMetadata>();
    initAssociationKeyMetadata();
    initCustomSQLStrings();
  }
View Full Code Here

      final Type uniqueKeyType = getPropertyTypes()[index];
      if ( uniqueKeyType.isEntityType() ) {
        String[] propertyColumnNames = getPropertyColumnNames( index );
        String[] rowKeyColumnNames = buildRowKeyColumnNamesForStarToOne( this, propertyColumnNames );
        String tableName = getTableName();
        EntityKeyMetadata entityKeyMetadata = createTargetEntityKeyMetadatata( tableName, propertyColumnNames, rowKeyColumnNames );
        AssociationKeyMetadata metadata = new AssociationKeyMetadata(
            tableName,
            propertyColumnNames,
            rowKeyColumnNames,
            ArrayHelper.EMPTY_STRING_ARRAY,
            entityKeyMetadata,
            entityKeyMetadata.getColumnNames()
        );
        associationKeyMetadataPerPropertyName.put( getPropertyNames()[index], metadata );
      }
    }
  }
View Full Code Here

      if ( !contains( associationKeyColumnNames, rowKeyColumnNames[i] ) ) {
        targetColumnList.add( rowKeyColumnNames[i] );
      }
    }
    String[] targetKeyColumnNames = targetColumnList.toArray( new String[targetColumnList.size()] );
    return new EntityKeyMetadata( tableName, targetKeyColumnNames );
  }
View Full Code Here

    this.singleEntityKeyMetadata = determineSingleEntityKeyMetadata( factory, customQueryReturns );
  }

  private static EntityKeyMetadata determineSingleEntityKeyMetadata(SessionFactoryImplementor sessionFactory, List<Return> customQueryReturns) {
    EntityKeyMetadata metadata = null;

    for ( Return queryReturn : customQueryReturns ) {
      if ( queryReturn instanceof RootReturn ) {
        if ( metadata != null ) {
          return null;
        }
        RootReturn rootReturn = (RootReturn) queryReturn;
        OgmEntityPersister persister = (OgmEntityPersister) sessionFactory.getEntityPersister( rootReturn.getEntityName() );
        metadata = new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
      }
    }

    return metadata;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.grid.EntityKeyMetadata

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.