Package org.hibernate.persister.collection

Examples of org.hibernate.persister.collection.CollectionPersister


        final Object owner = hasCollectionOwners ?
            row[ collectionOwners[i] ] :
            null; //if null, owner will be retrieved from session

        final CollectionPersister collectionPersister = collectionPersisters[i];
        final Serializable key;
        if ( owner == null ) {
          key = null;
        }
        else {
          key = collectionPersister.getCollectionType().getKeyOfOwner( owner, session );
          //TODO: old version did not require hashmap lookup:
          //keys[collectionOwner].getIdentifier()
        }

        readCollectionElement(
View Full Code Here


        return true;
      }
      else {
        throwLazyInitializationExceptionIfNotConnected();
        CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
        CollectionPersister persister = entry.getLoadedPersister();
        if ( persister.isExtraLazy() ) {
          if ( hasQueuedOperations() ) {
            session.flush();
          }
          cachedSize = persister.getSize( entry.getLoadedKey(), session );
          return true;
        }
      }
    }
    read();
View Full Code Here

 
  protected Boolean readIndexExistence(Object index) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return new Boolean( persister.indexExists( entry.getLoadedKey(), index, session ) );
      }
    }
    read();
    return null;
   
View Full Code Here

 
  protected Boolean readElementExistence(Object element) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return new Boolean( persister.elementExists( entry.getLoadedKey(), element, session ) );
      }
    }
    read();
    return null;
   
View Full Code Here

 
  protected Object readElementByIndex(Object index) {
    if (!initialized) {
      throwLazyInitializationExceptionIfNotConnected();
      CollectionEntry entry = session.getPersistenceContext().getCollectionEntry(this);
      CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        return persister.getElementByIndex( entry.getLoadedKey(), index, session, owner );
      }
    }
    read();
    return UNKNOWN;
   
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() )
        );
      }
      if ( !emptySnapshot ) persister.remove( id, session );
      persister.recreate( collection, id, session );
    }
    else {
      persister.deleteRows( collection, id, session );
      persister.updateRows( collection, id, session );
      persister.insertRows( collection, id, session );
    }

    getSession().getPersistenceContext()
      .getCollectionEntry(collection)
      .afterAction(collection);
View Full Code Here

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

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

  }

  Object processCollection(Object collection, CollectionType type) throws HibernateException {

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

    if ( collection == null ) {
      //do nothing
    }
    else if ( collection instanceof PersistentCollection ) {
View Full Code Here

       
        final Object owner = hasCollectionOwners ?
            row[ collectionOwners[i] ] :
            null; //if null, owner will be retrieved from session

        final CollectionPersister collectionPersister = collectionPersisters[i];
        final Serializable key;
        if ( owner == null ) {
          key = null;
        }
        else {
          key = collectionPersister.getCollectionType().getKeyOfOwner( owner, session );
          //TODO: old version did not require hashmap lookup:
          //keys[collectionOwner].getIdentifier()
        }
 
        readCollectionElement(
View Full Code Here

  private void cascadeCollection(
      final Object child,
      final CascadeStyle style,
      final Object anything,
      final CollectionType type) {
    CollectionPersister persister = eventSource.getFactory()
        .getCollectionPersister( type.getRole() );
    Type elemType = persister.getElementType();

    final int oldCascadeTo = cascadeTo;
    if ( cascadeTo==AFTER_INSERT_BEFORE_DELETE) {
      cascadeTo = AFTER_INSERT_BEFORE_DELETE_VIA_COLLECTION;
    }

    //cascade to current collection elements
    if ( elemType.isEntityType() || elemType.isAnyType() || elemType.isComponentType() ) {
      cascadeCollectionElements(
        child,
        type,
        style,
        elemType,
        anything,
        persister.isCascadeDeleteEnabled()
      );
    }

    cascadeTo = oldCascadeTo;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.persister.collection.CollectionPersister

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.