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
Пример #1
0
			public TableAccessCallback(ISessionImplementor session, TableGenerator owner)
			{
				this.session = session;
				this.owner = owner;
			}
Пример #2
0
 public TableAccessCallback(ISessionImplementor session, TableGenerator owner)
 {
     this.session = session;
     this.owner   = owner;
 }