I’ve been using one of NHibernate’s ‘Enhanced’ Id generators for a while:
<id name="Id">
<generator class="NHibernate.Id.Enhanced.TableGenerator">
<param name="prefer_entity_table_as_segment_value">true</param>
<param name="table_name">Keys</param>
<param name="value_column_name">NextKey</param>
<param name="segment_column_name">Type</param>
<param name="optimizer">pooled-lo</param>
<param name="increment_size">6</param>
</generator>
</id>
I spent a little time figuring out how to get the equivalent working with a ‘Fluent’ mapping:
this.Id(f => f.Id)
.GeneratedBy
.Custom<NHibernate.Id.Enhanced.TableGenerator>(
p =>
{
p.AddParam("prefer_entity_table_as_segment_value", "true");
p.AddParam("table_name", "Keys");
p.AddParam("value_column_name", "NextKey");
p.AddParam("segment_column_name", "Entity");
p.AddParam("optimizer", "pooled-lo");
p.AddParam("increment_size", "8");
});
When I first used this generator, it was undocumented. The
documentation has now been updated. These generators are an interesting alternative to HiLo.
No comments:
Post a Comment