Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.CollectionEntry


    super( enversConfiguration );
  }

  @Override
  public void onPreRemoveCollection(PreCollectionRemoveEvent event) {
        CollectionEntry collectionEntry = getCollectionEntry( event );
        if ( collectionEntry != null && !collectionEntry.getLoadedPersister().isInverse() ) {
            onCollectionAction( event, null, collectionEntry.getSnapshot(), collectionEntry );
        }
  }
View Full Code Here


    List list = IdentityMap.entries( session.getPersistenceContext().getCollectionEntries() );
    int size = list.size();
    for ( int i = 0; i < size; i++ ) {
      Map.Entry me = ( Map.Entry ) list.get( i );
      CollectionEntry ce = (CollectionEntry) me.getValue();
      if ( !ce.isReached() && !ce.isIgnore() ) {
        Collections.processUnreachableCollection( (PersistentCollection) me.getKey(), session );
      }
    }

    // Schedule updates to collections:

                if (LOG.isTraceEnabled()) {
                   LOG.trace("Scheduling collection removes/(re)creates/updates");
                }

    list = IdentityMap.entries( session.getPersistenceContext().getCollectionEntries() );
    size = list.size();
    ActionQueue actionQueue = session.getActionQueue();
    for ( int i = 0; i < size; i++ ) {
      Map.Entry me = (Map.Entry) list.get(i);
      PersistentCollection coll = (PersistentCollection) me.getKey();
      CollectionEntry ce = (CollectionEntry) 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
              )
          );
      }
View Full Code Here

        .clearSubselects(); //the database has changed now, so the subselect results need to be invalidated

    Iterator iter = persistenceContext.getCollectionEntries().entrySet().iterator();
    while ( iter.hasNext() ) {
      Map.Entry me = (Map.Entry) iter.next();
      CollectionEntry collectionEntry = (CollectionEntry) me.getValue();
      PersistentCollection 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

   * @return the owner, if its entity ID is available from the collection's loaded key
   * and the owner entity is in the persistence context; otherwise, returns null
   */
  @Override
  public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection) {
    CollectionEntry ce = getCollectionEntry( collection );
    if ( ce.getLoadedPersister() == null ) {
      return null; // early exit...
    }
    Object loadedOwner = null;
    // TODO: an alternative is to check if the owner has changed; if it hasn't then
    // return collection.getOwner()
    Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
    if ( entityId != null ) {
      loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
    }
    return loadedOwner;
  }
View Full Code Here

  /**
   * add a collection we just loaded up (still needs initializing)
   */
  @Override
  public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) {
    CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
    addCollection(collection, ce, id);
    if ( persister.getBatchSize() > 1 ) {
      getBatchFetchQueue().addBatchLoadableCollection( collection, ce );
    }
  }
View Full Code Here

  /**
   * add a detached uninitialized collection
   */
  @Override
  public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection) {
    CollectionEntry ce = new CollectionEntry( persister, collection.getKey() );
    addCollection( collection, ce, collection.getKey() );
    if ( persister.getBatchSize() > 1 ) {
      getBatchFetchQueue().addBatchLoadableCollection( collection, ce );
    }
  }
View Full Code Here

   *
   * @param collection The collection for which we are adding an entry.
   * @param persister The collection persister
   */
  private void addCollection(PersistentCollection collection, CollectionPersister persister) {
    CollectionEntry ce = new CollectionEntry( persister, collection );
    collectionEntries.put( collection, ce );
  }
View Full Code Here

    if ( collection.isUnreferenced() ) {
      //treat it just like a new collection
      addCollection( collection, collectionPersister );
    }
    else {
      CollectionEntry ce = new CollectionEntry( collection, session.getFactory() );
      addCollection( collection, ce, collection.getKey() );
    }
  }
View Full Code Here

   * add a collection we just pulled out of the cache (does not need initializing)
   */
  @Override
  public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
  throws HibernateException {
    CollectionEntry ce = new CollectionEntry(collection, persister, id, flushing);
    ce.postInitialize(collection);
    addCollection(collection, ce, id);
    return ce;
  }
View Full Code Here

      count = ois.readInt();
      if ( tracing ) LOG.trace("Starting deserialization of [" + count + "] collectionEntries entries");
      rtn.collectionEntries = IdentityMap.instantiateSequenced( count < INIT_COLL_SIZE ? INIT_COLL_SIZE : count );
      for ( int i = 0; i < count; i++ ) {
        final PersistentCollection pc = ( PersistentCollection ) ois.readObject();
        final CollectionEntry ce = CollectionEntry.deserialize( ois, session );
        pc.setCurrentSession( session );
        rtn.collectionEntries.put( pc, ce );
      }

      count = ois.readInt();
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.