Package org.hibernate.internal.util.collections

Examples of org.hibernate.internal.util.collections.IdentitySet


   * @param event The delete event to be handled.
   *
   * @throws HibernateException
   */
  public void onDelete(DeleteEvent event) throws HibernateException {
    onDelete( event, new IdentitySet() );
  }
View Full Code Here


      int max = !hasLimit || queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows().intValue();
      int size = results.size();
      List tmp = new ArrayList();
      IdentitySet distinction = new IdentitySet();
      for ( int i = 0; i < size; i++ ) {
        final Object result = results.get( i );
        if ( !distinction.add( result ) ) {
          continue;
        }
        includedCount++;
        if ( includedCount < first ) {
          continue;
View Full Code Here

            : queryParameters.getRowSelection().getFirstRow();
      int max = !hasLimit || queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows();
      List tmp = new ArrayList();
      IdentitySet distinction = new IdentitySet();
      for ( final Object result : results ) {
        if ( !distinction.add( result ) ) {
          continue;
        }
        includedCount++;
        if ( includedCount < first ) {
          continue;
View Full Code Here

    else {
      queryParametersToUse = queryParameters;
    }

    final List combinedResults = new ArrayList();
    final IdentitySet distinction = new IdentitySet();
    int includedCount = -1;
    translator_loop:
    for ( QueryTranslator translator : translators ) {
      final List tmp = translator.list( session, queryParametersToUse );
      if ( needsLimit ) {
        // NOTE : firstRow is zero-based
        final int first = queryParameters.getRowSelection().getFirstRow() == null
            ? 0
            : queryParameters.getRowSelection().getFirstRow();
        final int max = queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows();
        for ( final Object result : tmp ) {
          if ( !distinction.add( result ) ) {
            continue;
          }
          includedCount++;
          if ( includedCount < first ) {
            continue;
View Full Code Here

    // create the collection holding the Orphans
    Collection res = new ArrayList();

    // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
    java.util.Set currentIds = new HashSet();
    java.util.Set currentSaving = new IdentitySet();
    for ( Iterator it=currentElements.iterator(); it.hasNext(); ) {
      Object current = it.next();
      if ( current!=null && ForeignKeys.isNotTransient(entityName, current, null, session) ) {
        EntityEntry ee = session.getPersistenceContext().getEntry( current );
        if ( ee != null && ee.getStatus() == Status.SAVING ) {
          currentSaving.add( current );
        }
        else {
          Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(entityName, current, session);
          currentIds.add( new TypedValue( idType, currentId, session.getEntityMode() ) );
        }
      }
    }

    // iterate over the *old* list
    for ( Iterator it=oldElements.iterator(); it.hasNext(); ) {
      Object old = it.next();
      if ( ! currentSaving.contains( old ) ) {
        Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
        if ( !currentIds.contains( new TypedValue( idType, oldId, session.getEntityMode() ) ) ) {
          res.add(old);
        }
      }
View Full Code Here

      // Get any existing representations that have already been found.
      detachedEntitiesForManaged = managedToMergeEntitiesXref.get( managedEntity );
    }
    if ( detachedEntitiesForManaged == null ) {
      // There were no existing representations for this particular managed entity;
      detachedEntitiesForManaged = new IdentitySet();
      managedToMergeEntitiesXref.put( managedEntity, detachedEntitiesForManaged );
      incrementEntityNameCount( entityName );
    }
    // Now add the detached representation for the managed entity;
    detachedEntitiesForManaged.add( mergeEntity1 );
View Full Code Here

            : queryParameters.getRowSelection().getFirstRow();
      int max = !hasLimit || queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows();
      List tmp = new ArrayList();
      IdentitySet distinction = new IdentitySet();
      for ( final Object result : results ) {
        if ( !distinction.add( result ) ) {
          continue;
        }
        includedCount++;
        if ( includedCount < first ) {
          continue;
View Full Code Here

    else {
      queryParametersToUse = queryParameters;
    }

    final List combinedResults = new ArrayList();
    final IdentitySet distinction = new IdentitySet();
    int includedCount = -1;
    translator_loop:
    for ( QueryTranslator translator : translators ) {
      final List tmp = translator.list( session, queryParametersToUse );
      if ( needsLimit ) {
        // NOTE : firstRow is zero-based
        final int first = queryParameters.getRowSelection().getFirstRow() == null
            ? 0
            : queryParameters.getRowSelection().getFirstRow();
        final int max = queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows();
        for ( final Object result : tmp ) {
          if ( !distinction.add( result ) ) {
            continue;
          }
          includedCount++;
          if ( includedCount < first ) {
            continue;
View Full Code Here

    // create the collection holding the Orphans
    Collection res = new ArrayList();

    // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
    java.util.Set currentIds = new HashSet();
    java.util.Set currentSaving = new IdentitySet();
    for ( Object current : currentElements ) {
      if ( current != null && ForeignKeys.isNotTransient( entityName, current, null, session ) ) {
        EntityEntry ee = session.getPersistenceContext().getEntry( current );
        if ( ee != null && ee.getStatus() == Status.SAVING ) {
          currentSaving.add( current );
        }
        else {
          Serializable currentId = ForeignKeys.getEntityIdentifierIfNotUnsaved(
              entityName,
              current,
              session
          );
          currentIds.add( new TypedValue( idType, currentId, entityPersister.getEntityMode() ) );
        }
      }
    }

    // iterate over the *old* list
    for ( Object old : oldElements ) {
      if ( !currentSaving.contains( old ) ) {
        Serializable oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
        if ( !currentIds.contains( new TypedValue( idType, oldId, entityPersister.getEntityMode() ) ) ) {
          res.add( old );
        }
      }
View Full Code Here

      queryParametersToUse = queryParameters;
    }

    final int guessedResultSize = guessResultSize( rowSelection );
    final List combinedResults = new ArrayList( guessedResultSize );
    final IdentitySet distinction = new IdentitySet( guessedResultSize );
    int includedCount = -1;
    translator_loop:
    for ( QueryTranslator translator : translators ) {
      final List tmp = translator.list( session, queryParametersToUse );
      if ( needsLimit ) {
        // NOTE : firstRow is zero-based
        final int first = queryParameters.getRowSelection().getFirstRow() == null
            ? 0
            : queryParameters.getRowSelection().getFirstRow();
        final int max = queryParameters.getRowSelection().getMaxRows() == null
            ? -1
            : queryParameters.getRowSelection().getMaxRows();
        for ( final Object result : tmp ) {
          if ( !distinction.add( result ) ) {
            continue;
          }
          includedCount++;
          if ( includedCount < first ) {
            continue;
View Full Code Here

TOP

Related Classes of org.hibernate.internal.util.collections.IdentitySet

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.