Package org.hibernate.engine

Examples of org.hibernate.engine.EntityKey


    if ( isImpliedOptimisticLocking ) {
      // need to treat this as if it where optimistic-lock="all" (dirty does *not* make sense);
      // first we need to locate the "loaded" state
      //
      // Note, it potentially could be a proxy, so doAfterTransactionCompletion the location the safe way...
      EntityKey key = new EntityKey( id, this, session.getEntityMode() );
      Object entity = session.getPersistenceContext().getEntity( key );
      if ( entity != null ) {
        EntityEntry entry = session.getPersistenceContext().getEntry( entity );
        loadedState = entry.getLoadedState();
      }
View Full Code Here


          //if there is no resulting row, return null
          if ( !rs.next() ) {
            return null;
          }

          final EntityKey key = new EntityKey( id, this, session.getEntityMode() );
          Object owner = session.getPersistenceContext().getEntity( key );
          for ( int i = 0; i < naturalIdPropertyCount; i++ ) {
            snapshot[i] = extractionTypes[i].hydrate( rs, getPropertyAliases( "", naturalIdPropertyIndexes[i] ), session, null );
            if (extractionTypes[i].isEntityType()) {
              snapshot[i] = extractionTypes[i].resolve(snapshot[i], session, owner);
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

  /**
   * Return the underlying persistent object in the given <tt>Session</tt>, or null,
   * do not initialize the proxy
   */
  public final Object getImplementation(SessionImplementor s) throws HibernateException {
    final EntityKey entityKey = new EntityKey(
        getIdentifier(),
        s.getFactory().getEntityPersister( getEntityName() ),
        s.getEntityMode()
    );
    return s.getPersistenceContext().getEntity( entityKey );
View Full Code Here

        EntityEntry entry = source.getPersistenceContext().getEntry( entity );
        if ( entry == null ) {
          EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
          Serializable id = persister.getIdentifier( entity, source.getEntityMode() );
          if ( id != null ) {
            EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
            Object managedEntity = source.getPersistenceContext().getEntity( key );
            entry = source.getPersistenceContext().getEntry( managedEntity );
            if ( entry != null ) {
              // we have specialized case of a detached entity from the
              // perspective of the merge operation.  Specifically, we
View Full Code Here

  private boolean existsInDatabase(Object entity, EventSource source, EntityPersister persister) {
    EntityEntry entry = source.getPersistenceContext().getEntry( entity );
    if ( entry == null ) {
      Serializable id = persister.getIdentifier( entity, source.getEntityMode() );
      if ( id != null ) {
        EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
        Object managedEntity = source.getPersistenceContext().getEntity( key );
        entry = source.getPersistenceContext().getEntry( managedEntity );
      }
    }
View Full Code Here

      Serializable id,
      SessionImplementor session) throws MappingException {
    //cannot batch fetch by unique key (property-ref associations)
    if ( uniqueKeyPropertyName == null && id != null ) {
      EntityPersister persister = session.getFactory().getEntityPersister( getAssociatedEntityName() );
      EntityKey entityKey = new EntityKey( id, persister, session.getEntityMode() );
      if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
        session.getPersistenceContext()
            .getBatchFetchQueue()
            .addBatchLoadableEntityKey( entityKey );
      }
View Full Code Here

        log.trace(
            "refreshing transient " +
            MessageHelper.infoString( persister, id, source.getFactory() )
          );
      }
      EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
      if ( source.getPersistenceContext().getEntry(key) != null ) {
        throw new PersistentObjectException(
            "attempted to refresh transient instance when persistent instance was already associated with the Session: " +
            MessageHelper.infoString(persister, id, source.getFactory() )
          );
      }
    }
    else {
      if ( log.isTraceEnabled() ) {
        log.trace(
            "refreshing " +
            MessageHelper.infoString( e.getPersister(), e.getId(), source.getFactory()  )
          );
      }
      if ( !e.isExistsInDatabase() ) {
        throw new HibernateException( "this instance does not yet exist as a row in the database" );
      }

      persister = e.getPersister();
      id = e.getId();
    }

    // cascade the refresh prior to refreshing this entity
    refreshedAlready.put(object, object);
    new Cascade(CascadingAction.REFRESH, Cascade.BEFORE_REFRESH, source)
        .cascade( persister, object, refreshedAlready );

    if ( e != null ) {
      EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
      source.getPersistenceContext().removeEntity(key);
      if ( persister.hasCollections() ) new EvictVisitor( source ).process(object, persister);
    }

    if ( persister.hasCache() ) {
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

     
      EntityPersister ownerPersister = session.getFactory()
          .getEntityPersister(entityName);
      Serializable id = session.getContextEntityIdentifier(owner);

      EntityKey entityKey = new EntityKey( id, ownerPersister, session.getEntityMode() );
     
      return session.getPersistenceContext()
          .isPropertyNull( entityKey, getPropertyName() );
     
    }
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.