Examples of LazyInitializer


Examples of org.hibernate.proxy.LazyInitializer

   */
  public static boolean isPropertyInitialized(Object proxy, String propertyName) {
   
    Object entity;
    if ( proxy instanceof HibernateProxy ) {
      LazyInitializer li = ( ( HibernateProxy ) proxy ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        return false;
      }
      else {
        entity = li.getImplementation();
      }
    }
    else {
      entity = proxy;
    }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

   * @return true if the named property of the object is not listed as uninitialized; false otherwise
   */
  public static boolean isPropertyInitialized(Object proxy, String propertyName) {
    final Object entity;
    if ( proxy instanceof HibernateProxy ) {
      final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        return false;
      }
      else {
        entity = li.getImplementation();
      }
    }
    else {
      entity = proxy;
    }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

  }
  @Override
  public Object readObject(Object target, String name, Object oldValue) {
    Object value = intercept( target, name, oldValue );
    if ( value instanceof HibernateProxy ) {
      final LazyInitializer li = ( (HibernateProxy) value ).getHibernateLazyInitializer();
      if ( li.isUnwrap() ) {
        value = li.getImplementation();
      }
    }
    return value;
  }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

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

Examples of org.hibernate.proxy.LazyInitializer

    Iterator elems = getElementsIterator( collection, session );
    while ( elems.hasNext() ) {
      Object element = elems.next();
      // worrying about proxies is perhaps a little bit of overkill here...
      if ( element instanceof HibernateProxy ) {
        LazyInitializer li = ( (HibernateProxy) element ).getHibernateLazyInitializer();
        if ( !li.isUninitialized() ) element = li.getImplementation();
      }
      if ( element == childObject ) return true;
    }
    return false;
  }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

    String entityName = null;

    // this code is largely copied from Session's bestGuessEntityName
    Object entity = object;
    if ( entity instanceof HibernateProxy ) {
      final LazyInitializer initializer = ( (HibernateProxy) entity ).getHibernateLazyInitializer();
      if ( initializer.isUninitialized() ) {
        entityName = initializer.getEntityName();
      }
      entity = initializer.getImplementation();
    }

    if ( entityName == null ) {
      for ( EntityNameResolver resolver : scope.resolveFactory().iterateEntityNameResolvers() ) {
        entityName = resolver.resolveEntityName( entity );
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

  @Override
  public Serializable getIdentifier(Object object) throws HibernateException {
    errorIfClosed();
    checkTransactionSynchStatus();
    if ( object instanceof HibernateProxy ) {
      LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      if ( li.getSession() != this ) {
        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" );
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

    checkTransactionSynchStatus();
    if ( object instanceof HibernateProxy ) {
      //do not use proxiesByKey, since not all
      //proxies that point to this session's
      //instances are in that collection!
      LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      if ( li.isUninitialized() ) {
        //if it is an uninitialized proxy, pointing
        //with this session, then when it is accessed,
        //the underlying instance will be "contained"
        return li.getSession()==this;
      }
      else {
        //if it is initialized, see if the underlying
        //instance is contained, since we need to
        //account for the fact that it might have been
        //evicted
        object = li.getImplementation();
      }
    }
    // 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
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

  }

  @Override
  public String bestGuessEntityName(Object object) {
    if (object instanceof HibernateProxy) {
      LazyInitializer initializer = ( ( HibernateProxy ) object ).getHibernateLazyInitializer();
      // it is possible for this method to be called during flush processing,
      // so make certain that we do not accidentally initialize an uninitialized proxy
      if ( initializer.isUninitialized() ) {
        return initializer.getEntityName();
      }
      object = initializer.getImplementation();
    }
    EntityEntry entry = persistenceContext.getEntry(object);
    if (entry==null) {
      return guessEntityName(object);
    }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

    if ( original != null ) {

      final Object entity;
      if ( original instanceof HibernateProxy ) {
        LazyInitializer li = ( (HibernateProxy) original ).getHibernateLazyInitializer();
        if ( li.isUninitialized() ) {
          LOG.trace( "Ignoring uninitialized proxy" );
          event.setResult( source.load( li.getEntityName(), li.getIdentifier() ) );
          return; //EARLY EXIT!
        }
        else {
          entity = li.getImplementation();
        }
      }
      else {
        entity = original;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.