Package org.hibernate.engine

Examples of org.hibernate.engine.CollectionEntry


    if (session==this.session) {
      return false;
    }
    else {
      if ( isConnectedToSession() ) {
        CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
        if (ce==null) {
          throw new HibernateException(
              "Illegal attempt to associate a collection with two open sessions"
            );
        }
        else {
          throw new HibernateException(
              "Illegal attempt to associate a collection with two open sessions: " +
              MessageHelper.collectionInfoString(
                  ce.getLoadedPersister(),
                  ce.getLoadedKey(),
                  session.getFactory()
                )
            );
        }
      }
View Full Code Here


      if ( cachedSize!=-1 && !hasQueuedOperations() ) {
        return true;
      }
      else {
        throwLazyInitializationExceptionIfNotConnected();
        CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
        CollectionPersister persister = entry.getLoadedPersister();
        if ( persister.isExtraLazy() ) {
          if ( hasQueuedOperations() ) {
            session.flush();
          }
          cachedSize = persister.getSize( entry.getLoadedKey(), session );
          return true;
        }
      }
    }
    read();
View Full Code Here

  }
 
  protected Boolean readIndexExistence(Object index) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return new Boolean( persister.indexExists( entry.getLoadedKey(), index, session ) );
      }
    }
    read();
    return null;
   
View Full Code Here

  }
 
  protected Boolean readElementExistence(Object element) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return new Boolean( persister.elementExists( entry.getLoadedKey(), element, session ) );
      }
    }
    read();
    return null;
   
View Full Code Here

  protected static final Object UNKNOWN = new MarkerObject("UNKNOWN");
 
  protected Object readElementByIndex(Object index) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
      }
    }
    read();
    return UNKNOWN;
   
View Full Code Here

  /**
   * Is this the "inverse" end of a bidirectional association?
   */
  private boolean isInverseCollection() {
    CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
    return ce != null && ce.getLoadedPersister().isInverse();
  }
View Full Code Here

  /**
   * Is this the "inverse" end of a bidirectional association with
   * no orphan delete enabled?
   */
  private boolean isInverseCollectionNoOrphanDelete() {
    CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
    return ce != null &&
        ce.getLoadedPersister().isInverse() &&
        !ce.getLoadedPersister().hasOrphanDelete();
  }
View Full Code Here

  /**
   * Is this the "inverse" end of a bidirectional one-to-many, or
   * of a collection with no orphan delete?
   */
  private boolean isInverseOneToManyOrNoOrphanDelete() {
    CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(this);
    return ce != null && ce.getLoadedPersister().isInverse() && (
        ce.getLoadedPersister().isOneToMany() ||
        !ce.getLoadedPersister().hasOrphanDelete()
      );
  }
View Full Code Here

    if ( persister.getCollectionType().hasHolder( em ) ) {
      getLoadContext().getPersistenceContext().addCollectionHolder( lce.getCollection() );
    }

    CollectionEntry ce = getLoadContext().getPersistenceContext().getCollectionEntry( lce.getCollection() );
    if ( ce == null ) {
      ce = getLoadContext().getPersistenceContext().addInitializedCollection( persister, lce.getCollection(), lce.getKey() );
    }
    else {
      ce.postInitialize( lce.getCollection() );
    }

    boolean addToCache = hasNoQueuedAdds && // there were no queued additions
        persister.hasCache() &&             // and the role has a cache
        session.getCacheMode().isPutEnabled() &&
        !ce.isDoremove();                   // and this is not a forced initialization during flush
    if ( addToCache ) {
      addCollectionToCache( lce, persister );
    }

    if ( log.isDebugEnabled() ) {
View Full Code Here

  throws HibernateException {

    PersistentCollection collection = event.getCollection();
    SessionImplementor source = event.getSession();

    CollectionEntry ce = source.getPersistenceContext().getCollectionEntry(collection);
    if (ce==null) throw new HibernateException("collection was evicted");
    if ( !collection.wasInitialized() ) {
      if ( log.isTraceEnabled() ) {
        log.trace(
            "initializing collection " +
            MessageHelper.collectionInfoString( ce.getLoadedPersister(), ce.getLoadedKey(), source.getFactory() )
          );
      }

      log.trace("checking second-level cache");
      final boolean foundInCache = initializeCollectionFromCache(
          ce.getLoadedKey(),
          ce.getLoadedPersister(),
          collection,
          source
        );

      if (foundInCache) {
        log.trace("collection initialized from cache");
      }
      else {
        log.trace("collection not cached");
        ce.getLoadedPersister().initialize( ce.getLoadedKey(), source );
        log.trace("collection initialized");

        if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
          source.getFactory().getStatisticsImplementor().fetchCollection(
              ce.getLoadedPersister().getRole()
            );
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.CollectionEntry

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.