Package org.hibernate.proxy

Examples of org.hibernate.proxy.LazyInitializer


    final SessionImplementor source = event.getSession();
    final Object object = event.getObject();

    final Object entity;
    if ( object instanceof HibernateProxy ) {
      LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        if ( li.getSession() == source ) {
          return; //NOTE EARLY EXIT!
        }
        else {
          throw new PersistentObjectException( "uninitialized proxy passed to persist()" );
        }
      }
      entity = li.getImplementation();
    }
    else {
      entity = object;
    }
View Full Code Here


      final EntityKey keyToLoad,
      final LoadEventListener.LoadType options,
      final PersistenceContext persistenceContext,
      final Object proxy) {
    LOG.trace( "Entity proxy found in session cache" );
    LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
    if ( li.isUnwrap() ) {
      return li.getImplementation();
    }
    Object impl = null;
    if ( !options.isAllowProxyCreation() ) {
      impl = load( event, persister, keyToLoad, options );
      if ( impl == null ) {
View Full Code Here

      value = ( (ElementWrapper) value ).getElement();
    }

    if ( !Hibernate.isInitialized( value ) ) {
      final HibernateProxy proxy = (HibernateProxy) value;
      final LazyInitializer li = proxy.getHibernateLazyInitializer();
      reassociateProxy( li, proxy );
      return true;
    }
    else {
      return false;
View Full Code Here

    }

    if ( value instanceof HibernateProxy ) {
      LOG.debugf( "Setting proxy identifier: %s", id );
      final HibernateProxy proxy = (HibernateProxy) value;
      final LazyInitializer li = proxy.getHibernateLazyInitializer();
      li.setIdentifier( id );
      reassociateProxy( li, proxy );
    }
  }
View Full Code Here

      maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
    }

    if ( maybeProxy instanceof HibernateProxy ) {
      final HibernateProxy proxy = (HibernateProxy) maybeProxy;
      final LazyInitializer li = proxy.getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        throw new PersistentObjectException(
            "object was an uninitialized proxy for " + li.getEntityName()
        );
      }
      //unwrap the object and return
      return li.getImplementation();
    }
    else {
      return maybeProxy;
    }
  }
View Full Code Here

      maybeProxy = ( (ElementWrapper) maybeProxy ).getElement();
    }

    if ( maybeProxy instanceof HibernateProxy ) {
      final HibernateProxy proxy = (HibernateProxy) maybeProxy;
      final LazyInitializer li = proxy.getHibernateLazyInitializer();
      reassociateProxy( li, proxy );
      //initialize + unwrap the object and return it
      return li.getImplementation();
    }
    else {
      return maybeProxy;
    }
  }
View Full Code Here

      }
    }
    else {

      if ( object != null ) {
        final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
        li.setImplementation( object );
      }
      return proxy;
    }
  }
View Full Code Here

    final EventSource source = event.getSession();
    final PersistenceContext persistenceContext = source.getPersistenceContext();

    if ( object instanceof HibernateProxy ) {
      final LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      final Serializable id = li.getIdentifier();
      if ( id == null ) {
        throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" );
      }

      final EntityPersister persister = source.getFactory().getEntityPersister( li.getEntityName() );
      final EntityKey key = source.generateEntityKey( id, persister );
      persistenceContext.removeProxy( key );

      if ( !li.isUninitialized() ) {
        final Object entity = persistenceContext.removeEntity( key );
        if ( entity != null ) {
          EntityEntry e = persistenceContext.removeEntry( entity );
          doEvict( entity, key, e.getPersister(), event.getSession() );
        }
      }
      li.unsetSession();
    }
    else {
      EntityEntry e = persistenceContext.removeEntry( object );
      if ( e != null ) {
        persistenceContext.removeEntity( e.getEntityKey() );
View Full Code Here

public class PersistenceUtilHelper {
  public static LoadState isLoadedWithoutReference(Object proxy, String property, MetadataCache cache) {
    Object entity;
    boolean sureFromUs = false;
    if ( proxy instanceof HibernateProxy ) {
      LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        return LoadState.NOT_LOADED;
      }
      else {
        entity = li.getImplementation();
      }
      sureFromUs = true;
    }
    else {
      entity = proxy;
View Full Code Here

public class PersistenceUtilHelper {
  public static LoadState isLoadedWithoutReference(Object proxy, String property, MetadataCache cache) {
    Object entity;
    boolean sureFromUs = false;
    if ( proxy instanceof HibernateProxy ) {
      LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        return LoadState.NOT_LOADED;
      }
      else {
        entity = li.getImplementation();
      }
      sureFromUs = true;
    }
    else {
      entity = proxy;
View Full Code Here

TOP

Related Classes of org.hibernate.proxy.LazyInitializer

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.