Package org.hibernate.engine

Examples of org.hibernate.engine.EntityKey


    final Object optionalObject = queryParameters.getOptionalObject();
    final Serializable optionalId = queryParameters.getOptionalId();
    final String optionalEntityName = queryParameters.getOptionalEntityName();

    if ( optionalObject != null && optionalEntityName != null ) {
      return new EntityKey(
          optionalId,
          session.getEntityPersister( optionalEntityName, optionalObject ),
          session.getEntityMode()
        );
    }
View Full Code Here


    final int entitySpan = persisters.length;

    final int numberOfPersistersToProcess;
    final Serializable optionalId = queryParameters.getOptionalId();
    if ( isSingleRowLoader() && optionalId != null ) {
      keys[ entitySpan - 1 ] = new EntityKey( optionalId, persisters[ entitySpan - 1 ], session.getEntityMode() );
      // skip the last persister below...
      numberOfPersistersToProcess = entitySpan - 1;
    }
    else {
      numberOfPersistersToProcess = entitySpan;
    }

    final Object[] hydratedKeyState = new Object[numberOfPersistersToProcess];

    for ( int i = 0; i < numberOfPersistersToProcess; i++ ) {
      final Type idType = persisters[i].getIdentifierType();
      hydratedKeyState[i] = idType.hydrate( resultSet, getEntityAliases()[i].getSuffixedKeyAliases(), session, null );
    }

    for ( int i = 0; i < numberOfPersistersToProcess; i++ ) {
      final Type idType = persisters[i].getIdentifierType();
      if ( idType.isComponentType() && getCompositeKeyManyToOneTargetIndices() != null ) {
        // we may need to force resolve any key-many-to-one(s)
        int[] keyManyToOneTargetIndices = getCompositeKeyManyToOneTargetIndices()[i];
        // todo : better solution is to order the index processing based on target indices
        //    that would account for multiple levels whereas this scheme does not
        if ( keyManyToOneTargetIndices != null ) {
          for ( int targetIndex : keyManyToOneTargetIndices ) {
            if ( targetIndex < numberOfPersistersToProcess ) {
              final Type targetIdType = persisters[targetIndex].getIdentifierType();
              final Serializable targetId = (Serializable) targetIdType.resolve(
                  hydratedKeyState[targetIndex],
                  session,
                  null
              );
              // todo : need a way to signal that this key is resolved and its data resolved
              keys[targetIndex] = new EntityKey( targetId, persisters[targetIndex], session.getEntityMode() );
            }

            // this part copied from #getRow, this section could be refactored out
            Object object = session.getEntityUsingInterceptor( keys[targetIndex] );
            if ( object != null ) {
              //its already loaded so don't need to hydrate it
              instanceAlreadyLoaded(
                  resultSet,
                  targetIndex,
                  persisters[targetIndex],
                  keys[targetIndex],
                  object,
                  lockModes[targetIndex],
                  session
              );
            }
            else {
              object = instanceNotYetLoaded(
                  resultSet,
                  targetIndex,
                  persisters[targetIndex],
                  getEntityAliases()[targetIndex].getRowIdAlias(),
                  keys[targetIndex],
                  lockModes[targetIndex],
                  getOptionalObjectKey( queryParameters, session ),
                  queryParameters.getOptionalObject(),
                  hydratedObjects,
                  session
              );
            }
          }
        }
      }
      final Serializable resolvedId = (Serializable) idType.resolve( hydratedKeyState[i], session, null );
      keys[i] = resolvedId == null ? null : new EntityKey( resolvedId, persisters[i], session.getEntityMode() );
    }
  }
View Full Code Here

// from the new scrolling stuff.
//
// Would need to change the way the max-row stuff is handled (i.e. behind an interface) so
// that I could do the control breaking at the means to know when to stop
    final LockMode[] lockModeArray = getLockModes( queryParameters.getLockModes() );
    final EntityKey optionalObjectKey = getOptionalObjectKey( queryParameters, session );

    final boolean createSubselects = isSubselectLoadingEnabled();
    final List subselectResultKeys = createSubselects ? new ArrayList() : null;
    final List results = new ArrayList();
View Full Code Here

      EntityType[] ownerAssociationTypes = getOwnerAssociationTypes();
      for ( int i = 0; i < keys.length; i++ ) {
       
        int owner = owners[i];
        if ( owner > -1 ) {
          EntityKey ownerKey = keys[owner];
          if ( keys[i] == null && ownerKey != null ) {
           
            final PersistenceContext persistenceContext = session.getPersistenceContext();
           
            /*final boolean isPrimaryKey;
View Full Code Here

      if ( idIsResultId ) resultId = id; //use the id passed in
    }

    return resultId == null ?
        null :
        new EntityKey( resultId, persister, session.getEntityMode() );
  }
View Full Code Here

    final Object[] rowResults = new Object[cols];

    for ( int i = 0; i < cols; i++ ) {

      Object object = null;
      EntityKey key = keys[i];

      if ( keys[i] == null ) {
        //do nothing
      }
      else {
View Full Code Here

    }
   
    final PersistenceContext persistenceContext = session.getPersistenceContext();
   
    SubselectFetch subselect = persistenceContext.getBatchFetchQueue()
      .getSubselect( new EntityKey( key, getOwnerEntityPersister(), session.getEntityMode() ) );
   
    if (subselect == null) {
      return null;
    }
    else {
View Full Code Here

  private synchronized EntityKey generateDelayedEntityKey() {
    if ( !isDelayed ) {
      throw new AssertionFailure( "cannot request delayed entity-key for non-delayed post-insert-id generation" );
    }
    return new EntityKey( new DelayedPostInsertIdentifier(), getPersister(), getSession().getEntityMode() );
  }
View Full Code Here

          boolean eager,
          boolean nullable) throws HibernateException {
    errorIfClosed();
    EntityPersister persister = getFactory().getEntityPersister( entityName );
    // first, try to load it from the temp PC associated to this SS
    Object loaded = temporaryPersistenceContext.getEntity( new EntityKey( id, persister, getEntityMode() ) );
    if ( loaded != null ) {
      // we found it in the temp PC.  Should indicate we are in the midst of processing a result set
      // containing eager fetches via join fetch
      return loaded;
    }
View Full Code Here

   
    // now look up the object we are really interested in!
    // (this lets us correctly handle proxies and multi-row
    // or multi-column queries)
    return session.getPersistenceContext()
        .getEntity( new EntityKey( id, persister, session.getEntityMode() ) );

  }
View Full Code Here

TOP

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