Package org.hibernate.internal.util.collections

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


    // 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


    // 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

      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

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.