Package org.hibernate.collection

Examples of org.hibernate.collection.PersistentCollection


      // (if the collection is uninitialized, hibernate has no way of
      // knowing if the collection is actually empty without querying the db)
      getPersister().remove( getKey(), getSession() );
    }

    final PersistentCollection collection = getCollection();
    if (collection!=null) {
      getSession().getPersistenceContext()
        .getCollectionEntry(collection)
        .afterAction(collection);
    }
View Full Code Here


  public void execute() throws HibernateException {
    final Serializable id = getKey();
    final SessionImplementor session = getSession();
    final CollectionPersister persister = getPersister();
    final PersistentCollection collection = getCollection();
    boolean affectedByFilters = persister.isAffectedByEnabledFilters(session);

    preUpdate();

    if ( !collection.wasInitialized() ) {
      if ( !collection.hasQueuedOperations() ) throw new AssertionFailure( "no queued adds" );
      //do nothing - we only need to notify the cache...
    }
    else if ( !affectedByFilters && collection.empty() ) {
      if ( !emptySnapshot ) persister.remove( id, session );
    }
    else if ( collection.needsRecreate(persister) ) {
      if (affectedByFilters) {
        throw new HibernateException(
          "cannot recreate collection while filter is enabled: " +
          MessageHelper.collectionInfoString( persister, id, persister.getFactory() )
        );
View Full Code Here

  public void execute() throws HibernateException {
    // this method is called when a new non-null collection is persisted
    // or when an existing (non-null) collection is moved to a new owner

    final PersistentCollection collection = getCollection();
   
    preRecreate();

    getPersister().recreate( collection, getKey(), getSession() );
   
View Full Code Here

          //    with the current Session
          //throw new AssertionFailure("bug loading unowned collection");
        }
      }

      PersistentCollection rowCollection = persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, collectionRowKey );

      if ( rowCollection != null ) {
        rowCollection.readFrom( rs, persister, descriptor, owner );
      }

    }
    else if ( optionalKey != null ) {
      // we did not find a collection element in the result set, so we
View Full Code Here

    if (entityMode==EntityMode.DOM4J && !isEmbeddedInXML) {
      return UNFETCHED_COLLECTION;
    }

    // check if collection is currently being loaded
    PersistentCollection collection = persistenceContext.getLoadContexts().locateLoadingCollection( persister, key );
    if ( collection == null ) {
      // check if it is already completely loaded, but unowned
      collection = persistenceContext.useUnownedCollection( new CollectionKey(persister, key, entityMode) );
      if ( collection == null ) {
        // create a new collection wrapper, to be initialized later
        collection = instantiate( session, persister, key );
        collection.setOwner( owner );

        persistenceContext.addUninitializedCollection( persister, collection, key );

        // some collections are not lazy:
        if ( initializeImmediately( entityMode ) ) {
          session.initializeCollection( collection, false );
        }
        else if ( !persister.isLazy() ) {
          persistenceContext.addNonLazyCollection( collection );
        }
 
        if ( hasHolder( entityMode ) ) {
          session.getPersistenceContext().addCollectionHolder( collection );
        }
      }
    }
    collection.setOwner( owner );
    return collection.getValue();
  }
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( getSession().getEntityMode() ) ) {
        coll = getSession().getPersistenceContext().getCollectionHolder(collection);
      }
      else {
        coll = (PersistentCollection) collection;
View Full Code Here

    if ( collection == null ) {
      //do nothing
    }
    else if ( collection instanceof PersistentCollection ) {
      PersistentCollection persistentCollection = ( PersistentCollection ) collection;
      if ( persistentCollection.setCurrentSession( session ) ) {
        if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) {
          // a "detached" collection that originally belonged to the same entity
          if ( persistentCollection.isDirty() ) {
            throw new HibernateException( "reassociated object has dirty collection" );
          }
          reattachCollection( persistentCollection, type );
        }
        else {
View Full Code Here

    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

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

TOP

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