Package org.hibernate.persister.collection

Examples of org.hibernate.persister.collection.AbstractCollectionPersister$StandardOrderByAliasResolver


    // If many-to-many, delete the FK row in the collection table.
    // This partially overlaps with DeleteExecutor, but it instead uses the temp table in the idSubselect.
    for ( Type type : targetedPersister.getPropertyTypes() ) {
      if ( type.isCollectionType() ) {
        CollectionType cType = (CollectionType) type;
        AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );
        if ( cPersister.isManyToMany() ) {
          deletes.add( generateDelete( cPersister.getTableName(),
              cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup"));
        }
      }
    }

    String[] tableNames = targetedPersister.getConstraintOrderedTableNameClosure();
View Full Code Here


     
      // If many-to-many, delete the FK row in the collection table.
      for ( Type type : persister.getPropertyTypes() ) {
        if ( type.isCollectionType() ) {
          final CollectionType cType = (CollectionType) type;
          final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
          if ( cPersister.isManyToMany() ) {
            if ( persister.getIdentifierColumnNames().length > 1
                && !dialect.supportsTuplesInSubqueries() ) {
              LOG.warn(
                  "This dialect is unable to cascade the delete into the many-to-many join table" +
                  " when the entity has multiple primary keys.  Either properly setup cascading on" +
                  " the constraints or manually clear the associations prior to deleting the entities."
              );
            }
            else {
              final String idSubselect = "(select "
                  + StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
                  + persister.getTableName() + idSubselectWhere + ")";
              final String where = "(" + StringHelper.join( ", ", cPersister.getKeyColumnNames() )
                  + ") in " + idSubselect;
              final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
              if ( factory.getSettings().isCommentsEnabled() ) {
                delete.setComment( "delete FKs in join table" );
              }
              deletes.add( delete.toStatementString() );
            }
View Full Code Here

    // If many-to-many, delete the FK row in the collection table.
    // This partially overlaps with DeleteExecutor, but it instead uses the temp table in the idSubselect.
    for ( Type type : targetedPersister.getPropertyTypes() ) {
      if ( type.isCollectionType() ) {
        CollectionType cType = (CollectionType) type;
        AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );
        if ( cPersister.isManyToMany() ) {
          deletes.add( generateDelete( cPersister.getTableName(),
              cPersister.getKeyColumnNames(), idSubselect, "bulk delete - m2m join table cleanup"));
        }
      }
    }

    String[] tableNames = targetedPersister.getConstraintOrderedTableNameClosure();
View Full Code Here

     
      // If many-to-many, delete the FK row in the collection table.
      for ( Type type : persister.getPropertyTypes() ) {
        if ( type.isCollectionType() ) {
          final CollectionType cType = (CollectionType) type;
          final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
          if ( cPersister.isManyToMany() ) {
            if (persister.getIdentifierColumnNames().length > 1
                && !dialect.supportsTuplesInSubqueries()) {
              LOG.warn( "This dialect is unable to cascade the delete into the many-to-many join table" +
                  " when the entity has multiple primary keys.  Either properly setup cascading on" +
                  " the constraints or manually clear the associations prior to deleting the entities." );
            }
            else {
              final String idSubselect = "(select "
                  + StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
                  + persister.getTableName() + idSubselectWhere + ")";
              final String where = "(" + StringHelper.join( ", ", cPersister.getKeyColumnNames() )
                  + ") in " + idSubselect;
              final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
              if ( factory.getSettings().isCommentsEnabled() ) {
                delete.setComment( "delete FKs in join table" );
              }
              deletes.add( delete.toStatementString() );
            }
View Full Code Here

     
      // If many-to-many, delete the FK row in the collection table.
      for ( Type type : persister.getPropertyTypes() ) {
        if ( type.isCollectionType() ) {
          final CollectionType cType = (CollectionType) type;
          final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
          if ( cPersister.isManyToMany() ) {
            if (persister.getIdentifierColumnNames().length > 1
                && !dialect.supportsTuplesInSubqueries()) {
              LOG.warn( "This dialect is unable to cascade the delete into the many-to-many join table" +
                  " when the entity has multiple primary keys.  Either properly setup cascading on" +
                  " the constraints or manually clear the associations prior to deleting the entities." );
            }
            else {
              final String idSubselectWhere = gen.getSQL().length() > 7 ? gen.getSQL() : "";
              final String idSubselect = "(select "
                  + StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
                  + persister.getTableName() + idSubselectWhere + ")";
              final String where = "(" + StringHelper.join( ", ", cPersister.getKeyColumnNames() )
                  + ") in " + idSubselect;
              final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
              if ( factory.getSettings().isCommentsEnabled() ) {
                delete.setComment( "delete FKs in join table" );
              }
              deletes.add( delete.toStatementString() );
            }
View Full Code Here

    }

  }

  public void testProperLoaderSetup() {
    AbstractCollectionPersister cp = ( AbstractCollectionPersister )
        sfi().getCollectionPersister( User.class.getName() + ".groups" );
    assertClassAssignability( BatchingCollectionInitializer.class, cp.getInitializer().getClass() );
    BatchingCollectionInitializer initializer = ( BatchingCollectionInitializer ) cp.getInitializer();
    assertEquals( 50, findMaxBatchSize( initializer.getBatchSizes() ) );
  }
View Full Code Here

      }
    }

    Map collMetadata = sf.getAllCollectionMetadata();
    for (Object abstractCollectionPersistObject : collMetadata.values()) {
      AbstractCollectionPersister acp = (AbstractCollectionPersister) abstractCollectionPersistObject;
      if (acp.hasCache()) {
        sf.evictCollection(acp.getCache().getRegionName());
      }
    }
  }
View Full Code Here

    }

  }

  public void testProperLoaderSetup() {
    AbstractCollectionPersister cp = ( AbstractCollectionPersister )
        sfi().getCollectionPersister( User.class.getName() + ".groups" );
    assertClassAssignability( BatchingCollectionInitializer.class, cp.getInitializer().getClass() );
    BatchingCollectionInitializer initializer = ( BatchingCollectionInitializer ) cp.getInitializer();
    assertEquals( 50, findMaxBatchSize( initializer.getBatchSizes() ) );
  }
View Full Code Here

        // (unfortunately) indicated in a number of ways, but here we
        // are mainly concerned with:
        //    1) many-to-many mappings
        //    2) basic collection mappings
        final CollectionType cType = (CollectionType) type;
        final AbstractCollectionPersister cPersister = (AbstractCollectionPersister) factory
              .getCollectionPersister( cType.getRole() );
        final boolean hasCollectionTable = cPersister.isManyToMany()
            || !cPersister.getElementType().isAssociationType();
        if ( !hasCollectionTable ) {
          continue;
        }

        if ( persister.getIdentifierColumnNames().length > 1
            && !dialect.supportsTuplesInSubqueries() ) {
          LOG.warn(
              "This dialect is unable to cascade the delete into the many-to-many join table" +
                  " when the entity has multiple primary keys.  Either properly setup cascading on" +
                  " the constraints or manually clear the associations prior to deleting the entities."
          );
          continue;
        }

        final String idSubselect = "(select "
            + StringHelper.join( ", ", persister.getIdentifierColumnNames() ) + " from "
            + persister.getTableName() + idSubselectWhere + ")";
        final String where = "(" + StringHelper.join( ", ", cPersister.getKeyColumnNames() )
            + ") in " + idSubselect;
        final Delete delete = new Delete().setTableName( cPersister.getTableName() ).setWhere( where );
        if ( factory.getSettings().isCommentsEnabled() ) {
          delete.setComment( "bulk delete - collection table clean up (" + cPersister.getRole() + ")" );
        }
        deletes.add( delete.toStatementString() );
      }
    }
    catch (RecognitionException e) {
View Full Code Here

      if ( ! type.isCollectionType() ) {
        continue;
      }

      final CollectionType cType = (CollectionType) type;
      final AbstractCollectionPersister cPersister = (AbstractCollectionPersister)factory.getCollectionPersister( cType.getRole() );

      // if the plural attribute maps to a "collection table" we need
      // to remove the rows from that table corresponding to any
      // owners we are about to delete.  "collection table" is
      // (unfortunately) indicated in a number of ways, but here we
      // are mainly concerned with:
      //    1) many-to-many mappings
      //    2) basic collection mappings
      final boolean hasCollectionTable = cPersister.isManyToMany()
          || !cPersister.getElementType().isAssociationType();
      if ( !hasCollectionTable ) {
        continue;
      }

      deletes.add(
          generateDelete(
              cPersister.getTableName(),
              cPersister.getKeyColumnNames(),
              idSubselect,
              "bulk delete - collection table clean up (" + cPersister.getRole() + ")"
          )
      );
    }

    String[] tableNames = targetedPersister.getConstraintOrderedTableNameClosure();
View Full Code Here

TOP

Related Classes of org.hibernate.persister.collection.AbstractCollectionPersister$StandardOrderByAliasResolver

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.