Package org.hibernate.id

Examples of org.hibernate.id.IdentifierGenerator


  }

  public void testInsertWithGeneratedId() {
    // Make sure the env supports bulk inserts with generated ids...
    EntityPersister persister = sfi().getEntityPersister( PettingZoo.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    if ( !HqlSqlWalker.supportsIdGenWithBulkInsertion( generator ) ) {
      return;
    }

    // create a Zoo
View Full Code Here


  }

  public void testInsertWithGeneratedVersionAndId() {
    // Make sure the env supports bulk inserts with generated ids...
    EntityPersister persister = sfi().getEntityPersister( IntegerVersioned.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    if ( !HqlSqlWalker.supportsIdGenWithBulkInsertion( generator ) ) {
      return;
    }

    Session s = openSession();
View Full Code Here

  }

  public void testInsertWithGeneratedTimestampVersion() {
    // Make sure the env supports bulk inserts with generated ids...
    EntityPersister persister = sfi().getEntityPersister( TimestampVersioned.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    if ( !HqlSqlWalker.supportsIdGenWithBulkInsertion( generator ) ) {
      return;
    }

    // dialects which do not allow a parameter in the select portion of an INSERT ... SELECT statement
View Full Code Here

    identifierGenerators = new HashMap();
    Iterator classes = cfg.getClassMappings();
    while ( classes.hasNext() ) {
      PersistentClass model = (PersistentClass) classes.next();
      if ( !model.isInherited() ) {
        IdentifierGenerator generator = model.getIdentifier().createIdentifierGenerator(
            cfg.getIdentifierGeneratorFactory(),
            getDialect(),
                settings.getDefaultCatalogName(),
                settings.getDefaultSchemaName(),
                (RootClass) model
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );

    for ( PersistentClass pc : classes.values() ) {
      if ( !pc.isInherited() ) {
        IdentifierGenerator ig = pc.getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            (RootClass) pc
        );

        if ( ig instanceof PersistentIdentifierGenerator ) {
          generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
        }
        else if ( ig instanceof IdentifierGeneratorAggregator ) {
          ( (IdentifierGeneratorAggregator) ig ).registerPersistentGenerators( generators );
        }
      }
    }

    for ( Collection collection : collections.values() ) {
      if ( collection.isIdentified() ) {
        IdentifierGenerator ig = ( ( IdentifierCollection ) collection ).getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            null
View Full Code Here

    if ( !insertStatement.getIntoClause().isExplicitIdInsertion() ) {
      // the insert did not explicitly reference the id.  See if
      //    1) that is allowed
      //    2) whether we need to alter the SQL tree to account for id
      final IdentifierGenerator generator = persister.getIdentifierGenerator();
      if ( !BulkInsertionCapableIdentifierGenerator.class.isInstance( generator ) ) {
        throw new QueryException(
            "Invalid identifier generator encountered for implicit id handling as part of bulk insertions"
        );
      }
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );

    for ( PersistentClass pc : classes.values() ) {
      if ( !pc.isInherited() ) {
        IdentifierGenerator ig = pc.getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            (RootClass) pc
        );

        if ( ig instanceof PersistentIdentifierGenerator ) {
          generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
        }
        else if ( ig instanceof IdentifierGeneratorAggregator ) {
          ( (IdentifierGeneratorAggregator) ig ).registerPersistentGenerators( generators );
        }
      }
    }

    for ( Collection collection : collections.values() ) {
      if ( collection.isIdentified() ) {
        IdentifierGenerator ig = ( ( IdentifierCollection ) collection ).getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            null
View Full Code Here

    while ( iter.hasNext() ) {
      PersistentClass pc = (PersistentClass) iter.next();

      if ( !pc.isInherited() ) {

        IdentifierGenerator ig = pc.getIdentifier()
            .createIdentifierGenerator(
                cfg.getIdentifierGeneratorFactory(),
                dialect,
                defaultCatalog,
                defaultSchema,
                (RootClass) pc
              );

        if ( ig instanceof PersistentIdentifierGenerator ) {
          generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
        }

      }
    }

    iter = getConfiguration().getCollectionMappings();
    while ( iter.hasNext() ) {
      Collection collection = (Collection) iter.next();

      if ( collection.isIdentified() ) {

        IdentifierGenerator ig = ( (IdentifierCollection) collection ).getIdentifier()
            .createIdentifierGenerator(
                getConfiguration().getIdentifierGeneratorFactory(),
                dialect,
                defaultCatalog,
                defaultSchema,
View Full Code Here

    String defaultCatalog = properties.getProperty( Environment.DEFAULT_CATALOG );
    String defaultSchema = properties.getProperty( Environment.DEFAULT_SCHEMA );

    for ( PersistentClass pc : classes.values() ) {
      if ( !pc.isInherited() ) {
        IdentifierGenerator ig = pc.getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            (RootClass) pc
        );

        if ( ig instanceof PersistentIdentifierGenerator ) {
          generators.put( ( (PersistentIdentifierGenerator) ig ).generatorKey(), ig );
        }
        else if ( ig instanceof IdentifierGeneratorAggregator ) {
          ( (IdentifierGeneratorAggregator) ig ).registerPersistentGenerators( generators );
        }
      }
    }

    for ( Collection collection : collections.values() ) {
      if ( collection.isIdentified() ) {
        IdentifierGenerator ig = ( ( IdentifierCollection ) collection ).getIdentifier().createIdentifierGenerator(
            getIdentifierGeneratorFactory(),
            dialect,
            defaultCatalog,
            defaultSchema,
            null
View Full Code Here

    if ( !insertStatement.getIntoClause().isExplicitIdInsertion() ) {
      // We need to generate ids as part of this bulk insert.
      //
      // Note that this is only supported for sequence-style generators and
      // post-insert-style generators; basically, only in-db generators
      IdentifierGenerator generator = persister.getIdentifierGenerator();
      if ( !supportsIdGenWithBulkInsertion( generator ) ) {
        throw new QueryException( "can only generate ids as part of bulk insert with either sequence or post-insert style generators" );
      }

      AST idSelectExprNode = null;

      if ( SequenceGenerator.class.isAssignableFrom( generator.getClass() ) ) {
        String seqName = ( String ) ( ( SequenceGenerator ) generator ).generatorKey();
        String nextval = sessionFactoryHelper.getFactory().getDialect().getSelectSequenceNextValString( seqName );
        idSelectExprNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, nextval );
      }
      else {
View Full Code Here

TOP

Related Classes of org.hibernate.id.IdentifierGenerator

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.