Package org.hibernate.engine

Examples of org.hibernate.engine.EntityKey


              MessageHelper.infoString( persister, id, event.getSession().getFactory() )
      );
    }

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

    source.getPersistenceContext().checkUniqueness( key, object );

    //get a snapshot
    Object[] values = persister.getPropertyValues( object, source.getEntityMode() );
View Full Code Here


    errorIfClosed();
    EntityPersister persister = getFactory().getEntityPersister(entityName);
    if ( !eager && persister.hasProxy() ) {
      return persister.createProxy(id, this);
    }
    Object loaded = temporaryPersistenceContext.getEntity( new EntityKey(id, persister, EntityMode.POJO) );
    //TODO: if not loaded, throw an exception
    return loaded==null ? get( entityName, id ) : loaded;
  }
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

      EntityPersister persister = source.getFactory().getEntityPersister( li.getEntityName() );
      if ( id == null ) {
        throw new IllegalArgumentException("null identifier");
      }

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

      if ( !li.isUninitialized() ) {
        final Object entity = persistenceContext.removeEntity( key );
        if ( entity != null ) {
          EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity );
          doEvict( entity, key, e.getPersister(), event.getSession() );
        }
      }
      li.setSession( null );
    }
    else {
      EntityEntry e = persistenceContext.removeEntry( object );
      if ( e != null ) {
        EntityKey key = new EntityKey( e.getId(), e.getPersister(), source.getEntityMode()  );
        persistenceContext.removeEntity( key );
        doEvict( object, key, e.getPersister(), source );
      }
    }
  }
View Full Code Here

          "saving " +
              MessageHelper.infoString( persister, id, source.getFactory() )
      );
    }

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

        log.debug( "executing identity-insert immediately" );
        source.getActionQueue().execute( insert );
        id = insert.getGeneratedId();
        //now done in EntityIdentityInsertAction
        //persister.setIdentifier( entity, id, source.getEntityMode() );
        key = new EntityKey( id, persister, source.getEntityMode() );
        source.getPersistenceContext().checkUniqueness( key, entity );
        //source.getBatcher().executeBatch(); //found another way to ensure that all batched joined inserts have been executed
      }
      else {
        log.debug( "delaying identity-insert due to no transaction in progress" );
View Full Code Here

    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 perform 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

   
    // 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

        return snapshot;
      }
    }
    else {
      //TODO: optimize away this lookup for entities w/o unsaved-value="undefined"
      EntityKey entityKey = new EntityKey( id, persister, session.getEntityMode() );
      return session.getPersistenceContext()
          .getCachedDatabaseSnapshot( entityKey );
    }
  }
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.