Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18367 Modified Files: Assigned.cs CounterGenerator.cs ForeignGenerator.cs GuidCombGenerator.cs GuidGenerator.cs IConfigurable.cs IdentifierGeneratorFactory.cs IdentityGenerator.cs IIdentifierGenerator.cs IPersistentIdentifierGenerator.cs SequenceGenerator.cs SequenceHiLoGenerator.cs TableGenerator.cs TableHiLoGenerator.cs UUIDHexGenerator.cs UUIDStringGenerator.cs Log Message: updated alot of the documentation. Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TableGenerator.cs 31 Dec 2004 18:57:22 -0000 1.12 --- TableGenerator.cs 15 Jan 2005 21:16:13 -0000 1.13 *************** *** 13,33 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that uses a database table to store the last /// generated value. /// </summary> /// <remarks> ! /// <para> /// It is not intended that applications use this strategy directly. However, /// it may be used to build other (efficient) strategies. The return type is /// <c>System.Int32</c> ! /// </para> ! /// <para> /// The hi value MUST be fetched in a seperate transaction to the <c>ISession</c> /// transaction so the generator must be able to obtain a new connection and commit it. /// Hence this implementation may not be used when the user is supplying connections. ! /// </para> ! /// <para> ! /// Mapping parameters supported are: <c>table</c>, <c>column</c> ! /// </para> /// </remarks> public class TableGenerator : IPersistentIdentifierGenerator, IConfigurable --- 13,33 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that uses a database table to store the last /// generated value. /// </summary> /// <remarks> ! /// <p> /// It is not intended that applications use this strategy directly. However, /// it may be used to build other (efficient) strategies. The return type is /// <c>System.Int32</c> ! /// </p> ! /// <p> /// The hi value MUST be fetched in a seperate transaction to the <c>ISession</c> /// transaction so the generator must be able to obtain a new connection and commit it. /// Hence this implementation may not be used when the user is supplying connections. ! /// </p> ! /// <p> ! /// The mapping parameters <c>table</c> and <c>column</c> are required. ! /// </p> /// </remarks> public class TableGenerator : IPersistentIdentifierGenerator, IConfigurable *************** *** 35,45 **** private static readonly ILog log = LogManager.GetLogger( typeof( TableGenerator ) ); ! /// <summary></summary> public const string Column = "column"; ! /// <summary></summary> public const string Table = "table"; ! /// <summary></summary> public const string Schema = "schema"; --- 35,51 ---- private static readonly ILog log = LogManager.GetLogger( typeof( TableGenerator ) ); ! /// <summary> ! /// The name of the column parameter. ! /// </summary> public const string Column = "column"; ! /// <summary> ! /// The name of the table parameter. ! /// </summary> public const string Table = "table"; ! /// <summary> ! /// The name of the schema parameter. ! /// </summary> public const string Schema = "schema"; *************** *** 50,59 **** private SqlString updateSql; /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="dialect"></param> public virtual void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { --- 56,68 ---- private SqlString updateSql; + #region IConfigurable Members + /// <summary> ! /// Configures the TableGenerator by reading the value of <c>table</c>, ! /// <c>column</c>, and <c>schema</c> from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public virtual void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { *************** *** 94,104 **** } /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> [MethodImpl( MethodImplOptions.Synchronized )] public virtual object Generate( ISessionImplementor session, object obj ) --- 103,118 ---- } + + #endregion + + #region IIdentifierGenerator Members /// <summary> ! /// Generate a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/> ! /// for the identifier by selecting and updating a value in a table. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/>.</returns> [MethodImpl( MethodImplOptions.Synchronized )] public virtual object Generate( ISessionImplementor session, object obj ) *************** *** 182,185 **** --- 196,201 ---- } + #endregion + /// <summary> /// Index: UUIDStringGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/UUIDStringGenerator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UUIDStringGenerator.cs 31 Dec 2004 18:58:24 -0000 1.4 --- UUIDStringGenerator.cs 15 Jan 2005 21:16:13 -0000 1.5 *************** *** 6,15 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that returns a string of length /// 16. /// </summary> /// <remarks> /// <para> ! /// This string will NOT consist of only alphanumeric characters. Use /// this only if you don't mind unreadable identifiers. /// </para> --- 6,19 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that returns a string of length /// 16. /// </summary> /// <remarks> + /// <p> + /// This id generation strategy is specified in the mapping file as + /// <code><generator class="uuid.string" /></code> + /// </p> /// <para> ! /// The identifier string will NOT consist of only alphanumeric characters. Use /// this only if you don't mind unreadable identifiers. /// </para> *************** *** 20,30 **** public class UUIDStringGenerator : IIdentifierGenerator { /// <summary> ! /// /// </summary> ! /// <param name="cache"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor cache, object obj ) { byte[ ] guidInBytes = new byte[16]; --- 24,36 ---- public class UUIDStringGenerator : IIdentifierGenerator { + #region IIdentifierGenerator Members + /// <summary> ! /// Generate a new <see cref="String"/> for the identifier using the "uuid.string" algorithm. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="String"/>.</returns> ! public object Generate( ISessionImplementor session, object obj ) { byte[ ] guidInBytes = new byte[16]; *************** *** 41,44 **** --- 47,52 ---- return guidBuilder.ToString(); } + + #endregion } } \ No newline at end of file Index: IConfigurable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IConfigurable.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IConfigurable.cs 31 Dec 2004 18:56:22 -0000 1.3 --- IConfigurable.cs 15 Jan 2005 21:16:13 -0000 1.4 *************** *** 14,20 **** /// This method is called just once, followed by instantiation. /// </summary> ! /// <param name="type"></param> ! /// <param name="parms">Param values that are keyed by parameter name.</param> ! /// <param name="d"></param> void Configure( IType type, IDictionary parms, Dialect.Dialect d ); } --- 14,20 ---- /// This method is called just once, followed by instantiation. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="d">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> void Configure( IType type, IDictionary parms, Dialect.Dialect d ); } Index: SequenceHiLoGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/SequenceHiLoGenerator.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SequenceHiLoGenerator.cs 31 Dec 2004 18:57:22 -0000 1.6 --- SequenceHiLoGenerator.cs 15 Jan 2005 21:16:13 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using System.Runtime.CompilerServices; *************** *** 13,24 **** /// </summary> /// <remarks> ! /// <para> ! /// The user may specify a maximum lo value to determine how often new hi values are /// fetched. If sequences are not avaliable, <c>TableHiLoGenerator</c> might be an /// alternative. ! /// </para> ! /// <para> ! /// The mapping parameters supported are: <c>sequence</c>, <c>max_lo</c> ! /// </para> /// </remarks> public class SequenceHiLoGenerator : SequenceGenerator --- 14,35 ---- /// </summary> /// <remarks> ! /// <p> ! /// This id generation strategy is specified in the mapping file as ! /// <code> ! /// <generator class="seqhilo"> ! /// <param name="sequence">uid_sequence</param> ! /// <param name="max_lo">max_lo_value</param> ! /// <param name="schema">db_schema</param> ! /// </generator> ! /// </code> ! /// </p> ! /// <p> ! /// The <c>sequence</c> parameter is required, the <c>max_lo</c> and <c>schema</c> are optional. ! /// </p> ! /// <p> ! /// The user may specify a <c>max_lo</c> value to determine how often new hi values are /// fetched. If sequences are not avaliable, <c>TableHiLoGenerator</c> might be an /// alternative. ! /// </p> /// </remarks> public class SequenceHiLoGenerator : SequenceGenerator *************** *** 26,30 **** private static readonly ILog log = LogManager.GetLogger( typeof( SequenceHiLoGenerator ) ); ! /// <summary></summary> public const string MaxLo = "max_lo"; --- 37,43 ---- private static readonly ILog log = LogManager.GetLogger( typeof( SequenceHiLoGenerator ) ); ! /// <summary> ! /// The name of the maximum low value parameter. ! /// </summary> public const string MaxLo = "max_lo"; *************** *** 34,46 **** private System.Type returnClass; /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="d"></param> ! public override void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { ! base.Configure( type, parms, d ); maxLo = PropertiesHelper.GetInt32( MaxLo, parms, 9 ); lo = maxLo + 1; // so we "clock over" on the first invocation --- 47,62 ---- private System.Type returnClass; + #region IConfigurable Members + /// <summary> ! /// Configures the SequenceHiLoGenerator by reading the value of <c>sequence</c>, <c>max_lo</c>, ! /// and <c>schema</c> from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> ! public override void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { ! base.Configure( type, parms, dialect ); maxLo = PropertiesHelper.GetInt32( MaxLo, parms, 9 ); lo = maxLo + 1; // so we "clock over" on the first invocation *************** *** 48,57 **** } /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> [MethodImpl( MethodImplOptions.Synchronized )] public override object Generate( ISessionImplementor session, object obj ) --- 64,78 ---- } + #endregion + + #region IIdentifierGenerator Members + /// <summary> ! /// Generate an <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/> ! /// for the identifier by using a database sequence. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/>.</returns> [MethodImpl( MethodImplOptions.Synchronized )] public override object Generate( ISessionImplementor session, object obj ) *************** *** 66,69 **** --- 87,92 ---- return IdentifierGeneratorFactory.CreateNumber( hi + lo++, returnClass ); } + #endregion + } } \ No newline at end of file Index: IdentityGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentityGenerator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentityGenerator.cs 31 Dec 2004 18:56:49 -0000 1.4 --- IdentityGenerator.cs 15 Jan 2005 21:16:13 -0000 1.5 *************** *** 4,22 **** { /// <summary> ! /// Indicates to the <see cref="ISession"/> that identity /// (ie. identity/autoincrement column) key generation should be used. /// </summary> /// <remarks> ! /// <para> /// This id generation strategy is specified in the mapping file as ! /// <c><generator class="identity"></c> ! /// </para> ! /// <para> /// This indicates to NHibernate that the database generates the id when /// the entity is inserted. ! /// </para> /// </remarks> public class IdentityGenerator : IIdentifierGenerator { /// <summary> /// This class can not generate the <c>id</c>. It has to get the --- 4,26 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that indicates to the <see cref="ISession"/> that identity /// (ie. identity/autoincrement column) key generation should be used. /// </summary> /// <remarks> ! /// <p> /// This id generation strategy is specified in the mapping file as ! /// <code><generator class="identity" /></code> ! /// or if the database natively supports identity columns ! /// <code><generator class="native" /></code> ! /// </p> ! /// <p> /// This indicates to NHibernate that the database generates the id when /// the entity is inserted. ! /// </p> /// </remarks> public class IdentityGenerator : IIdentifierGenerator { + #region IIdentifierGenerator Members + /// <summary> /// This class can not generate the <c>id</c>. It has to get the *************** *** 34,37 **** --- 38,43 ---- return null; } + + #endregion } } \ No newline at end of file Index: UUIDHexGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/UUIDHexGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UUIDHexGenerator.cs 31 Dec 2004 18:58:24 -0000 1.2 --- UUIDHexGenerator.cs 15 Jan 2005 21:16:13 -0000 1.3 *************** *** 9,39 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that returns a string of length /// 32, 36, or 38 depending on the configuration. /// </summary> /// <remarks> ! /// <para> ! /// This string will consist of only hex digits. Optionally, the string /// may be generated with enclosing characters and seperators between each component /// of the UUID. If there are seperators then the string length will be 36. If a format /// that has enclosing brackets is used, then the string length will be 38. ! /// </para> ! /// <para> ! /// The mapping parameters supported are: <c>format</c> and <c>seperator</c>. ! /// </para> ! /// <para> ! /// <c>format</c> is either "N", "D", "B", or "P". These formats are described in /// the <see cref="System.Guid.ToString(string)">Guid.ToString(String)</see> method. /// If no <c>format</c> is specified the default is "N". ! /// </para> ! /// <para> /// <c>seperator</c> is the char that will replace the "-" if specified. If no value is /// configured then the default seperator for the format will be used. If the format "D", "B", or /// "P" is specified, then the seperator will replace the "-". If the format is "N" then this /// parameter will be ignored. ! /// </para> ! /// <para> /// This class is based on <see cref="System.Guid"/> ! /// </para> /// </remarks> public class UUIDHexGenerator : IIdentifierGenerator, IConfigurable --- 9,52 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that returns a string of length /// 32, 36, or 38 depending on the configuration. /// </summary> /// <remarks> ! /// <p> ! /// This id generation strategy is specified in the mapping file as ! /// <code> ! /// <generator class="uuid.hex"> ! /// <param name="format">format_string</param> ! /// <param name="seperator">seperator_string</param> ! /// </generator> ! /// </code> ! /// </p> ! /// <p> ! /// The <c>format</c> and <c>seperator</c> parameters are optional. ! /// </p> ! /// <p> ! /// The identifier string will consist of only hex digits. Optionally, the identifier string /// may be generated with enclosing characters and seperators between each component /// of the UUID. If there are seperators then the string length will be 36. If a format /// that has enclosing brackets is used, then the string length will be 38. ! /// </p> ! /// <p> ! /// <c>format</c> is either ! /// "N" (<c>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</c>), ! /// "D" (<c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c>), ! /// "B" (<c>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</c>), ! /// or "P" (<c>(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)</c>). These formats are described in /// the <see cref="System.Guid.ToString(string)">Guid.ToString(String)</see> method. /// If no <c>format</c> is specified the default is "N". ! /// </p> ! /// <p> /// <c>seperator</c> is the char that will replace the "-" if specified. If no value is /// configured then the default seperator for the format will be used. If the format "D", "B", or /// "P" is specified, then the seperator will replace the "-". If the format is "N" then this /// parameter will be ignored. ! /// </p> ! /// <p> /// This class is based on <see cref="System.Guid"/> ! /// </p> /// </remarks> public class UUIDHexGenerator : IIdentifierGenerator, IConfigurable *************** *** 46,63 **** //"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" private const string FormatWithDigitsOnly = "N"; ! //xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ! private const string FormatWithHyphens = "D"; ! //{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} ! private const string FormatWithEnclosingBrackets = "B"; ! //(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) ! private const string FormatWithEnclosingParens = "P"; /// <summary> ! /// /// </summary> ! /// <param name="cache"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor cache, object obj ) { string guidString = Guid.NewGuid().ToString( format ); --- 59,72 ---- //"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" private const string FormatWithDigitsOnly = "N"; ! ! #region IIdentifierGenerator Members /// <summary> ! /// Generate a new <see cref="String"/> for the identifier using the "uuid.hex" algorithm. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="String"/>.</returns> ! public object Generate( ISessionImplementor session, object obj ) { string guidString = Guid.NewGuid().ToString( format ); *************** *** 71,82 **** } #region IConfigurable Members /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="dialect"></param> public void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { --- 80,94 ---- } + #endregion + #region IConfigurable Members /// <summary> ! /// Configures the UUIDHexGenerator by reading the value of <c>format</c> and ! /// <c>seperator</c> from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { Index: Assigned.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/Assigned.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Assigned.cs 31 Dec 2004 18:55:56 -0000 1.3 --- Assigned.cs 15 Jan 2005 21:16:12 -0000 1.4 *************** *** 5,11 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that returns the current identifier ! /// assigned to an instance /// </summary> public class Assigned : IIdentifierGenerator { --- 5,17 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that returns the current identifier ! /// assigned to an instance. /// </summary> + /// <remarks> + /// <p> + /// This id generation strategy is specified in the mapping file as + /// <code><generator class="assigned" /></code> + /// </p> + /// </remarks> public class Assigned : IIdentifierGenerator { *************** *** 13,22 **** public static readonly Assigned Instance = new Assigned(); /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> public object Generate( ISessionImplementor session, object obj ) { --- 19,35 ---- public static readonly Assigned Instance = new Assigned(); + #region IIdentifierGenerator Members + /// <summary> ! /// Generates a new identifier by getting the value of the identifier ! /// for the <c>obj</c> parameter. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The value that was assigned to the mapped <c>id</c>'s property.</returns> ! /// <exception cref="IdentifierGenerationException"> ! /// Thrown when a <see cref="PersistentCollection"/> is passed in as the <c>obj</c> or ! /// if the identifier of <c>obj</c> is null. ! /// </exception> public object Generate( ISessionImplementor session, object obj ) { *************** *** 24,28 **** { throw new IdentifierGenerationException( ! "Illegal use of assigned id generation fro a toplevel collection" ); } --- 37,41 ---- { throw new IdentifierGenerationException( ! "Illegal use of assigned id generation for a toplevel collection" ); } *************** *** 37,40 **** --- 50,56 ---- return id; } + + #endregion + } } \ No newline at end of file Index: GuidCombGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/GuidCombGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuidCombGenerator.cs 31 Dec 2004 18:56:22 -0000 1.2 --- GuidCombGenerator.cs 15 Jan 2005 21:16:13 -0000 1.3 *************** *** 5,14 **** { /// <summary> ! /// Generates <see cref="System.Guid"/> values using a strategy suggested Jimmy Nilsson's /// <a href="http://www.informit.com/articles/article.asp?p=25862">article</a> /// on <a href="http://www.informit.com">informit.com</a>. /// </summary> /// <remarks> /// This code was contributed by Donald Mull. /// </remarks> public class GuidCombGenerator : IIdentifierGenerator --- 5,25 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that generates <see cref="System.Guid"/> values ! /// using a strategy suggested Jimmy Nilsson's /// <a href="http://www.informit.com/articles/article.asp?p=25862">article</a> /// on <a href="http://www.informit.com">informit.com</a>. /// </summary> /// <remarks> + /// <p> + /// This id generation strategy is specified in the mapping file as + /// <code><generator class="guid.comb" /></code> + /// </p> + /// <p> + /// The <c>comb</c> algorithm is designed to make the use of GUIDs as Primary Keys, Foreign Keys, + /// and Indexes nearly as efficient as ints. + /// </p> + /// <p> /// This code was contributed by Donald Mull. + /// </p> /// </remarks> public class GuidCombGenerator : IIdentifierGenerator *************** *** 17,25 **** /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> public object Generate( ISessionImplementor session, object obj ) { --- 28,36 ---- /// <summary> ! /// Generate a new <see cref="Guid"/> using the comb algorithm. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Guid"/>.</returns> public object Generate( ISessionImplementor session, object obj ) { *************** *** 27,31 **** } ! /// <summary></summary> private Guid GenerateComb() { --- 38,44 ---- } ! /// <summary> ! /// Generate a new <see cref="Guid"/> using the comb algorithm. ! /// </summary> private Guid GenerateComb() { Index: GuidGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/GuidGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GuidGenerator.cs 31 Dec 2004 18:56:22 -0000 1.2 --- GuidGenerator.cs 15 Jan 2005 21:16:13 -0000 1.3 *************** *** 5,10 **** { /// <summary> ! /// Generates <c>Guid</c> values using <see cref="System.Guid.NewGuid()"/>. /// </summary> public class GuidGenerator : IIdentifierGenerator { --- 5,17 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that generates <see cref="Guid"/> values ! /// using <see cref="System.Guid.NewGuid()">Guid.NewGuid()</see>. /// </summary> + /// <remarks> + /// <p> + /// This id generation strategy is specified in the mapping file as + /// <code><generator class="guid" /></code> + /// </p> + /// </remarks> public class GuidGenerator : IIdentifierGenerator { *************** *** 12,20 **** /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> public object Generate( ISessionImplementor session, object obj ) { --- 19,27 ---- /// <summary> ! /// Generate a new <see cref="Guid"/> for the identifier. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Guid"/>.</returns> public object Generate( ISessionImplementor session, object obj ) { Index: CounterGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/CounterGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CounterGenerator.cs 31 Dec 2004 18:55:56 -0000 1.3 --- CounterGenerator.cs 15 Jan 2005 21:16:12 -0000 1.4 *************** *** 5,9 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that returns a <c>Int64</c> constructed from the system /// time and a counter value. Not safe for use in a clustser! /// </summary> --- 5,9 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that returns a <c>Int64</c> constructed from the system /// time and a counter value. Not safe for use in a clustser! /// </summary> Index: ForeignGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/ForeignGenerator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ForeignGenerator.cs 31 Dec 2004 18:55:56 -0000 1.4 --- ForeignGenerator.cs 15 Jan 2005 21:16:13 -0000 1.5 *************** *** 6,23 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that uses the value of the id property of an associated object ! /// ! /// One mapping parameter is required: property. /// </summary> public class ForeignGenerator : IIdentifierGenerator, IConfigurable { private string propertyName; /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> public object Generate( ISessionImplementor session, object obj ) { --- 6,39 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that uses the value of ! /// the id property of an associated object /// </summary> + /// <remarks> + /// <para> + /// This id generation strategy is specified in the mapping file as + /// <code> + /// <generator class="foreign"> + /// <param name="sequence">uid_sequence</param> + /// </generator> + /// </code> + /// </para> + /// The mapping parameter <c>property</c> is required. + /// </remarks> public class ForeignGenerator : IIdentifierGenerator, IConfigurable { private string propertyName; + #region IIdentifierGenerator Members + /// <summary> ! /// Generates an identifer from the value of a Property. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns> ! /// The identifier value from the associated object or ! /// <see cref="IdentifierGeneratorFactory.ShortCircuitIndicator"/> if the <c>session</c> ! /// already contains <c>obj</c>. ! /// </returns> public object Generate( ISessionImplementor session, object obj ) { *************** *** 25,29 **** .GetClassMetadata( obj.GetType() ) .GetPropertyValue( obj, propertyName ); ! //return session.getEntityIdentifierIfNotUnsaved(associatedObject); object id = session.Save( associatedObject ); if( session.Contains( obj ) ) --- 41,45 ---- .GetClassMetadata( obj.GetType() ) .GetPropertyValue( obj, propertyName ); ! object id = session.Save( associatedObject ); if( session.Contains( obj ) ) *************** *** 31,45 **** //abort the save (the object is already saved by a circular cascade) return IdentifierGeneratorFactory.ShortCircuitIndicator; - //throw new IdentifierGenerationException("save associated object first, or disable cascade for inverse association"); } return id; } /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="d"></param> public void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { --- 47,69 ---- //abort the save (the object is already saved by a circular cascade) return IdentifierGeneratorFactory.ShortCircuitIndicator; } + return id; } + #endregion + + #region IConfigurable Members + /// <summary> ! /// Configures the ForeignGenerator by reading the value of <c>property</c> ! /// from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="d">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> ! /// <exception cref="MappingException"> ! /// Thrown if the key <c>property</c> is not found in the <c>parms</c> parameter. ! /// </exception> public void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { *************** *** 50,53 **** --- 74,79 ---- } } + + #endregion } } \ No newline at end of file Index: IPersistentIdentifierGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IPersistentIdentifierGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IPersistentIdentifierGenerator.cs 31 Dec 2004 18:57:03 -0000 1.3 --- IPersistentIdentifierGenerator.cs 15 Jan 2005 21:16:13 -0000 1.4 *************** *** 2,8 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that requires creation of database objects ! /// All <c>IPersistentIdentifierGenerator</c>s that also implement ! /// <c>IConfigurable</c> have access to a special mapping parameter: schema /// </summary> public interface IPersistentIdentifierGenerator : IIdentifierGenerator --- 2,8 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that requires creation of database objects ! /// All <see cref="IPersistentIdentifierGenerator"/>s that also implement ! /// An <see cref="IConfigurable" /> have access to a special mapping parameter: schema /// </summary> public interface IPersistentIdentifierGenerator : IIdentifierGenerator Index: SequenceGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/SequenceGenerator.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SequenceGenerator.cs 31 Dec 2004 18:57:03 -0000 1.7 --- SequenceGenerator.cs 15 Jan 2005 21:16:13 -0000 1.8 *************** *** 11,17 **** { /// <summary> ! /// Generates <c>Int64</c> values using an oracle-style sequence. A higher performance ! /// algorithm is <see cref="SequenceHiLoGenerator"/> /// </summary> public class SequenceGenerator : IPersistentIdentifierGenerator, IConfigurable { --- 11,32 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that generates <c>Int64</c> values using an ! /// oracle-style sequence. A higher performance algorithm is ! /// <see cref="SequenceHiLoGenerator"/>. /// </summary> + /// <remarks> + /// <p> + /// This id generation strategy is specified in the mapping file as + /// <code> + /// <generator class="sequence"> + /// <param name="sequence">uid_sequence</param> + /// <param name="schema">db_schema</param> + /// </generator> + /// </code> + /// </p> + /// <p> + /// The <c>sequence</c> parameter is required while the <c>schema</c> is optional. + /// </p> + /// </remarks> public class SequenceGenerator : IPersistentIdentifierGenerator, IConfigurable { *************** *** 19,27 **** /// <summary> ! /// The sequence parameter /// </summary> public const string Sequence = "sequence"; ! /// <summary></summary> public const string Schema = "schema"; --- 34,44 ---- /// <summary> ! /// The name of the sequence parameter. /// </summary> public const string Sequence = "sequence"; ! /// <summary> ! /// The name of the schema parameter. ! /// </summary> public const string Schema = "schema"; *************** *** 30,39 **** private string sql; /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="dialect"></param> public virtual void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { --- 47,59 ---- private string sql; + #region IConfigurable Members + /// <summary> ! /// Configures the SequenceGenerator by reading the value of <c>sequence</c> and ! /// <c>schema</c> from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> public virtual void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { *************** *** 48,57 **** } /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> public virtual object Generate( ISessionImplementor session, object obj ) { --- 68,82 ---- } + #endregion + + #region IIdentifierGenerator Members + /// <summary> ! /// Generate an <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/> ! /// for the identifier by using a database sequence. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/>.</returns> public virtual object Generate( ISessionImplementor session, object obj ) { *************** *** 81,84 **** --- 106,111 ---- } + #endregion + /// <summary> /// Index: IIdentifierGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IIdentifierGenerator.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IIdentifierGenerator.cs 31 Dec 2004 18:57:03 -0000 1.4 --- IIdentifierGenerator.cs 15 Jan 2005 21:16:13 -0000 1.5 *************** *** 30,34 **** /// </summary> /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generate</param> /// <returns>The new identifier</returns> object Generate( ISessionImplementor session, object obj ); --- 30,34 ---- /// </summary> /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> /// <returns>The new identifier</returns> object Generate( ISessionImplementor session, object obj ); Index: TableHiLoGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableHiLoGenerator.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TableHiLoGenerator.cs 31 Dec 2004 18:57:22 -0000 1.6 --- TableHiLoGenerator.cs 15 Jan 2005 21:16:13 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + using System; using System.Collections; using System.Runtime.CompilerServices; *************** *** 9,26 **** { /// <summary> ! /// An <c>IIdentifierGenerator</c> that returns an <c>Int64</c>, constructed using /// a hi/lo algorithm. /// </summary> /// <remarks> ! /// <para> ! /// The hi value MUST be fecthed in a seperate transaction to the <c>Session</c> /// transaction so the generator must be able to obtain a new connection and /// commit it. Hence this implmentation may not be used when the user is supplying /// connections. In that case a <see cref="SequenceHiLoGenerator"/> would be a /// better choice (where supported). ! /// </para> ! /// <para> ! /// Mapping parameters supported are: <c>table</c>, <c>column</c>, and <c>max_lo</c> ! /// </para> /// </remarks> public class TableHiLoGenerator : TableGenerator --- 10,39 ---- { /// <summary> ! /// An <see cref="IIdentifierGenerator" /> that returns an <c>Int64</c>, constructed using /// a hi/lo algorithm. /// </summary> /// <remarks> ! /// <p> ! /// This id generation strategy is specified in the mapping file as ! /// <code> ! /// <generator class="hilo"> ! /// <param name="table">table</param> ! /// <param name="column">id_column</param> ! /// <param name="max_lo">max_lo_value</param> ! /// <param name="schema">db_schema</param> ! /// </generator> ! /// </code> ! /// </p> ! /// <p> ! /// The <c>table</c> and <c>column</c> parameters are required, the <c>max_lo</c> and ! /// <c>schema</c> are optional. ! /// </p> ! /// <p> ! /// The hi value MUST be fecthed in a seperate transaction to the <c>ISession</c> /// transaction so the generator must be able to obtain a new connection and /// commit it. Hence this implmentation may not be used when the user is supplying /// connections. In that case a <see cref="SequenceHiLoGenerator"/> would be a /// better choice (where supported). ! /// </p> /// </remarks> public class TableHiLoGenerator : TableGenerator *************** *** 28,32 **** private static readonly ILog log = LogManager.GetLogger( typeof( TableHiLoGenerator ) ); ! /// <summary></summary> public const string MaxLo = "max_lo"; --- 41,47 ---- private static readonly ILog log = LogManager.GetLogger( typeof( TableHiLoGenerator ) ); ! /// <summary> ! /// The name of the max lo parameter. ! /// </summary> public const string MaxLo = "max_lo"; *************** *** 36,48 **** private System.Type returnClass; /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="d"></param> ! public override void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { ! base.Configure( type, parms, d ); maxLo = PropertiesHelper.GetInt32( MaxLo, parms, short.MaxValue ); lo = maxLo + 1; // so we "clock over" on the first invocation --- 51,66 ---- private System.Type returnClass; + #region IConfigurable Members + /// <summary> ! /// Configures the TableHiLoGenerator by reading the value of <c>table</c>, ! /// <c>column</c>, <c>max_lo</c>, and <c>schema</c> from the <c>parms</c> parameter. /// </summary> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> ! public override void Configure( IType type, IDictionary parms, Dialect.Dialect dialect ) { ! base.Configure( type, parms, dialect ); maxLo = PropertiesHelper.GetInt32( MaxLo, parms, short.MaxValue ); lo = maxLo + 1; // so we "clock over" on the first invocation *************** *** 50,59 **** } /// <summary> ! /// /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> [MethodImpl( MethodImplOptions.Synchronized )] public override object Generate( ISessionImplementor session, object obj ) --- 68,82 ---- } + #endregion + + #region IIdentifierGenerator Members + /// <summary> ! /// Generate a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/> ! /// for the identifier by selecting and updating a value in a table. /// </summary> ! /// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param> ! /// <param name="obj">The entity for which the id is being generated.</param> ! /// <returns>The new identifier as a <see cref="Int16"/>, <see cref="Int32"/>, or <see cref="Int64"/>.</returns> [MethodImpl( MethodImplOptions.Synchronized )] public override object Generate( ISessionImplementor session, object obj ) *************** *** 69,72 **** --- 92,98 ---- return IdentifierGeneratorFactory.CreateNumber( hi + lo++, returnClass ); } + + #endregion + } } \ No newline at end of file Index: IdentifierGeneratorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** IdentifierGeneratorFactory.cs 31 Dec 2004 18:56:49 -0000 1.13 --- IdentifierGeneratorFactory.cs 15 Jan 2005 21:16:13 -0000 1.14 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using System.Data; + using NHibernate.Type; *************** *** 9,24 **** /// Factory methods for <c>IdentifierGenerator</c> framework. /// </summary> public sealed class IdentifierGeneratorFactory { /// <summary> ! /// /// </summary> ! /// <param name="rs"></param> ! /// <param name="clazz"></param> ! /// <returns></returns> public static object Get( IDataReader rs, System.Type clazz ) { // here is an interesting one: ! // - MsSql's @@identity returns a numeric - which translates to a C# decimal type. // - MySql LAST_IDENITY() returns an Int64 try --- 10,89 ---- /// Factory methods for <c>IdentifierGenerator</c> framework. /// </summary> + /// <remarks> + /// <p>The built in strategies for identifier generation in NHibernate are:</p> + /// <list type="table"> + /// <listheader> + /// <term>strategy</term> + /// <description>Implementation of strategy</description> + /// </listheader> + /// <item> + /// <term>assigned</term> + /// <description><see cref="Assigned"/></description> + /// </item> + /// <item> + /// <term>foreign</term> + /// <description><see cref="ForeignGenerator"/></description> + /// </item> + /// <item> + /// <term>guid</term> + /// <description><see cref="GuidGenerator"/></description> + /// </item> + /// <item> + /// <term>guid.comb</term> + /// <description><see cref="GuidCombGenerator"/></description> + /// </item> + /// <item> + /// <term>hilo</term> + /// <description><see cref="TableHiLoGenerator"/></description> + /// </item> + /// <item> + /// <term>identity</term> + /// <description><see cref="IdentityGenerator"/></description> + /// </item> + /// <item> + /// <term>native</term> + /// <description> + /// Chooses between <see cref="IdentityGenerator"/>, <see cref="SequenceGenerator"/> + /// , and <see cref="TableHiLoGenerator"/> based on the + /// <see cref="Dialect.Dialect"/>'s capabilities. + /// </description> + /// </item> + /// <item> + /// <term>seqhilo</term> + /// <description><see cref="SequenceHiLoGenerator"/></description> + /// </item> + /// <item> + /// <term>sequence</term> + /// <description><see cref="SequenceGenerator"/></description> + /// </item> + /// <item> + /// <term>uuid.hex</term> + /// <description><see cref="UUIDHexGenerator"/></description> + /// </item> + /// <item> + /// <term>uuid.string</term> + /// <description><see cref="UUIDStringGenerator"/></description> + /// </item> + /// </list> + /// </remarks> public sealed class IdentifierGeneratorFactory { /// <summary> ! /// Gets the value of the identifier from the <see cref="IDataReader"/> and ! /// ensures it is the correct <see cref="System.Type"/>. /// </summary> ! /// <param name="rs">The <see cref="IDataReader"/> to read the identifier value from.</param> ! /// <param name="clazz">The <see cref="System.Type"/> the value should be converted to.</param> ! /// <returns> ! /// The value for the identifier. ! /// </returns> ! /// <exception cref="IdentifierGenerationException"> ! /// Thrown if there is any problem getting the value from the <see cref="IDataReader"/> ! /// or with converting it to the <see cref="System.Type"/>. ! /// </exception> public static object Get( IDataReader rs, System.Type clazz ) { // here is an interesting one: ! // - MsSql's @@identity returns a Decimal // - MySql LAST_IDENITY() returns an Int64 try *************** *** 33,42 **** } private static readonly Hashtable idgenerators = new Hashtable(); ! /// <summary></summary> public static readonly string ShortCircuitIndicator = String.Empty; ! /// <summary></summary> static IdentifierGeneratorFactory() { --- 98,119 ---- } + /// <summary> + /// An <see cref="Hashtable"/> where the <c>key</c> is the strategy and + /// the <c>value</c> is the <see cref="System.Type"/> for the strategy. + /// </summary> private static readonly Hashtable idgenerators = new Hashtable(); ! /// <summary> ! /// When this is returned by <c>Generate()</c> it indicates that the object ! /// has already been saved. ! /// </summary> ! /// <value> ! /// <see cref="String.Empty">String.Empty</see> ! /// </value> public static readonly string ShortCircuitIndicator = String.Empty; ! /// <summary> ! /// Initializes the static fields in <see cref="IdentifierGeneratorFactory"/>. ! /// </summary> static IdentifierGeneratorFactory() { *************** *** 56,69 **** private IdentifierGeneratorFactory() { ! } //cannot be instantiated /// <summary> ! /// /// </summary> ! /// <param name="strategy"></param> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> public static IIdentifierGenerator Create( string strategy, IType type, IDictionary parms, Dialect.Dialect dialect ) { --- 133,156 ---- private IdentifierGeneratorFactory() { ! //cannot be instantiated ! } /// <summary> ! /// Creates an <see cref="IIdentifierGenerator"/> from the named strategy. /// </summary> ! /// <param name="strategy"> ! /// The name of the generator to create. This can be one of the NHibernate abbreviations (ie - <c>native</c>, ! /// <c>sequence</c>, <c>guid.comb</c>, etc...), a full class name if the Type is in the NHibernate assembly, or ! /// a full type name if the strategy is in an external assembly. ! /// </param> ! /// <param name="type">The <see cref="IType"/> that the retured identifier should be.</param> ! /// <param name="parms">An <see cref="IDictionary"/> of <c><param></c> values from the mapping.</param> ! /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param> ! /// <returns> ! /// An instantiated and configured <see cref="IIdentifierGenerator"/>. ! /// </returns> ! /// <exception cref="MappingException"> ! /// Thrown if there are any exceptions while creating the <see cref="IIdentifierGenerator"/>. ! /// </exception> public static IIdentifierGenerator Create( string strategy, IType type, IDictionary parms, Dialect.Dialect dialect ) { *************** *** 90,98 **** clazz = System.Type.GetType( strategy ); } IIdentifierGenerator idgen = ( IIdentifierGenerator ) Activator.CreateInstance( clazz ); ! if( idgen is IConfigurable ) { ! ( ( IConfigurable ) idgen ).Configure( type, parms, dialect ); } return idgen; } --- 177,190 ---- clazz = System.Type.GetType( strategy ); } + IIdentifierGenerator idgen = ( IIdentifierGenerator ) Activator.CreateInstance( clazz ); ! ! // configure if the generator supports it. ! IConfigurable configurable = idgen as IConfigurable; ! if( configurable!=null ) { ! configurable.Configure( type, parms, dialect ); } + return idgen; } *************** *** 104,112 **** /// <summary> ! /// /// </summary> ! /// <param name="value"></param> ! /// <param name="type"></param> ! /// <returns></returns> internal static object CreateNumber( long value, System.Type type ) { --- 196,210 ---- /// <summary> ! /// Create the correct boxed <see cref="System.Type"/> for the identifier. /// </summary> ! /// <param name="value">The value of the new identifier.</param> ! /// <param name="type">The <see cref="IType"/> the identifier should be.</param> ! /// <returns> ! /// The identifier value converted to the <see cref="System.Type"/>. ! /// </returns> ! /// <exception cref="IdentifierGenerationException"> ! /// The <c>type</c> parameter must be an <see cref="Int16"/>, <see cref="Int32"/>, ! /// or <see cref="Int64"/>. ! /// </exception> internal static object CreateNumber( long value, System.Type type ) { |