Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.CollectionEntry


    if ( persister.getCollectionType().hasHolder() ) {
      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() );
//      if (ce.getLoadedPersister().getBatchSize() > 1) { // not the best place for doing this, moved into ce.postInitialize
//        getLoadContext().getPersistenceContext().getBatchFetchQueue().removeBatchLoadableCollection(ce);
//      }
    }


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

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


      // retain the same snapshot
      targetSnapshot = resultSnapshot;

    }

    CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( result );
    if ( ce != null ) {
      ce.resetStoredSnapshot( result, targetSnapshot );
    }

  }
View Full Code Here

    return getEntity( session.generateEntityKey( key, collectionPersister.getOwnerEntityPersister() ) );
  }

  @Override
  public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection) {
    final CollectionEntry ce = getCollectionEntry( collection );
    if ( ce.getLoadedPersister() == null ) {
      return null;
    }

    Object loadedOwner = null;
    // TODO: an alternative is to check if the owner has changed; if it hasn't then
    // return collection.getOwner()
    final Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
    if ( entityId != null ) {
      loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
    }
    return loadedOwner;
  }
View Full Code Here

    return ce.getLoadedPersister().getCollectionType().getIdOfOwnerOrNull( ce.getLoadedKey(), session );
  }

  @Override
  public void addUninitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id) {
    final CollectionEntry ce = new CollectionEntry( collection, persister, id, flushing );
    addCollection( collection, ce, id );
    if ( persister.getBatchSize() > 1 ) {
      getBatchFetchQueue().addBatchLoadableCollection( collection, ce );
    }
  }
View Full Code Here

    }
  }

  @Override
  public void addUninitializedDetachedCollection(CollectionPersister persister, PersistentCollection collection) {
    final 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) {
    final 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 {
      final CollectionEntry ce = new CollectionEntry( collection, session.getFactory() );
      addCollection( collection, ce, collection.getKey() );
    }
  }
View Full Code Here

  }

  @Override
  public CollectionEntry addInitializedCollection(CollectionPersister persister, PersistentCollection collection, Serializable id)
      throws HibernateException {
    final CollectionEntry ce = new CollectionEntry( collection, persister, id, flushing );
    ce.postInitialize( collection );
    addCollection( collection, ce, id );
    return ce;
  }
View Full Code Here

        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

   */
  private void deleteOrphans(String entityName, PersistentCollection pc) throws HibernateException {
    //TODO: suck this logic into the collection!
    final Collection orphans;
    if ( pc.wasInitialized() ) {
      final CollectionEntry ce = eventSource.getPersistenceContext().getCollectionEntry( pc );
      orphans = ce==null
          ? java.util.Collections.EMPTY_LIST
          : ce.getOrphans( entityName, pc );
    }
    else {
      orphans = pc.getQueuedOrphans( entityName );
    }

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.