C# 클래스 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
상속: NHibernate.Engine.TransactionHelper, IPersistentIdentifierGenerator, IConfigurable
파일 보기 프로젝트 열기: nhibernate/nhibernate-core 1 사용 예제들

공개 메소드들

메소드 설명
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[]

보호된 메소드들

메소드 설명
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.

비공개 메소드들

메소드 설명
Generate ( ISessionImplementor session, object obj ) : object

메소드 상세

BuildInsertQuery() 보호된 메소드

protected BuildInsertQuery ( ) : void
리턴 void

BuildSelectQuery() 보호된 메소드

protected BuildSelectQuery ( Dialect dialect ) : void
dialect Dialect
리턴 void

BuildUpdateQuery() 보호된 메소드

protected BuildUpdateQuery ( ) : void
리턴 void

Configure() 공개 메소드

public Configure ( IType type, string>.IDictionary parms, Dialect dialect ) : void
type IType
parms string>.IDictionary
dialect Dialect
리턴 void

DetermineDefaultSegmentValue() 보호된 메소드

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

DetermineGeneratorTableName() 보호된 메소드

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
리턴 string

DetermineIncrementSize() 보호된 메소드

protected DetermineIncrementSize ( string>.IDictionary parms ) : int
parms string>.IDictionary
리턴 int

DetermineInitialValue() 보호된 메소드

protected DetermineInitialValue ( string>.IDictionary parms ) : int
parms string>.IDictionary
리턴 int

DetermineSegmentColumnName() 보호된 메소드

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
리턴 string

DetermineSegmentColumnSize() 보호된 메소드

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

DetermineSegmentValue() 보호된 메소드

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

DetermineValueColumnName() 보호된 메소드

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
리턴 string

DoWorkInCurrentTransaction() 공개 메소드

public DoWorkInCurrentTransaction ( ISessionImplementor session, System conn, System transaction ) : object
session ISessionImplementor
conn System
transaction System
리턴 object

GeneratorKey() 공개 메소드

public GeneratorKey ( ) : string
리턴 string

SqlCreateStrings() 공개 메소드

public SqlCreateStrings ( Dialect dialect ) : string[]
dialect Dialect
리턴 string[]

SqlDropString() 공개 메소드

public SqlDropString ( Dialect dialect ) : string[]
dialect Dialect
리턴 string[]