Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.EntityKey


    //cannot batch fetch by unique key (property-ref associations)
    //FIXME support non-pk unique id
    if ( //uniqueKeyPropertyName == null &&
        id != null ) {
      EntityPersister persister = session.getFactory().getEntityPersister( delegate.getAssociatedEntityName() );
      EntityKey entityKey = session.generateEntityKey( id, persister );
      if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
        session.getPersistenceContext().getBatchFetchQueue().addBatchLoadableEntityKey( entityKey );
      }
    }
  }
View Full Code Here


  protected final boolean isConnectedToSession() {
    return getProxyOrNull() != null;
  }

  private Object getProxyOrNull() {
    final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() );
    if ( entityKey != null && session != null && session.isOpen() ) {
      return session.getPersistenceContext().getProxy( entityKey );
    }
    return null;
  }
View Full Code Here

    initialized = true;
  }

  @Override
  public final Object getImplementation(SessionImplementor s) throws HibernateException {
    final EntityKey entityKey = generateEntityKeyOrNull( getIdentifier(), s, getEntityName() );
    return (entityKey == null ? null : s.getPersistenceContext().getEntity( entityKey ));
  }
View Full Code Here

      if ( !persister.isMutable() && !readOnly ) {
        throw new IllegalStateException( "cannot make proxies for immutable entities modifiable" );
      }
      this.readOnly = readOnly;
      if ( initialized ) {
        EntityKey key = generateEntityKeyOrNull( getIdentifier(), session, getEntityName() );
        if ( key != null && session.getPersistenceContext().containsEntity( key ) ) {
          session.getPersistenceContext().setReadOnly( target, readOnly );
        }
      }
    }
View Full Code Here

    if ( LOG.isTraceEnabled() ) {
      LOG.tracev( "Saving {0}", MessageHelper.infoString( persister, id, source.getFactory() ) );
    }

    final EntityKey key;
    if ( !useIdentityColumn ) {
      key = source.generateEntityKey( id, persister );
      Object old = source.getPersistenceContext().getEntity( key );
      if ( old != null ) {
        if ( source.getPersistenceContext().getEntry( old ).getStatus() == Status.DELETED ) {
View Full Code Here

      final ResultSetProcessingContext.EntityReferenceProcessingState processingState =
          rootReturnReader.getIdentifierResolutionContext( context );
      // if the entity reference we are hydrating is a Return, it is possible that its EntityKey is
      // supplied by the QueryParameter optional entity information
      if ( context.shouldUseOptionalEntityInformation() && context.getQueryParameters().getOptionalId() != null ) {
        EntityKey entityKey = ResultSetProcessorHelper.getOptionalObjectKey(
            context.getQueryParameters(),
            context.getSession()
        );
        processingState.registerIdentifierHydratedForm( entityKey.getIdentifier() );
        processingState.registerEntityKey( entityKey );
        final EntityPersister entityPersister = processingState.getEntityReference().getEntityPersister();
        if ( entityPersister.getIdentifierType().isComponentType()  ) {
          final ComponentType identifierType = (ComponentType) entityPersister.getIdentifierType();
          if ( !identifierType.isEmbedded() ) {
            addKeyManyToOnesToSession(
                context,
                identifierType,
                entityKey.getIdentifier()
            );
          }
        }
      }
      return super.readRow( resultSet, context );
View Full Code Here

    final EntityReferenceProcessingState fetchOwnerState = getOwnerProcessingState( fetch );
    if ( fetchOwnerState == null ) {
      throw new IllegalStateException( "Could not locate fetch owner state" );
    }

    final EntityKey ownerEntityKey = fetchOwnerState.getEntityKey();
    if ( ownerEntityKey == null ) {
      throw new IllegalStateException( "Could not locate fetch owner EntityKey" );
    }

    session.getPersistenceContext().addNullProperty(
View Full Code Here

  @Override
  public Object read(ResultSet resultSet, ResultSetProcessingContext context) throws SQLException {
    final EntityReferenceProcessingState processingState = getIdentifierResolutionContext( context );

    final EntityKey entityKey = processingState.getEntityKey();
    final Object entityInstance = context.getProcessingState( entityReturn ).getEntityInstance();

    if ( context.shouldReturnProxies() ) {
      final Object proxy = context.getSession().getPersistenceContext().proxyFor(
          entityReturn.getEntityPersister(),
View Full Code Here

  private boolean isCurrentRowForSameEntity(
      final EntityKey keyToRead,
      final int persisterIndex,
      final ResultSet resultSet,
      final SessionImplementor session) throws SQLException {
    EntityKey currentRowKey = getKeyFromResultSet(
        persisterIndex, getEntityPersisters()[persisterIndex], null, resultSet, session
    );
    return keyToRead.equals( currentRowKey );
  }
View Full Code Here

      // key value upon which to perform the breaking logic.  However,
      // it is also then called from getRowFromResultSet() which is certainly
      // not the most efficient.  But the call here is needed, and there
      // currently is no other way without refactoring of the doQuery()/getRowFromResultSet()
      // methods
      final EntityKey currentKey = getKeyFromResultSet(
          0,
          getEntityPersisters()[0],
          null,
          resultSet,
          session
View Full Code Here

TOP

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