Package org.hibernate.engine

Examples of org.hibernate.engine.EntityKey


  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


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

    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

      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

        );
      }

      final EventSource source = event.getSession();

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

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

      if ( invokeUpdateLifecycle( entity, persister, source ) ) {
        reassociate( event, event.getObject(), event.getRequestedId(), persister );
View Full Code Here

        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 );
View Full Code Here

        propTypes
    );

    // before any callbacks, etc, so subdeletions see that this deletion happened first
    persistenceContext.setEntryStatus( entityEntry, Status.DELETED );
    EntityKey key = new EntityKey( entityEntry.getId(), persister, session.getEntityMode() );

    cascadeBeforeDelete( session, persister, entity, entityEntry, transientEntities );

    new ForeignKeys.Nullifier( entity, true, false, session )
        .nullifyTransientReferences( entityEntry.getDeletedState(), propTypes );
View Full Code Here

            "Provided id of the wrong type for class " + persister.getEntityName() + ". Expected: " + idClass + ", got " + event.getEntityId().getClass()
        );
      }
    }

    EntityKey keyToLoad = new EntityKey( event.getEntityId(), persister, source.getEntityMode()  );

    try {
      if ( loadType.isNakedEntityReturned() ) {
        //do not return a proxy!
        //(this option indicates we are initializing a proxy)
View Full Code Here

    Object result = optionalObject == null ?
        session.instantiate( subclassPersister, id ) : optionalObject;

    // make it circular-reference safe
    TwoPhaseLoad.addUninitializedCachedEntity(
        new EntityKey( id, subclassPersister, session.getEntityMode() ),
        result,
        subclassPersister,
        LockMode.NONE,
        entry.areLazyPropertiesUnfetched(),
        entry.getVersion(),
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

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.