Package org.hibernate.engine

Examples of org.hibernate.engine.CollectionEntry


  }
 
  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 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 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 (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

      boolean shallow) throws HibernateException {
    if ( collection == null ) {
      throw new NullPointerException( "null collection passed to filter" );
    }

    CollectionEntry entry = persistenceContext.getCollectionEntryOrNull( collection );
    final CollectionPersister roleBeforeFlush = (entry == null) ? null : entry.getLoadedPersister();

    FilterQueryPlan plan = null;
    if ( roleBeforeFlush == null ) {
      // if it was previously unreferenced, we need to flush in order to
      // get its state into the database in order to execute query
      flush();
      entry = persistenceContext.getCollectionEntryOrNull( collection );
      CollectionPersister roleAfterFlush = (entry == null) ? null : entry.getLoadedPersister();
      if ( roleAfterFlush == null ) {
        throw new QueryException( "The collection was unreferenced" );
      }
      plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getEnabledFilters() );
    }
    else {
      // otherwise, we only need to flush if there are in-memory changes
      // to the queried tables
      plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleBeforeFlush.getRole(), shallow, getEnabledFilters() );
      if ( autoFlushIfRequired( plan.getQuerySpaces() ) ) {
        // might need to run a different filter entirely after the flush
        // because the collection role may have changed
        entry = persistenceContext.getCollectionEntryOrNull( collection );
        CollectionPersister roleAfterFlush = (entry == null) ? null : entry.getLoadedPersister();
        if ( roleBeforeFlush != roleAfterFlush ) {
          if ( roleAfterFlush == null ) {
            throw new QueryException( "The collection was dereferenced" );
          }
          plan = factory.getQueryPlanCache().getFilterQueryPlan( filter, roleAfterFlush.getRole(), shallow, getEnabledFilters() );
        }
      }
    }

    if ( parameters != null ) {
      parameters.getPositionalParameterValues()[0] = entry.getLoadedKey();
      parameters.getPositionalParameterTypes()[0] = entry.getLoadedPersister().getKeyType();
    }

    return plan;
  }
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

    this.affectedOwnerEntityName =
        getAffectedOwnerEntityName( collectionPersister, affectedOwner, source );
  }

  protected static CollectionPersister getLoadedCollectionPersister( PersistentCollection collection, EventSource source ) {
    CollectionEntry ce = source.getPersistenceContext().getCollectionEntry( collection );
    return ( ce == null ? null : ce.getLoadedPersister() );   
  }
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.