Package org.hibernate.proxy

Examples of org.hibernate.proxy.LazyInitializer


  }

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


    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

    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

  }

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

  }

  public void clear() {
    Iterator itr = proxiesByKey.values().iterator();
    while ( itr.hasNext() ) {
      final LazyInitializer li = ( ( HibernateProxy ) itr.next() ).getHibernateLazyInitializer();
      li.unsetSession();
    }
    Map.Entry[] collectionEntryArray = IdentityMap.concurrentEntries( collectionEntries );
    for ( int i = 0; i < collectionEntryArray.length; i++ ) {
      ( ( PersistentCollection ) collectionEntryArray[i].getKey() ).unsetSession( getSession() );
    }
View Full Code Here

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

    }
   
    if ( value instanceof HibernateProxy ) {
      if ( log.isDebugEnabled() ) log.debug("setting proxy identifier: " + id);
      HibernateProxy proxy = (HibernateProxy) value;
      LazyInitializer li = proxy.getHibernateLazyInitializer();
      li.setIdentifier(id);
      reassociateProxy(li, proxy);
    }
  }
View Full Code Here

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

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

     
    }
    else {
     
      if ( object != null ) {
        LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer();
        li.setImplementation(object);
      }
     
      return 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.