Package org.hibernate.collection.spi

Examples of org.hibernate.collection.spi.PersistentCollection


    if ( isUpdate ) {
      removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
    }
    if ( collection != null && ( collection instanceof PersistentCollection ) ) {
      PersistentCollection wrapper = ( PersistentCollection ) collection;
      wrapper.setCurrentSession( session );
      if ( wrapper.wasInitialized() ) {
        session.getPersistenceContext().addNewCollection( persister, wrapper );
      }
      else {
        reattachCollection( wrapper, type );
      }
View Full Code Here


    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(),
View Full Code Here

    // 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()
View Full Code Here

    }
    else {
      return; //EARLY EXIT!
    }

    PersistentCollection collection = (PersistentCollection) pc;
    if ( collection.unsetSession( getSession() ) ) evictCollection(collection);
  }
View Full Code Here

  throws HibernateException {

    if ( collection!=null && (collection instanceof PersistentCollection) ) {

      final SessionImplementor session = getSession();
      PersistentCollection coll = (PersistentCollection) collection;
      if ( coll.setCurrentSession(session) ) {
        reattachCollection( coll, collectionType );
      }
      return null;

    }
View Full Code Here

      //TODO: move into collection type, so we can use polymorphism!
      if ( collectionType.hasHolder() ) {

        if (collection==CollectionType.UNFETCHED_COLLECTION) return null;

        PersistentCollection ah = persistenceContext.getCollectionHolder(collection);
        if (ah==null) {
          ah = collectionType.wrap(session, collection);
          persistenceContext.addNewCollection( persister, ah );
          persistenceContext.addCollectionHolder(ah);
        }
        return null;
      }
      else {

        PersistentCollection persistentCollection = collectionType.wrap(session, collection);
        persistenceContext.addNewCollection( persister, persistentCollection );

        if ( LOG.isTraceEnabled() ) {
          LOG.tracev( "Wrapped collection in role: {0}", collectionType.getRole() );
        }
View Full Code Here

   * called by a collection that wants to initialize itself
   */
  public void onInitializeCollection(InitializeCollectionEvent event)
  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() ) {
      final boolean traceEnabled = LOG.isTraceEnabled();
      if ( traceEnabled ) {
        LOG.tracev( "Initializing collection {0}",
            MessageHelper.collectionInfoString( ce.getLoadedPersister(), collection, ce.getLoadedKey(), source ) );
        LOG.trace( "Checking second-level cache" );
View Full Code Here

    EventSource session = getSession();
    CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );

    final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
    if ( collection!=null && (collection instanceof PersistentCollection) ) {
      PersistentCollection wrapper = (PersistentCollection) collection;
      if ( wrapper.setCurrentSession(session) ) {
        //a "detached" collection!
        if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
          // if the collection belonged to a different entity,
          // clean up the existing state of the collection
          removeCollection( persister, collectionKey, session );
View Full Code Here

    if (collection!=null) {

      SessionImplementor session = getSession();

      final PersistentCollection persistentCollection;
      if ( type.isArrayType() ) {
         persistentCollection = session.getPersistenceContext().getCollectionHolder(collection);
        // if no array holder we found an unwrappered array (this can't occur,
        // because we now always call wrap() before getting to here)
        // return (ah==null) ? true : searchForDirtyCollections(ah, type);
      }
      else {
        // if not wrappered yet, its dirty (this can't occur, because
        // we now always call wrap() before getting to here)
        // return ( ! (obj instanceof PersistentCollection) ) ?
        //true : searchForDirtyCollections( (PersistentCollection) obj, type );
        persistentCollection = (PersistentCollection) collection;
      }

      if ( persistentCollection.isDirty() ) { //we need to check even if it was not initialized, because of delayed adds!
        dirty=true;
        return null; //NOTE: EARLY EXIT!
      }
    }
View Full Code Here

    if (collection==CollectionType.UNFETCHED_COLLECTION) {
      return null;
    }

    if (collection!=null) {
      final PersistentCollection coll;
      if ( type.hasHolder() ) {
        coll = getSession().getPersistenceContext().getCollectionHolder(collection);
      }
      else {
        coll = (PersistentCollection) collection;
View Full Code Here

TOP

Related Classes of org.hibernate.collection.spi.PersistentCollection

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.