Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.CollectionEntry


    if ( !initialized ) {
      Boolean extraLazyExistenceCheck = withTemporarySessionIfNeeded(
          new LazyInitializationWork<Boolean>() {
            @Override
            public Boolean doWork() {
              CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
              CollectionPersister persister = entry.getLoadedPersister();
              if ( persister.isExtraLazy() ) {
                if ( hasQueuedOperations() ) {
                  session.flush();
                }
                return persister.elementExists( entry.getLoadedKey(), element, session );
              }
              else {
                read();
              }
              return null;
View Full Code Here


        private boolean isExtraLazy;
        private Object element;

        @Override
        public Object doWork() {
          CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
          CollectionPersister persister = entry.getLoadedPersister();
          isExtraLazy = persister.isExtraLazy();
          if ( isExtraLazy ) {
            if ( hasQueuedOperations() ) {
              session.flush();
            }
            element = persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
          }
          else {
            read();
          }
          return null;
View Full Code Here

  /**
   * Is this the "inverse" end of a bidirectional association?
   */
  @SuppressWarnings({"JavaDoc"})
  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?
   */
  @SuppressWarnings({"JavaDoc"})
  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?
   */
  @SuppressWarnings({"JavaDoc"})
  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(), this,
                      ce.getLoadedKey(), session
                  )
          );
        }
      }
      else {
View Full Code Here

        private boolean isExtraLazy;
        private Object element;

        @Override
        public Object doWork() {
          CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
          CollectionPersister persister = entry.getLoadedPersister();
          isExtraLazy = persister.isExtraLazy();
          if ( isExtraLazy ) {
            if ( hasQueuedOperations() ) {
              session.flush();
            }
            element = persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
          }
          else {
            read();
          }
          return null;
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

    );

    final int count = entries.length;

    for ( Map.Entry<PersistentCollection,CollectionEntry> me : entries ) {
      CollectionEntry ce = me.getValue();
      if ( !ce.isReached() && !ce.isIgnore() ) {
        Collections.processUnreachableCollection( me.getKey(), session );
      }
    }

    // Schedule updates to collections:

    LOG.trace( "Scheduling collection removes/(re)creates/updates" );

    ActionQueue actionQueue = session.getActionQueue();
    for ( Map.Entry<PersistentCollection,CollectionEntry> me :
      IdentityMap.concurrentEntries( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
      PersistentCollection coll = me.getKey();
      CollectionEntry ce = me.getValue();

      if ( ce.isDorecreate() ) {
        session.getInterceptor().onCollectionRecreate( coll, ce.getCurrentKey() );
        actionQueue.addAction(
            new CollectionRecreateAction(
                coll,
                ce.getCurrentPersister(),
                ce.getCurrentKey(),
                session
              )
          );
      }
      if ( ce.isDoremove() ) {
        session.getInterceptor().onCollectionRemove( coll, ce.getLoadedKey() );
        actionQueue.addAction(
            new CollectionRemoveAction(
                coll,
                ce.getLoadedPersister(),
                ce.getLoadedKey(),
                ce.isSnapshotEmpty(coll),
                session
              )
          );
      }
      if ( ce.isDoupdate() ) {
        session.getInterceptor().onCollectionUpdate( coll, ce.getLoadedKey() );
        actionQueue.addAction(
            new CollectionUpdateAction(
                coll,
                ce.getLoadedPersister(),
                ce.getLoadedKey(),
                ce.isSnapshotEmpty(coll),
                session
              )
          );
      }
      if ( !coll.wasInitialized() && coll.hasQueuedOperations() ) {
        actionQueue.addAction(
            new QueuedOperationCollectionAction(
                coll,
                ce.getLoadedPersister(),
                ce.getLoadedKey(),
                session
              )
          );
      }
View Full Code Here

    // the database has changed now, so the subselect results need to be invalidated
    // the batch fetching queues should also be cleared - especially the collection batch fetching one
    persistenceContext.getBatchFetchQueue().clear();

    for ( Map.Entry<PersistentCollection, CollectionEntry> me : IdentityMap.concurrentEntries( persistenceContext.getCollectionEntries() ) ) {
      CollectionEntry collectionEntry = me.getValue();
      PersistentCollection persistentCollection = me.getKey();
      collectionEntry.postFlush(persistentCollection);
      if ( collectionEntry.getLoadedPersister() == null ) {
        //if the collection is dereferenced, remove from the session cache
        //iter.remove(); //does not work, since the entrySet is not backed by the set
        persistenceContext.getCollectionEntries()
            .remove(persistentCollection);
      }
      else {
        //otherwise recreate the mapping between the collection and its key
        CollectionKey collectionKey = new CollectionKey(
            collectionEntry.getLoadedPersister(),
            collectionEntry.getLoadedKey()
        );
        persistenceContext.getCollectionsByKey().put(collectionKey, persistentCollection);
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.spi.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.