Package org.hibernate.id

Examples of org.hibernate.id.IdentifierGenerator


  }

  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

    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

    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

    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

    data.cleanup();
  }

  protected boolean supportsBulkInsertIdGeneration(Class entityClass) {
    EntityPersister persister = sfi().getEntityPersister( entityClass.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    return HqlSqlWalker.supportsIdGenWithBulkInsertion( generator );
  }
View Full Code Here

  protected void runSchemaDrop() {
  }

  public void testMinimalSequenceEntity() {
    final EntityPersister persister = sfi().getEntityPersister( MinimalSequenceEntity.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
    SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
    assertEquals( MinimalSequenceEntity.SEQ_NAME, seqGenerator.getDatabaseStructure().getName() );
    // 1 is the annotation default
    assertEquals( 1, seqGenerator.getDatabaseStructure().getInitialValue() );
View Full Code Here

    assertFalse( OptimizerFactory.NoopOptimizer.class.isInstance( seqGenerator.getOptimizer() ) );
  }

  public void testCompleteSequenceEntity() {
    final EntityPersister persister = sfi().getEntityPersister( CompleteSequenceEntity.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
    SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
    assertEquals( "my_catalog.my_schema."+CompleteSequenceEntity.SEQ_NAME, seqGenerator.getDatabaseStructure().getName() );
    assertEquals( 1000, seqGenerator.getDatabaseStructure().getInitialValue() );
    assertEquals( 52, seqGenerator.getDatabaseStructure().getIncrementSize() );
View Full Code Here

    assertFalse( OptimizerFactory.NoopOptimizer.class.isInstance( seqGenerator.getOptimizer() ) );
  }

  public void testAutoEntity() {
    final EntityPersister persister = sfi().getEntityPersister( AutoEntity.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );
    SequenceStyleGenerator seqGenerator = (SequenceStyleGenerator) generator;
    assertEquals( SequenceStyleGenerator.DEF_SEQUENCE_NAME, seqGenerator.getDatabaseStructure().getName() );
    assertEquals( SequenceStyleGenerator.DEFAULT_INITIAL_VALUE, seqGenerator.getDatabaseStructure().getInitialValue() );
    assertEquals( SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE, seqGenerator.getDatabaseStructure().getIncrementSize() );
View Full Code Here

    assertEquals( SequenceStyleGenerator.DEFAULT_INCREMENT_SIZE, seqGenerator.getDatabaseStructure().getIncrementSize() );
  }

  public void testMinimalTableEntity() {
    final EntityPersister persister = sfi().getEntityPersister( MinimalTableEntity.class.getName() );
    IdentifierGenerator generator = persister.getIdentifierGenerator();
    assertTrue( TableGenerator.class.isInstance( generator ) );
    TableGenerator tabGenerator = (TableGenerator) generator;
    assertEquals( MinimalTableEntity.TBL_NAME, tabGenerator.getTableName() );
    assertEquals( TableGenerator.DEF_SEGMENT_COLUMN, tabGenerator.getSegmentColumnName() );
    assertEquals( "MINIMAL_TBL", tabGenerator.getSegmentValue() );
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.