Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.EntityEntry


    EventSource eventSource = event.getSession();
    handlePostUpdate(entity, eventSource);
  }

  private void handlePostUpdate(Object entity, EventSource source) {
    EntityEntry entry = (EntityEntry) source.getPersistenceContext().getEntry( entity );
    // mimic the preUpdate filter
    if ( Status.DELETED != entry.getStatus()) {
      callbackRegistry.postUpdate(entity);
    }
  }
View Full Code Here


  public Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session)
      throws HibernateException {

    final Serializable id = session.getContextEntityIdentifier( entity );

    final EntityEntry entry = session.getPersistenceContext().getEntry( entity );
    if ( entry == null ) {
      throw new HibernateException( "entity is not associated with the session: " + id );
    }

    if ( LOG.isTraceEnabled() ) {
View Full Code Here

    final boolean[] tableUpdateNeeded = getTableUpdateNeeded( dirtyFields, hasDirtyCollection );
    final int span = getTableSpan();

    final boolean[] propsToUpdate;
    final String[] updateStrings;
    EntityEntry entry = session.getPersistenceContext().getEntry( object );

    // Ensure that an immutable or non-modifiable entity is not being updated unless it is
    // in the process of being deleted.
    if ( entry == null && ! isMutable() ) {
      throw new IllegalStateException( "Updating immutable entity that is not in session yet!" );
View Full Code Here

      //
      // Note, it potentially could be a proxy, so doAfterTransactionCompletion the location the safe way...
      final EntityKey key = session.generateEntityKey( id, this );
      Object entity = session.getPersistenceContext().getEntity( key );
      if ( entity != null ) {
        EntityEntry entry = session.getPersistenceContext().getEntry( entity );
        loadedState = entry.getLoadedState();
      }
    }

    final String[] deleteStrings;
    if ( isImpliedOptimisticLocking && loadedState != null ) {
View Full Code Here

      int timeout,
      SessionImplementor session) throws StaleObjectStateException, JDBCException {
    if ( !lockable.isVersioned() ) {
      throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
    }
    EntityEntry entry = session.getPersistenceContext().getEntry( object );
    final EntityPersister persister = entry.getPersister();
    Object nextVersion = persister.forceVersionIncrement( entry.getId(), entry.getVersion(), session );
    entry.forceLocked( object, nextVersion );
  }
View Full Code Here

      Object object,
      int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException {
    if ( !lockable.isVersioned() ) {
      throw new HibernateException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
    }
    EntityEntry entry = session.getPersistenceContext().getEntry( object );
    EntityIncrementVersionProcess incrementVersion = new EntityIncrementVersionProcess( object, entry );
    EventSource source = (EventSource) session;
    // Register the EntityIncrementVersionProcess action to run just prior to transaction commit.
    source.getActionQueue().registerProcess( incrementVersion );
  }
View Full Code Here

      Object object,
      int timeout, SessionImplementor session) throws StaleObjectStateException, JDBCException {
    if ( !lockable.isVersioned() ) {
      throw new OptimisticLockException( "[" + lockMode + "] not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
    }
    EntityEntry entry = session.getPersistenceContext().getEntry(object);
    EventSource source = (EventSource)session;
    EntityVerifyVersionProcess verifyVersion = new EntityVerifyVersionProcess(object, entry);
    // Register the EntityVerifyVersionProcess action to run just prior to transaction commit.
    source.getActionQueue().registerProcess(verifyVersion);
  }
View Full Code Here

    //postDelete:
    // After actually deleting a row, record the fact that the instance no longer
    // exists on the database (needed for identity-column key generation), and
    // remove it from the session cache
    final PersistenceContext persistenceContext = session.getPersistenceContext();
    EntityEntry entry = persistenceContext.removeEntry( instance );
    if ( entry == null ) {
      throw new AssertionFailure( "possible nonthreadsafe access to session" );
    }
    entry.postDelete();

    persistenceContext.removeEntity( entry.getEntityKey() );
    persistenceContext.removeProxy( entry.getEntityKey() );
   
    if ( persister.hasCache() ) {
      persister.getCacheAccessStrategy().remove( ck );
    }
View Full Code Here

    public void afterDeserialize(SessionImplementor session) {
    super.afterDeserialize( session );
    // IMPL NOTE: non-flushed changes code calls this method with session == null...
    // guard against NullPointerException
    if ( session != null ) {
      EntityEntry entityEntry = session.getPersistenceContext().getEntry( getInstance() );
      this.state = entityEntry.getLoadedState();
    }
  }
View Full Code Here

          rowId,
          session
      );
    }

    EntityEntry entry = getSession().getPersistenceContext().getEntry( instance );
    if ( entry == null ) {
      throw new AssertionFailure( "possible nonthreadsafe access to session" );
    }
   
    if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {
      // get the updated snapshot of the entity state by cloning current state;
      // it is safe to copy in place, since by this time no-one else (should have)
      // has a reference  to the array
      TypeHelper.deepCopy(
          state,
          persister.getPropertyTypes(),
          persister.getPropertyCheckability(),
          state,
          session
      );
      if ( persister.hasUpdateGeneratedProperties() ) {
        // this entity defines proeprty generation, so process those generated
        // values...
        persister.processUpdateGeneratedProperties( id, instance, state, session );
        if ( persister.isVersionPropertyGenerated() ) {
          nextVersion = Versioning.getVersion( state, persister );
        }
      }
      // have the entity entry doAfterTransactionCompletion post-update processing, passing it the
      // update state and the new version (if one).
      entry.postUpdate( instance, state, nextVersion );
    }

    if ( persister.hasCache() ) {
      if ( persister.isCacheInvalidationRequired() || entry.getStatus()!= Status.MANAGED ) {
        persister.getCacheAccessStrategy().remove( ck );
      }
      else {
        //TODO: inefficient if that cache is just going to ignore the updated state!
        CacheEntry ce = new CacheEntry(
View Full Code Here

TOP

Related Classes of org.hibernate.engine.spi.EntityEntry

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.