C# Class NHibernate.Id.Enhanced.TableGenerator

An enhanced version of table-based id generation.
Unlike the simplistic legacy one (which, btw, was only ever intended for subclassing support) we "segment" the table into multiple values. Thus a single table can actually serve as the persistent storage for multiple independent generators. One approach would be to segment the values by the name of the entity for which we are performing generation, which would mean that we would have a row in the generator table for each entity name. Or any configuration really; the setup is very flexible.

In this respect it is very similar to the legacy MultipleHiLoPerTableGenerator (not available in NHibernate) in terms of the underlying storage structure (namely a single table capable of holding multiple generator values). The differentiator is, as with SequenceStyleGenerator as well, the externalized notion of an optimizer.

NOTE that by default we use a single row for all generators (based on DefaultSegmentValue). The configuration parameter ConfigPreferSegmentPerEntity can be used to change that to instead default to using a row for each entity name.

Configuration parameters:
NAME DEFAULT DESCRIPTION
TableParam DefaultTable The name of the table to use to store/retrieve values
ValueColumnParam DefaultValueColumn The name of column which holds the sequence value for the given segment
SegmentColumnParam DefaultSegmentColumn The name of the column which holds the segment key
SegmentValueParam DefaultSegmentValue The value indicating which segment is used by this generator; refers to values in the SegmentColumnParam column
SegmentLengthParam DefaultSegmentLength The data length of the SegmentColumnParam column; used for schema creation
InitialParam DefaltInitialValue The initial value to be stored for the given segment
IncrementParam DefaultIncrementSize The increment size for the underlying segment; see the discussion on Optimizer for more details.
OptimizerParam depends on defined increment size Allows explicit definition of which optimization strategy to use
Inheritance: NHibernate.Engine.TransactionHelper, IPersistentIdentifierGenerator, IConfigurable
Afficher le fichier Open project: nhibernate/nhibernate-core Class Usage Examples

Méthodes publiques

Méthode Description
Configure ( IType type, string>.IDictionary parms, Dialect dialect ) : void
DoWorkInCurrentTransaction ( ISessionImplementor session, System conn, System transaction ) : object
GeneratorKey ( ) : string
SqlCreateStrings ( Dialect dialect ) : string[]
SqlDropString ( Dialect dialect ) : string[]

Méthodes protégées

Méthode Description
BuildInsertQuery ( ) : void
BuildSelectQuery ( Dialect dialect ) : void
BuildUpdateQuery ( ) : void
DetermineDefaultSegmentValue ( string>.IDictionary parms ) : string

Used in the cases where DetermineSegmentValue is unable to determine the value to use.

DetermineGeneratorTableName ( string>.IDictionary parms, Dialect dialect ) : string

Determine the table name to use for the generator values. Called during configuration.

DetermineIncrementSize ( string>.IDictionary parms ) : int
DetermineInitialValue ( string>.IDictionary parms ) : int
DetermineSegmentColumnName ( string>.IDictionary parms, Dialect dialect ) : string

Determine the name of the column used to indicate the segment for each row. This column acts as the primary key. Called during configuration.

DetermineSegmentColumnSize ( string>.IDictionary parms ) : int

Determine the size of the SegmentColumnName segment column. Called during configuration.

DetermineSegmentValue ( string>.IDictionary parms ) : string

Determine the segment value corresponding to this generator instance. Called during configuration.

DetermineValueColumnName ( string>.IDictionary parms, Dialect dialect ) : string

Determine the name of the column in which we will store the generator persistent value. Called during configuration.

Private Methods

Méthode Description
Generate ( ISessionImplementor session, object obj ) : object

Method Details

BuildInsertQuery() protected méthode

protected BuildInsertQuery ( ) : void
Résultat void

BuildSelectQuery() protected méthode

protected BuildSelectQuery ( Dialect dialect ) : void
dialect Dialect
Résultat void

BuildUpdateQuery() protected méthode

protected BuildUpdateQuery ( ) : void
Résultat void

Configure() public méthode

public Configure ( IType type, string>.IDictionary parms, Dialect dialect ) : void
type IType
parms string>.IDictionary
dialect Dialect
Résultat void

DetermineDefaultSegmentValue() protected méthode

Used in the cases where DetermineSegmentValue is unable to determine the value to use.
protected DetermineDefaultSegmentValue ( string>.IDictionary parms ) : string
parms string>.IDictionary
Résultat string

DetermineGeneratorTableName() protected méthode

Determine the table name to use for the generator values. Called during configuration.
protected DetermineGeneratorTableName ( string>.IDictionary parms, Dialect dialect ) : string
parms string>.IDictionary The parameters supplied in the generator config (plus some standard useful extras).
dialect Dialect The dialect
Résultat string

DetermineIncrementSize() protected méthode

protected DetermineIncrementSize ( string>.IDictionary parms ) : int
parms string>.IDictionary
Résultat int

DetermineInitialValue() protected méthode

protected DetermineInitialValue ( string>.IDictionary parms ) : int
parms string>.IDictionary
Résultat int

DetermineSegmentColumnName() protected méthode

Determine the name of the column used to indicate the segment for each row. This column acts as the primary key. Called during configuration.
protected DetermineSegmentColumnName ( string>.IDictionary parms, Dialect dialect ) : string
parms string>.IDictionary The parameters supplied in the generator config (plus some standard useful extras).
dialect Dialect The
Résultat string

DetermineSegmentColumnSize() protected méthode

Determine the size of the SegmentColumnName segment column. Called during configuration.
protected DetermineSegmentColumnSize ( string>.IDictionary parms ) : int
parms string>.IDictionary
Résultat int

DetermineSegmentValue() protected méthode

Determine the segment value corresponding to this generator instance. Called during configuration.
protected DetermineSegmentValue ( string>.IDictionary parms ) : string
parms string>.IDictionary
Résultat string

DetermineValueColumnName() protected méthode

Determine the name of the column in which we will store the generator persistent value. Called during configuration.
protected DetermineValueColumnName ( string>.IDictionary parms, Dialect dialect ) : string
parms string>.IDictionary
dialect Dialect
Résultat string

DoWorkInCurrentTransaction() public méthode

public DoWorkInCurrentTransaction ( ISessionImplementor session, System conn, System transaction ) : object
session ISessionImplementor
conn System
transaction System
Résultat object

GeneratorKey() public méthode

public GeneratorKey ( ) : string
Résultat string

SqlCreateStrings() public méthode

public SqlCreateStrings ( Dialect dialect ) : string[]
dialect Dialect
Résultat string[]

SqlDropString() public méthode

public SqlDropString ( Dialect dialect ) : string[]
dialect Dialect
Résultat string[]