org.hibernate.id
Class SequenceIdentityGenerator

java.lang.Object
  extended by org.hibernate.id.SequenceGenerator
      extended by org.hibernate.id.SequenceIdentityGenerator
All Implemented Interfaces:
BulkInsertionCapableIdentifierGenerator, Configurable, IdentifierGenerator, PersistentIdentifierGenerator, PostInsertIdentifierGenerator

public class SequenceIdentityGenerator
extends SequenceGenerator
implements PostInsertIdentifierGenerator

A generator which combines sequence generation with immediate retrieval through JDBC3 getGeneratedKeys. In this respect it works much like ANSI-SQL IDENTITY generation.

This generator only known to work with newer Oracle drivers compiled for JDK 1.4 (JDBC3).

Note: Due to a bug in Oracle drivers, sql comments on these insert statements are completely disabled.


Nested Class Summary
static class SequenceIdentityGenerator.Delegate
           
static class SequenceIdentityGenerator.NoCommentsInsert
           
 
Field Summary
 
Fields inherited from class org.hibernate.id.SequenceGenerator
PARAMETERS, SEQUENCE
 
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME, JPA_ENTITY_NAME
 
Fields inherited from interface org.hibernate.id.PersistentIdentifierGenerator
CATALOG, IDENTIFIER_NORMALIZER, PK, SCHEMA, TABLE, TABLES
 
Constructor Summary
SequenceIdentityGenerator()
           
 
Method Summary
 void configure(Type type, Properties params, Dialect dialect)
          Configure this instance, given the value of parameters specified by the user as <param> elements.
 Serializable generate(SessionImplementor s, Object obj)
          Generate a new identifier.
 InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(PostInsertIdentityPersister persister, Dialect dialect, boolean isGetGeneratedKeysEnabled)
           
 
Methods inherited from class org.hibernate.id.SequenceGenerator
buildHolder, determineBulkInsertionIdentifierGenerationSelectFragment, generateHolder, generatorKey, getIdentifierType, getSequenceName, sqlCreateStrings, sqlDropStrings, supportsBulkInsertionIdentifierGeneration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SequenceIdentityGenerator

public SequenceIdentityGenerator()
Method Detail

generate

public Serializable generate(SessionImplementor s,
                             Object obj)
Description copied from interface: IdentifierGenerator
Generate a new identifier.

Specified by:
generate in interface IdentifierGenerator
Overrides:
generate in class SequenceGenerator
obj - the entity or toplevel collection for which the id is being generated
Returns:
a new identifier

getInsertGeneratedIdentifierDelegate

public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(PostInsertIdentityPersister persister,
                                                                              Dialect dialect,
                                                                              boolean isGetGeneratedKeysEnabled)
                                                                       throws HibernateException
Specified by:
getInsertGeneratedIdentifierDelegate in interface PostInsertIdentifierGenerator
Throws:
HibernateException

configure

public void configure(Type type,
                      Properties params,
                      Dialect dialect)
               throws MappingException
Description copied from interface: Configurable
Configure this instance, given the value of parameters specified by the user as <param> elements. This method is called just once, following instantiation.

Specified by:
configure in interface Configurable
Overrides:
configure in class SequenceGenerator
params - param values, keyed by parameter name
Throws:
MappingException


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.