Package org.hibernate.ogm.type

Examples of org.hibernate.ogm.type.GridType


    return gridValue;
  }

  private Object convertToGridType(Object value, Type propertyType) {
    Tuple dummy = new Tuple();
    GridType gridType = typeTranslator().getType( propertyType );
    gridType.nullSafeSet( dummy, value, new String[] { "key" }, null );
    return dummy.get( "key" );
  }
View Full Code Here


    }
    else {
      if (optionalId == null) {
        final OgmEntityPersister currentPersister = entityPersisters[0];
        Tuple tuple =  ogmLoadingContext.getResultSet().getTuple();
        GridType gridIdentifierType = currentPersister.getGridIdentifierType();
        optionalId = (Serializable) gridIdentifierType.nullSafeGet( tuple, currentPersister.getIdentifierColumnNames(), session, null );
      }
      final org.hibernate.engine.spi.EntityKey key = session.generateEntityKey( optionalId,  entityPersisters[0] );
      keys[0] = key;
    }
  }
View Full Code Here

      String propertyName,
      Object uniqueKey,
      SessionImplementor session) throws HibernateException {
    //we get the property type for an associated entity
    final int propertyIndex = getPropertyIndex( propertyName );
    final GridType gridUniqueKeyType = getUniqueKeyTypeFromAssociatedEntity( propertyIndex, propertyName );
    //get the associated property index (to get its column names)
    //find the ids per unique property name
    AssociationKeyMetadata associationKeyMetadata = associationKeyMetadataPerPropertyName.get( propertyName );
    if ( associationKeyMetadata == null ) {
      throw new AssertionFailure( "loadByUniqueKey on a non EntityType:" + propertyName );
View Full Code Here

              + " value: " + uniqueKey );
    }
  }

  private GridType getUniqueKeyTypeFromAssociatedEntity(int propertyIndex, String propertyName) {
    GridType gridUniqueKeyType;//get the unique key type and if it's an entity type, get it's identifier type
    final Type uniqueKeyType = getPropertyTypes()[propertyIndex];
    if ( uniqueKeyType.isEntityType() ) {
      //we run under the assumption that we are fully in an OGM world
      EntityType entityType = (EntityType) uniqueKeyType;
      final OgmEntityPersister entityPersister = (OgmEntityPersister) entityType.getAssociatedJoinable( getFactory() );
View Full Code Here

          for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
            boolean include = includeOldField[i] &&
                isPropertyOfTable( i, j ) &&
                versionability[i]; //TODO: is this really necessary????
            if ( include ) {
              final GridType type = types[i];
              //FIXME what do do with settable?
              boolean[] settable = type.toColumnNullness( oldFields[i], factory );
              final Object snapshotValue = type.nullSafeGet(
                  resultset, getPropertyColumnNames( i ), session, object
              );
              comparePropertyAndRaiseSOSE(
                  id,
                  oldFields[i],
                  factory,
                  !type.isEqual( oldFields, snapshotValue, factory )
              );

            }
          }
        }
View Full Code Here

        GridType[] types = gridPropertyTypes;

        for ( int i = 0; i < entityMetamodel.getPropertySpan(); i++ ) {
          boolean include = isPropertyOfTable( i, j ) && versionability[i];
          if ( include ) {
            final GridType type = types[i];
            final Object snapshotValue = type.nullSafeGet(
                resultset, getPropertyColumnNames( i ), session, object
            );
            //TODO support other entity modes
            if ( ! type.isEqual( loadedState[i], snapshotValue, factory ) ) {
              if ( factory.getStatistics().isStatisticsEnabled() ) {
                factory.getStatisticsImplementor()
                    .optimisticFailure( getEntityName() );
              }
              throw new StaleObjectStateException( getEntityName(), id );
View Full Code Here

      return null;
    }

    //TODO should we cache results? It seems an actual HashMap might be slower but it makes it more robust
    //     against badly written dialects
    GridType dialectType = dialect.overrideType( type );
    if ( dialectType != null ) {
      return dialectType;
    }
    else if ( type instanceof AbstractStandardBasicType ) {
      AbstractStandardBasicType<?> exposedType = (AbstractStandardBasicType<?>) type;
      final GridType gridType = typeConverter.get( exposedType.getJavaTypeDescriptor() );
      if (gridType == null) {
        throw log.unableToFindGridType( exposedType.getJavaTypeDescriptor().getJavaTypeClass().getName() );
      }
      return gridType;
    }
View Full Code Here

      associationPersister.flushToCache();
    }
  }

  private Object getReferencedEntity(int propertyIndex) {
    GridType propertyType = gridPropertyTypes[propertyIndex];
    Serializable id = (Serializable) propertyType.hydrate(
        resultset, persister.getPropertyColumnNames( propertyIndex ), session, null
    );

    if ( id != null ) {
      EntityPersister hostingEntityPersister = session.getFactory().getEntityPersister(
          propertyType.getReturnedClass().getName()
      );

      return session.getPersistenceContext().getEntity(
          session.generateEntityKey( id, hostingEntityPersister )
      );
View Full Code Here

  public Object loadByUniqueKey(
      String propertyName,
      Object uniqueKey,
      SessionImplementor session) throws HibernateException {
    //we get the property type for an associated entity
    final GridType gridUniqueKeyType = getUniqueKeyTypeFromAssociatedEntity( propertyName );
    //get the associated property index (to get its column names)
    final int propertyIndex = getPropertyIndex( propertyName );
    //find the ids per unique property name
    PropertyMetadataProvider metadataProvider = new PropertyMetadataProvider()
        .tableName( getTableName() )
View Full Code Here

              + " value: " + uniqueKey );
    }
  }

  private GridType getUniqueKeyTypeFromAssociatedEntity(String propertyName) {
    GridType gridUniqueKeyType;//get the unique key type and if it's an entity type, get it's identifier type
    final Type uniqueKeyType = propertyMapping.toType( propertyName );
    if ( uniqueKeyType.isEntityType() ) {
      String className = ( ( EntityType ) uniqueKeyType ).getAssociatedEntityName();
      //we run under the assumption that we are fully in an OGM world
      final OgmEntityPersister entityPersister = (OgmEntityPersister) getFactory().getEntityPersister( className );
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.type.GridType

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.