From: Kevin W. <kev...@us...> - 2004-12-31 18:57:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2328 Modified Files: IIdentifierGenerator.cs IPersistentIdentifierGenerator.cs SequenceGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: SequenceGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/SequenceGenerator.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SequenceGenerator.cs 30 Nov 2004 18:36:50 -0000 1.6 --- SequenceGenerator.cs 31 Dec 2004 18:57:03 -0000 1.7 *************** *** 1,7 **** using System; - using System.Data; using System.Collections; ! ! using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.SqlCommand; --- 1,6 ---- using System; using System.Collections; ! using System.Data; ! using log4net; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 9,14 **** using NHibernate.Util; ! ! namespace NHibernate.Id { /// <summary> --- 8,12 ---- using NHibernate.Util; ! namespace NHibernate.Id { /// <summary> *************** *** 16,22 **** /// algorithm is <see cref="SequenceHiLoGenerator"/> /// </summary> ! public class SequenceGenerator : IPersistentIdentifierGenerator, IConfigurable { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(SequenceGenerator)); /// <summary> --- 14,20 ---- /// algorithm is <see cref="SequenceHiLoGenerator"/> /// </summary> ! public class SequenceGenerator : IPersistentIdentifierGenerator, IConfigurable { ! private static readonly ILog log = LogManager.GetLogger( typeof( SequenceGenerator ) ); /// <summary> *************** *** 24,27 **** --- 22,27 ---- /// </summary> public const string Sequence = "sequence"; + + /// <summary></summary> public const string Schema = "schema"; *************** *** 30,85 **** private string sql; ! public virtual void Configure(IType type, IDictionary parms, Dialect.Dialect dialect) { ! this.sequenceName = PropertiesHelper.GetString(Sequence, parms, "hibernate_sequence"); ! string schemaName = (string)parms[Schema]; ! if ( schemaName!=null && sequenceName.IndexOf(StringHelper.Dot)<0 ) ! sequenceName = schemaName + '.' + sequenceName; ! returnClass = type.ReturnedClass; ! sql = dialect.GetSequenceNextValString(sequenceName); } ! public virtual object Generate(ISessionImplementor session, object obj) { ! IDbCommand cmd = session.Batcher.PrepareCommand( new SqlString(sql) ); IDataReader reader = null; ! try { ! reader = session.Batcher.ExecuteReader( cmd ); object result = null; reader.Read(); ! result = IdentifierGeneratorFactory.Get(reader, returnClass); ! log.Debug("sequence ID generated: " + result); return result; } ! // TODO: change to SQLException ! catch (Exception e) { // TODO: add code to log the sql exception throw; ! } ! finally { ! session.Batcher.CloseCommand( cmd, reader); } } ! public string[] SqlCreateStrings(Dialect.Dialect dialect) { ! return new string[] { ! dialect.GetCreateSequenceString(sequenceName) ! }; } ! public string SqlDropString(Dialect.Dialect dialect) { ! return dialect.GetDropSequenceString(sequenceName); } ! public object GeneratorKey() { return sequenceName; } } ! } --- 30,112 ---- 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 ) { ! this.sequenceName = PropertiesHelper.GetString( Sequence, parms, "hibernate_sequence" ); ! string schemaName = ( string ) parms[ Schema ]; ! if( schemaName != null && sequenceName.IndexOf( StringHelper.Dot ) < 0 ) ! { ! sequenceName = schemaName + '.' + sequenceName; ! } ! returnClass = type.ReturnedClass; ! sql = dialect.GetSequenceNextValString( sequenceName ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public virtual object Generate( ISessionImplementor session, object obj ) { ! IDbCommand cmd = session.Batcher.PrepareCommand( new SqlString( sql ) ); IDataReader reader = null; ! try { ! reader = session.Batcher.ExecuteReader( cmd ); object result = null; reader.Read(); ! result = IdentifierGeneratorFactory.Get( reader, returnClass ); ! log.Debug( "sequence ID generated: " + result ); return result; } ! // TODO: change to SQLException ! catch( Exception e ) { // TODO: add code to log the sql exception + log.Error( "error generating sequence", e ); throw; ! } ! finally { ! session.Batcher.CloseCommand( cmd, reader ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string[ ] SqlCreateStrings( Dialect.Dialect dialect ) { ! return new string[ ] ! { ! dialect.GetCreateSequenceString( sequenceName ) ! }; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string SqlDropString( Dialect.Dialect dialect ) { ! return dialect.GetDropSequenceString( sequenceName ); } ! /// <summary></summary> ! public object GeneratorKey() { return sequenceName; } } ! } \ No newline at end of file Index: IIdentifierGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IIdentifierGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IIdentifierGenerator.cs 9 Dec 2004 17:53:14 -0000 1.3 --- IIdentifierGenerator.cs 31 Dec 2004 18:57:03 -0000 1.4 *************** *** 1,8 **** - using System; - using NHibernate.Engine; ! namespace NHibernate.Id { ! /// <summary> /// The general contract between a class that generates unique --- 1,6 ---- using NHibernate.Engine; ! namespace NHibernate.Id ! { /// <summary> /// The general contract between a class that generates unique *************** *** 26,32 **** /// </para> /// </remarks> ! public interface IIdentifierGenerator { - /// <summary> /// Generate a new identifier --- 24,29 ---- /// </para> /// </remarks> ! public interface IIdentifierGenerator { /// <summary> /// Generate a new identifier *************** *** 35,39 **** /// <param name="obj">The entity for which the id is being generate</param> /// <returns>The new identifier</returns> ! object Generate(ISessionImplementor session, object obj); } ! } --- 32,36 ---- /// <param name="obj">The entity for which the id is being generate</param> /// <returns>The new identifier</returns> ! object Generate( ISessionImplementor session, object obj ); } ! } \ No newline at end of file Index: IPersistentIdentifierGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IPersistentIdentifierGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IPersistentIdentifierGenerator.cs 22 Apr 2003 23:47:34 -0000 1.2 --- IPersistentIdentifierGenerator.cs 31 Dec 2004 18:57:03 -0000 1.3 *************** *** 1,6 **** ! using System; ! using NHibernate.Dialect; ! ! namespace NHibernate.Id { /// <summary> /// An <c>IIdentifierGenerator</c> that requires creation of database objects --- 1,4 ---- ! namespace NHibernate.Id ! { /// <summary> /// An <c>IIdentifierGenerator</c> that requires creation of database objects *************** *** 8,22 **** /// <c>IConfigurable</c> have access to a special mapping parameter: schema /// </summary> ! public interface IPersistentIdentifierGenerator : IIdentifierGenerator { ! /// <summary> /// The SQL required to create the underlying database objects /// </summary> ! string[] SqlCreateStrings(Dialect.Dialect dialect); /// <summary> /// The SQL required to remove the underlying database objects /// </summary> ! string SqlDropString(Dialect.Dialect dialect); /// <summary> --- 6,22 ---- /// <c>IConfigurable</c> have access to a special mapping parameter: schema /// </summary> ! public interface IPersistentIdentifierGenerator : IIdentifierGenerator ! { /// <summary> /// The SQL required to create the underlying database objects /// </summary> ! /// <param name="dialect"></param> ! string[ ] SqlCreateStrings( Dialect.Dialect dialect ); /// <summary> /// The SQL required to remove the underlying database objects /// </summary> ! /// <param name="dialect"></param> ! string SqlDropString( Dialect.Dialect dialect ); /// <summary> *************** *** 28,30 **** object GeneratorKey(); } ! } --- 28,30 ---- object GeneratorKey(); } ! } \ No newline at end of file |