Package org.hibernate.ogm.model.spi

Examples of org.hibernate.ogm.model.spi.Tuple


  }

  private List<Object> listOfArrays(SessionImplementor session, Iterator<Tuple> tuples) {
    List<Object> results = new ArrayList<Object>();
    while ( tuples.hasNext() ) {
      Tuple tuple = tuples.next();
      Object[] entry = null;
      if ( !customQuery.getCustomQueryReturns().isEmpty() ) {
        entry = new Object[customQuery.getCustomQueryReturns().size()];
        int i = 0;
        for ( Return queryReturn : customQuery.getCustomQueryReturns() ) {
          ScalarReturn scalarReturn = (ScalarReturn) queryReturn;
          Type type = scalarReturn.getType();

          if ( type != null ) {
            GridType gridType = typeTranslator.getType( type );
            entry[i++] = gridType.nullSafeGet( tuple, scalarReturn.getColumnAlias(), session, null );
          }
          else {
            entry[i++] = tuple.get( scalarReturn.getColumnAlias() );
          }
        }
      }
      else {
        // TODO OGM-564 As a temporary work-around, retrieving the names from the actual result in case there
        // are no query returns defined (no result mapping has been given for a native query). Actually we
        // should drive this based on the selected columns as otherwise the order might not be correct and/or
        // null values will not show up
        entry = new Object[tuple.getColumnNames().size()];
        int i = 0;
        for ( String column : tuple.getColumnNames() ) {
          entry[i++] = tuple.get( column );
        }
      }

      if ( entry.length == 1 ) {
        results.add( entry[0] );
View Full Code Here


    }
    return columnValues;
  }

  public static Object[] getColumnsValuesFromObjectValue(Object uniqueKey, GridType gridUniqueKeyType, String[] propertyColumnNames, SessionImplementor session) {
    Tuple tempResultset = new Tuple();
    gridUniqueKeyType.nullSafeSet( tempResultset, uniqueKey, propertyColumnNames, session) ;
    Object[] columnValuesFromResultset = LogicalPhysicalConverterHelper.getColumnValuesFromResultset( tempResultset, propertyColumnNames );
    return columnValuesFromResultset;
  }
View Full Code Here

    FineGrainedAtomicMap<String, Object> atomicMap = AtomicMapLookup.getFineGrainedAtomicMap( cache, key, false );
    if ( atomicMap == null ) {
      return null;
    }
    else {
      return new Tuple( new InfinispanTupleSnapshot( atomicMap ) );
    }
  }
View Full Code Here

  public Tuple createTuple(EntityKey key, TupleContext tupleContext) {
    //TODO we don't verify that it does not yet exist assuming that this has been done before by the calling code
    //should we improve?
    Cache<EntityKey, Map<String, Object>> cache = provider.getCache( ENTITY_CACHE );
    FineGrainedAtomicMap<String,Object> atomicMap =  AtomicMapLookup.getFineGrainedAtomicMap( cache, key, true );
    return new Tuple( new InfinispanTupleSnapshot( atomicMap ) );
  }
View Full Code Here

  }

  @Override
  public Tuple get(RowKey column) {
    Map<String, Object> rawResult = associationMap.get( column );
    return rawResult != null ? new Tuple( new MapTupleSnapshot( rawResult ) ) : null;
  }
View Full Code Here

    Map<String, Object> entityMap = provider.getEntityTuple( key );
    if ( entityMap == null ) {
      return null;
    }
    else {
      return new Tuple( new MapTupleSnapshot( entityMap ) );
    }
  }
View Full Code Here

  @Override
  public Tuple createTuple(EntityKey key, TupleContext tupleContext) {
    HashMap<String,Object> tuple = new HashMap<String,Object>();
    provider.putEntity( key, tuple );
    return new Tuple( new MapTupleSnapshot( tuple ) );
  }
View Full Code Here

  public void forEachTuple(ModelConsumer consumer, EntityKeyMetadata... metadatas) {
    Map<EntityKey, Map<String, Object>> entityMap = provider.getEntityMap();
    for ( EntityKey key : entityMap.keySet() ) {
      for ( EntityKeyMetadata metadata : metadatas ) {
        if ( key.getTable().equals( metadata.getTable() ) ) {
          consumer.consume( new Tuple( new MapTupleSnapshot( entityMap.get( key ) ) ) );
        }
      }
    }
  }
View Full Code Here

    if ( log.isTraceEnabled() ) {
      log.trace( "Getting current persistent state for: " + MessageHelper.infoString( this, id, getFactory() ) );
    }

    //snapshot is a Map in the end
    final Tuple resultset = getResultsetById( id, session );

    //if there is no resulting row, return null
    if ( resultset == null || resultset.getSnapshot().isEmpty() ) {
      return null;
    }
    //otherwise return the "hydrated" state (ie. associations are not resolved)
    GridType[] types = gridPropertyTypes;
    Object[] values = new Object[types.length];
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

TOP

Related Classes of org.hibernate.ogm.model.spi.Tuple

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.