Package org.hibernate.engine

Examples of org.hibernate.engine.EntityEntry


  protected void dirtyCheck(FlushEntityEvent event) throws HibernateException {
   
    final Object entity = event.getEntity();
    final Object[] values = event.getPropertyValues();
    final SessionImplementor session = event.getSession();
    final EntityEntry entry = event.getEntityEntry();
    final EntityPersister persister = entry.getPersister();
    final Serializable id = entry.getId();
    final Object[] loadedState = entry.getLoadedState();

    int[] dirtyProperties = session.getInterceptor().findDirty(
        entity,
        id,
        values,
View Full Code Here


      object = ( (HibernateProxy) object ).getHibernateLazyInitializer().getImplementation(this);
      if ( object == null ) {
        return LockMode.NONE;
      }
    }
    EntityEntry e = persistenceContext.getEntry(object);
    if ( e == null ) {
      throw new TransientObjectException( "Given object not associated with the session" );
    }
    if ( e.getStatus() != Status.MANAGED ) {
      throw new ObjectDeletedException(
          "The given object was deleted",
          e.getId(),
          e.getPersister().getEntityName()
        );
    }
    return e.getLockMode();
  }
View Full Code Here

        throw new TransientObjectException( "The proxy was not associated with this session" );
      }
      return li.getIdentifier();
    }
    else {
      EntityEntry entry = persistenceContext.getEntry(object);
      if ( entry == null ) {
        throw new TransientObjectException( "The instance was not associated with this session" );
      }
      return entry.getId();
    }
  }
View Full Code Here

    errorIfClosed();
    if ( object instanceof HibernateProxy ) {
      return getProxyIdentifier(object);
    }
    else {
      EntityEntry entry = persistenceContext.getEntry(object);
      return entry != null ? entry.getId() : null;
    }
  }
View Full Code Here

      }
    }
    // A session is considered to contain an entity only if the entity has
    // an entry in the session's persistence context and the entry reports
    // that the entity has not been removed
    EntityEntry entry = persistenceContext.getEntry( object );
    return entry != null && entry.getStatus() != Status.DELETED && entry.getStatus() != Status.GONE;
  }
View Full Code Here

      if ( initializer.isUninitialized() ) {
        return initializer.getEntityName();
      }
      object = initializer.getImplementation();
    }
    EntityEntry entry = persistenceContext.getEntry(object);
    if (entry==null) {
      return guessEntityName(object);
    }
    else {
      return entry.getPersister().getEntityName();
    }
  }
View Full Code Here

        throw new TransientObjectException("proxy was not associated with the session");
      }
      object = ( (HibernateProxy) object ).getHibernateLazyInitializer().getImplementation();
    }

    EntityEntry entry = persistenceContext.getEntry(object);
    if ( entry == null ) {
      throwTransientObjectException( object );
    }
    return entry.getPersister().getEntityName();
  }
View Full Code Here

    log.trace( "saving transient instance" );

    final EventSource source = event.getSession();

    EntityEntry entityEntry = event.getEntry();
    if ( entityEntry != null ) {
      if ( entityEntry.getStatus() == Status.DELETED ) {
        source.forceFlush( entityEntry );
      }
      else {
        throw new AssertionFailure( "entity was persistent" );
      }
View Full Code Here

    final EventSource source = event.getSession();

    final PersistenceContext persistenceContext = source.getPersistenceContext();
    Object entity = persistenceContext.unproxyAndReassociate( event.getObject() );

    EntityEntry entityEntry = persistenceContext.getEntry( entity );
    final EntityPersister persister;
    final Serializable id;
    final Object version;

    if ( entityEntry == null ) {
      log.trace( "entity was not persistent in delete processing" );

      persister = source.getEntityPersister( event.getEntityName(), entity );

      if ( ForeignKeys.isTransient( persister.getEntityName(), entity, null, source ) ) {
        deleteTransientEntity( source, entity, event.isCascadeDeleteEnabled(), persister, transientEntities );
        // EARLY EXIT!!!
        return;
      }
      else {
        performDetachedEntityDeletionCheck( event );
      }

      id = persister.getIdentifier( entity, source.getEntityMode() );

      if ( id == null ) {
        throw new TransientObjectException(
            "the detached instance passed to delete() had a null identifier"
        );
      }

      EntityKey key = new EntityKey( id, persister, source.getEntityMode() );

      persistenceContext.checkUniqueness( key, entity );

      new OnUpdateVisitor( source, id, entity ).process( entity, persister );

      version = persister.getVersion( entity, source.getEntityMode() );

      entityEntry = persistenceContext.addEntity(
          entity,
          Status.MANAGED,
          persister.getPropertyValues( entity, source.getEntityMode() ),
          key,
          version,
          LockMode.NONE,
          true,
          persister,
          false,
          false
      );
    }
    else {
      log.trace( "deleting a persistent instance" );

      if ( entityEntry.getStatus() == Status.DELETED || entityEntry.getStatus() == Status.GONE ) {
        log.trace( "object was already deleted" );
        return;
      }
      persister = entityEntry.getPersister();
      id = entityEntry.getId();
      version = entityEntry.getVersion();
    }

    /*if ( !persister.isMutable() ) {
      throw new HibernateException(
          "attempted to delete an object of immutable class: " +
View Full Code Here

    Object existing = persistenceContext.getEntity( keyToLoad );
    if ( existing != null ) {
      // return existing object or initialized proxy (unless deleted)
      log.trace( "entity found in session cache" );
      if ( options.isCheckDeleted() ) {
        EntityEntry entry = persistenceContext.getEntry( existing );
        Status status = entry.getStatus();
        if ( status == Status.DELETED || status == Status.GONE ) {
          return null;
        }
      }
      return existing;
View Full Code Here

TOP

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