Examples of LazyInitializer


Examples of org.hibernate.proxy.LazyInitializer

  }

  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

Examples of org.hibernate.proxy.LazyInitializer

      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

Examples of org.hibernate.proxy.LazyInitializer

    }
   
    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

Examples of org.hibernate.proxy.LazyInitializer

      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

Examples of org.hibernate.proxy.LazyInitializer

      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

Examples of org.hibernate.proxy.LazyInitializer

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

Examples of org.hibernate.proxy.LazyInitializer

   * @return The extracted identifier.
   */
  private static Serializable getIdentifier(Object object, EntityPersister persister, EntityMode entityMode) {
    if (object instanceof HibernateProxy) {
      HibernateProxy proxy = (HibernateProxy) object;
      LazyInitializer li = proxy.getHibernateLazyInitializer();
      return li.getIdentifier();
    }
    else {
      return persister.getIdentifier( object, entityMode );
    }
  }
View Full Code Here

Examples of org.hibernate.proxy.LazyInitializer

  // not for internal use:
  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

    }
  }

  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 accidently 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
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.