You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Kevin W. <kev...@us...> - 2004-12-31 19:53:26
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12931 Modified Files: ScheduledCollectionRemove.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ScheduledCollectionRemove.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRemove.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ScheduledCollectionRemove.cs 29 Nov 2004 15:31:07 -0000 1.5 --- ScheduledCollectionRemove.cs 31 Dec 2004 19:53:11 -0000 1.6 *************** *** 1,7 **** - using System; using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> --- 1,6 ---- using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> *************** *** 11,18 **** /// This Collection is not represented in the database anymore. /// </remarks> ! internal sealed class ScheduledCollectionRemove : ScheduledCollectionAction { private bool _emptySnapshot; ! /// <summary> /// Initializes a new instance of <see cref="ScheduledCollectionRemove"/>. --- 10,17 ---- /// This Collection is not represented in the database anymore. /// </remarks> ! internal sealed class ScheduledCollectionRemove : ScheduledCollectionAction { private bool _emptySnapshot; ! /// <summary> /// Initializes a new instance of <see cref="ScheduledCollectionRemove"/>. *************** *** 22,38 **** /// <param name="emptySnapshot">Indicates if the Collection was empty when it was loaded.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRemove(CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session) ! : base(persister, id, session) { _emptySnapshot = emptySnapshot; } ! public override void Execute() { Persister.Softlock( Id ); ! // if there were no entries in the snapshot of the collection then there // is nothing to remove so verify that the snapshot was not empty. ! if( !_emptySnapshot ) { Persister.Remove( Id, Session ); --- 21,38 ---- /// <param name="emptySnapshot">Indicates if the Collection was empty when it was loaded.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRemove( CollectionPersister persister, object id, bool emptySnapshot, ISessionImplementor session ) ! : base( persister, id, session ) { _emptySnapshot = emptySnapshot; } ! /// <summary></summary> ! public override void Execute() { Persister.Softlock( Id ); ! // if there were no entries in the snapshot of the collection then there // is nothing to remove so verify that the snapshot was not empty. ! if( !_emptySnapshot ) { Persister.Remove( Id, Session ); *************** *** 40,42 **** } } ! } --- 40,42 ---- } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:53:02
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12855 Modified Files: ScheduledCollectionRecreate.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ScheduledCollectionRecreate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRecreate.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScheduledCollectionRecreate.cs 29 Nov 2004 15:31:07 -0000 1.4 --- ScheduledCollectionRecreate.cs 31 Dec 2004 19:52:53 -0000 1.5 *************** *** 1,12 **** - using System; using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> /// A scheduled recreation of the Collection in the database. /// </summary> ! internal sealed class ScheduledCollectionRecreate : ScheduledCollectionAction { private PersistentCollection _collection; --- 1,11 ---- using NHibernate.Collection; using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> /// A scheduled recreation of the Collection in the database. /// </summary> ! internal sealed class ScheduledCollectionRecreate : ScheduledCollectionAction { private PersistentCollection _collection; *************** *** 19,29 **** /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRecreate(PersistentCollection collection, CollectionPersister persister, object id, ISessionImplementor session) ! : base(persister, id, session) { _collection = collection; } ! public override void Execute() { Persister.Softlock( Id ); --- 18,29 ---- /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionRecreate( PersistentCollection collection, CollectionPersister persister, object id, ISessionImplementor session ) ! : base( persister, id, session ) { _collection = collection; } ! /// <summary></summary> ! public override void Execute() { Persister.Softlock( Id ); *************** *** 31,33 **** } } ! } --- 31,33 ---- } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:52:52
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12812 Modified Files: ScheduledCollectionAction.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScheduledCollectionAction.cs 9 Dec 2004 22:08:54 -0000 1.8 --- ScheduledCollectionAction.cs 31 Dec 2004 19:52:43 -0000 1.9 *************** *** 1,8 **** - using System; - using NHibernate.Engine; using NHibernate.Collection; ! using NHibernate.Cache; ! namespace NHibernate.Impl { /// <summary> --- 1,6 ---- using NHibernate.Collection; ! using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> *************** *** 10,14 **** /// flush. /// </summary> ! internal abstract class ScheduledCollectionAction : IExecutable { private CollectionPersister _persister; --- 8,12 ---- /// flush. /// </summary> ! internal abstract class ScheduledCollectionAction : IExecutable { private CollectionPersister _persister; *************** *** 22,26 **** /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionAction(CollectionPersister persister, object id, ISessionImplementor session) { _persister = persister; --- 20,24 ---- /// <param name="id">The identifier of the Collection owner.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledCollectionAction( CollectionPersister persister, object id, ISessionImplementor session ) { _persister = persister; *************** *** 32,38 **** /// Gets the <see cref="CollectionPersister"/> that is responsible for persisting the Collection. /// </summary> ! public CollectionPersister Persister { ! get { return _persister;} } --- 30,36 ---- /// Gets the <see cref="CollectionPersister"/> that is responsible for persisting the Collection. /// </summary> ! public CollectionPersister Persister { ! get { return _persister; } } *************** *** 40,46 **** /// Gets the identifier of the Collection owner. /// </summary> ! public object Id { ! get { return _id;} } --- 38,44 ---- /// Gets the identifier of the Collection owner. /// </summary> ! public object Id { ! get { return _id; } } *************** *** 48,59 **** /// Gets the <see cref="ISessionImplementor"/> the action is executing in. /// </summary> ! public ISessionImplementor Session { ! get { return _session;} } #region SessionImpl.IExecutable Members ! public void AfterTransactionCompletion() { _persister.ReleaseSoftlock( _id ); --- 46,58 ---- /// Gets the <see cref="ISessionImplementor"/> the action is executing in. /// </summary> ! public ISessionImplementor Session { ! get { return _session; } } #region SessionImpl.IExecutable Members ! /// <summary></summary> ! public void AfterTransactionCompletion() { _persister.ReleaseSoftlock( _id ); *************** *** 61,72 **** public abstract void Execute(); ! ! public object[] PropertySpaces { ! get { return new string[] { _persister.QualifiedTableName }; } //TODO: cache the array on the persister } - - #endregion } ! } --- 60,71 ---- public abstract void Execute(); ! ! /// <summary></summary> ! public object[ ] PropertySpaces { ! get { return new string[ ] {_persister.QualifiedTableName}; } //TODO: cache the array on the persister } + #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:52:35
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12763 Modified Files: QueryImpl.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: QueryImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/QueryImpl.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** QueryImpl.cs 9 Dec 2004 17:52:15 -0000 1.17 --- QueryImpl.cs 31 Dec 2004 19:52:25 -0000 1.18 *************** *** 2,25 **** using System.Collections; using System.Text; - using NHibernate.Engine; using NHibernate.Proxy; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.Impl { ! [...1139 lines suppressed...] ! /// ! /// </summary> ! /// <param name="name"></param> ! /// <param name="vals"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! public IQuery SetParameterList( string name, object[ ] vals, IType type ) ! { ! return SetParameterList( name, vals, type ); ! } ! ! // ! public IQuery SetParameterList( string name, object[ ] vals ) ! { ! return SetParameterList( name, vals ); ! } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:52:26
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12730 Modified Files: NonBatchingBatcher.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: NonBatchingBatcher.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/NonBatchingBatcher.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** NonBatchingBatcher.cs 14 Sep 2004 17:49:55 -0000 1.6 --- NonBatchingBatcher.cs 31 Dec 2004 19:52:14 -0000 1.7 *************** *** 1,32 **** - using System; using System.Data; using NHibernate.Engine; ! namespace NHibernate.Impl { /// <summary> /// An implementation of the <c>IBatcher</c> inteface that does no batching /// </summary> ! internal class NonBatchingBatcher : BatcherImpl { ! ! public NonBatchingBatcher(ISessionImplementor session) : base(session) ! { } ! public override void AddToBatch(int expectedRowCount) { int rowCount = this.ExecuteNonQuery( this.GetCommand() ); //negative expected row count means we don't know how many rows to expect ! if ( expectedRowCount>0 && expectedRowCount!=rowCount ) { ! throw new HibernateException("SQL update or deletion failed (row not found)"); } } ! protected override void DoExecuteBatch(IDbCommand ps) { } } ! } --- 1,43 ---- using System.Data; using NHibernate.Engine; ! ! namespace NHibernate.Impl { /// <summary> /// An implementation of the <c>IBatcher</c> inteface that does no batching /// </summary> ! internal class NonBatchingBatcher : BatcherImpl { ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! public NonBatchingBatcher( ISessionImplementor session ) : base( session ) ! { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="expectedRowCount"></param> ! public override void AddToBatch( int expectedRowCount ) { int rowCount = this.ExecuteNonQuery( this.GetCommand() ); //negative expected row count means we don't know how many rows to expect ! if( expectedRowCount > 0 && expectedRowCount != rowCount ) { ! throw new HibernateException( "SQL update or deletion failed (row not found)" ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="ps"></param> ! protected override void DoExecuteBatch( IDbCommand ps ) { } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:52:12
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12672 Modified Files: MessageHelper.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: MessageHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/MessageHelper.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MessageHelper.cs 28 Mar 2004 06:07:37 -0000 1.3 --- MessageHelper.cs 31 Dec 2004 19:52:03 -0000 1.4 *************** *** 1,5 **** using System; using System.Text; - using NHibernate.Collection; using NHibernate.Persister; --- 1,4 ---- *************** *** 12,39 **** internal sealed class MessageHelper { ! public static string InfoString(System.Type clazz, object id) { StringBuilder s = new StringBuilder(); ! s.Append('['); ! if(clazz==null) { ! s.Append("<null Class>"); } ! else { s.Append( clazz.Name ); } ! s.Append('#'); ! ! if (id==null) { ! s.Append("<null>"); } ! else { ! s.Append(id); } ! s.Append(']'); ! return s.ToString(); } --- 11,44 ---- internal sealed class MessageHelper { ! /// <summary> ! /// ! /// </summary> ! /// <param name="clazz"></param> ! /// <param name="id"></param> ! /// <returns></returns> ! public static string InfoString( System.Type clazz, object id ) { StringBuilder s = new StringBuilder(); ! s.Append( '[' ); ! if( clazz == null ) { ! s.Append( "<null Class>" ); } ! else { s.Append( clazz.Name ); } ! s.Append( '#' ); ! ! if( id == null ) { ! s.Append( "<null>" ); } ! else { ! s.Append( id ); } ! s.Append( ']' ); ! return s.ToString(); } *************** *** 45,115 **** /// <param name="id">The id</param> /// <returns>String on the form [FooBar#id]</returns> ! public static string InfoString(IClassPersister persister, object id) { StringBuilder s = new StringBuilder(); ! s.Append('['); ! if(persister==null) { ! s.Append("<null ClassPersister>"); } ! else { ! s.Append(persister.ClassName); } ! s.Append('#'); ! ! if (id==null) { ! s.Append("<null>"); } ! else { ! s.Append(id); } ! ! s.Append(']'); return s.ToString(); } ! public static String InfoString(IClassPersister persister) { StringBuilder s = new StringBuilder(); ! s.Append('['); ! if (persister == null) { ! s.Append("<null ClassPersister>"); } ! else { s.Append( persister.ClassName ); } ! s.Append(']'); return s.ToString(); } ! public static String InfoString(CollectionPersister persister, object id) { StringBuilder s = new StringBuilder(); ! s.Append('['); ! if(persister==null) { ! s.Append("<unreferenced>"); } ! else { s.Append( persister.Role ); ! s.Append('#'); ! ! if (id==null) { ! s.Append("<null>"); } ! else { ! s.Append(id); } } ! s.Append(']'); ! return s.ToString(); } --- 50,131 ---- /// <param name="id">The id</param> /// <returns>String on the form [FooBar#id]</returns> ! public static string InfoString( IClassPersister persister, object id ) { StringBuilder s = new StringBuilder(); ! s.Append( '[' ); ! if( persister == null ) { ! s.Append( "<null ClassPersister>" ); } ! else { ! s.Append( persister.ClassName ); } ! s.Append( '#' ); ! ! if( id == null ) { ! s.Append( "<null>" ); } ! else { ! s.Append( id ); } ! ! s.Append( ']' ); return s.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <returns></returns> ! public static String InfoString( IClassPersister persister ) { StringBuilder s = new StringBuilder(); ! s.Append( '[' ); ! if( persister == null ) { ! s.Append( "<null ClassPersister>" ); } ! else { s.Append( persister.ClassName ); } ! s.Append( ']' ); return s.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="persister"></param> ! /// <param name="id"></param> ! /// <returns></returns> ! public static String InfoString( CollectionPersister persister, object id ) { StringBuilder s = new StringBuilder(); ! s.Append( '[' ); ! if( persister == null ) { ! s.Append( "<unreferenced>" ); } ! else { s.Append( persister.Role ); ! s.Append( '#' ); ! ! if( id == null ) { ! s.Append( "<null>" ); } ! else { ! s.Append( id ); } } ! s.Append( ']' ); ! return s.ToString(); } |
From: Kevin W. <kev...@us...> - 2004-12-31 19:52:01
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12587 Modified Files: IExecutable.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IExecutable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/IExecutable.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IExecutable.cs 9 Dec 2004 22:08:54 -0000 1.1 --- IExecutable.cs 31 Dec 2004 19:51:46 -0000 1.2 *************** *** 1,12 **** - using System; - namespace NHibernate.Impl { - /// <summary> /// An action that <see cref="ISession"/> can Execute during a /// <c>Flush</c>. /// </summary> ! internal interface IExecutable { /// <summary> --- 1,9 ---- namespace NHibernate.Impl { /// <summary> /// An action that <see cref="ISession"/> can Execute during a /// <c>Flush</c>. /// </summary> ! internal interface IExecutable { /// <summary> *************** *** 31,36 **** /// a query is executed so stale data is not returned. /// </remarks> ! object[] PropertySpaces { get; } } ! } --- 28,33 ---- /// a query is executed so stale data is not returned. /// </remarks> ! object[ ] PropertySpaces { get; } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:51:41
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12537 Modified Files: FilterImpl.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: FilterImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/FilterImpl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FilterImpl.cs 31 Oct 2004 04:31:00 -0000 1.8 --- FilterImpl.cs 31 Dec 2004 19:51:30 -0000 1.9 *************** *** 1,24 **** - using System; using System.Collections; - using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Impl { - /// <summary> /// Implementation of the <see cref="IQuery"/> interface for collection filters. /// </summary> ! internal class FilterImpl : QueryImpl { private object collection; ! public FilterImpl(string queryString, object collection, ISessionImplementor session) : base(queryString, session) { this.collection = collection; } ! public override IEnumerable Enumerable() { //TODO: see if there is a better way to implement --- 1,28 ---- using System.Collections; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Impl { /// <summary> /// Implementation of the <see cref="IQuery"/> interface for collection filters. /// </summary> ! internal class FilterImpl : QueryImpl { private object collection; ! /// <summary> ! /// ! /// </summary> ! /// <param name="queryString"></param> ! /// <param name="collection"></param> ! /// <param name="session"></param> ! public FilterImpl( string queryString, object collection, ISessionImplementor session ) : base( queryString, session ) { this.collection = collection; } ! /// <summary></summary> ! public override IEnumerable Enumerable() { //TODO: see if there is a better way to implement *************** *** 32,36 **** } ! public override IList List() { //TODO: see if there is a better way to implement --- 36,41 ---- } ! /// <summary></summary> ! public override IList List() { //TODO: see if there is a better way to implement *************** *** 44,66 **** } ! private IType[] TypeArray() { IList typeList = Types; int size = typeList.Count; ! IType[] result = new IType[size+1]; ! for (int i=0; i<size; i++) ! result[i+1] = (IType) typeList[i]; return result; } ! private object[] ValueArray() { IList valueList = Values; int size = valueList.Count; ! object[] result = new object[size+1]; ! for (int i=0; i<size; i++) ! result[i+1] = valueList[i]; return result; } } ! } --- 49,75 ---- } ! private IType[ ] TypeArray() { IList typeList = Types; int size = typeList.Count; ! IType[ ] result = new IType[size + 1]; ! for( int i = 0; i < size; i++ ) ! { ! result[ i + 1 ] = ( IType ) typeList[ i ]; ! } return result; } ! private object[ ] ValueArray() { IList valueList = Values; int size = valueList.Count; ! object[ ] result = new object[size + 1]; ! for( int i = 0; i < size; i++ ) ! { ! result[ i + 1 ] = valueList[ i ]; ! } return result; } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:51:29
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12503 Modified Files: EnumerableImpl.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: EnumerableImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/EnumerableImpl.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EnumerableImpl.cs 29 Nov 2004 18:43:21 -0000 1.7 --- EnumerableImpl.cs 31 Dec 2004 19:51:20 -0000 1.8 *************** *** 1,10 **** - using System; using System.Collections; using System.Data; ! using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Impl { /// <summary> --- 1,9 ---- using System.Collections; using System.Data; ! using log4net; using NHibernate.Engine; using NHibernate.Type; ! namespace NHibernate.Impl { /// <summary> *************** *** 16,28 **** internal class EnumerableImpl : IEnumerable, IEnumerator { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(EnumerableImpl)); ! private IDataReader _reader; private ISessionImplementor _sess; ! private IType[] _types; private bool _single; ! private object[] _currentResults; private bool _hasNext; ! private string[][] _names; private IDbCommand _cmd; --- 15,27 ---- internal class EnumerableImpl : IEnumerable, IEnumerator { ! private static readonly ILog log = LogManager.GetLogger( typeof( EnumerableImpl ) ); ! private IDataReader _reader; private ISessionImplementor _sess; ! private IType[ ] _types; private bool _single; ! private object[ ] _currentResults; private bool _hasNext; ! private string[ ][ ] _names; private IDbCommand _cmd; *************** *** 45,49 **** /// The <see cref="IDataReader"/> should already be positioned on the first record in <see cref="RowSelection"/>. /// </remarks> ! public EnumerableImpl(IDataReader reader, IDbCommand cmd, ISessionImplementor sess, IType[] types, string[][] columnNames, RowSelection selection) { _reader = reader; --- 44,48 ---- /// The <see cref="IDataReader"/> should already be positioned on the first record in <see cref="RowSelection"/>. /// </remarks> ! public EnumerableImpl( IDataReader reader, IDbCommand cmd, ISessionImplementor sess, IType[ ] types, string[ ][ ] columnNames, RowSelection selection ) { _reader = reader; *************** *** 54,83 **** _selection = selection; ! _single = _types.Length==1; } ! private void PostMoveNext(bool hasNext) { _hasNext = hasNext; _currentRow++; ! if( _selection!=null && _selection.MaxRows!=RowSelection.NoValue ) { _hasNext = _hasNext && ( _currentRow < _selection.MaxRows ); } // there are no more records in the DataReader so clean up ! if( !_hasNext ) { ! log.Debug("exhausted results"); _currentResults = null; _sess.Batcher.CloseQueryCommand( _cmd, _reader ); ! } ! else { ! log.Debug("retreiving next results"); _currentResults = new object[_types.Length]; ! // move through each of the ITypes contained in the IDataReader and convert them // to their objects. ! for (int i=0; i<_types.Length; i++) { // The IType knows how to extract its value out of the IDataReader. If the IType --- 53,82 ---- _selection = selection; ! _single = _types.Length == 1; } ! private void PostMoveNext( bool hasNext ) { _hasNext = hasNext; _currentRow++; ! if( _selection != null && _selection.MaxRows != RowSelection.NoValue ) { _hasNext = _hasNext && ( _currentRow < _selection.MaxRows ); } // there are no more records in the DataReader so clean up ! if( !_hasNext ) { ! log.Debug( "exhausted results" ); _currentResults = null; _sess.Batcher.CloseQueryCommand( _cmd, _reader ); ! } ! else { ! log.Debug( "retreiving next results" ); _currentResults = new object[_types.Length]; ! // move through each of the ITypes contained in the IDataReader and convert them // to their objects. ! for( int i = 0; i < _types.Length; i++ ) { // The IType knows how to extract its value out of the IDataReader. If the IType *************** *** 85,89 **** // the IType is an Entity type then the IType will extract the id from the IDataReader // and use the ISession to load an instance of the object. ! _currentResults[i] = _types[i].NullSafeGet(_reader, _names[i], _sess, null); } } --- 84,88 ---- // the IType is an Entity type then the IType will extract the id from the IDataReader // and use the ISession to load an instance of the object. ! _currentResults[ i ] = _types[ i ].NullSafeGet( _reader, _names[ i ], _sess, null ); } } *************** *** 96,100 **** /// An <see cref="IEnumerator" /> that can be used to iterate through the query results. /// </returns> ! public IEnumerator GetEnumerator() { this.Reset(); --- 95,99 ---- /// An <see cref="IEnumerator" /> that can be used to iterate through the query results. /// </returns> ! public IEnumerator GetEnumerator() { this.Reset(); *************** *** 114,126 **** /// returned. /// </remarks> ! public object Current { ! get { ! if( _single ) { ! return _currentResults[0]; ! } ! else { return _currentResults; --- 113,125 ---- /// returned. /// </remarks> ! public object Current { ! get { ! if( _single ) { ! return _currentResults[ 0 ]; ! } ! else { return _currentResults; *************** *** 136,147 **** /// ; <c>false</c> if the enumerator has passed the end of the query results. ///</returns> ! public bool MoveNext() { PostMoveNext( _reader.Read() ); ! return _hasNext; } ! public void Reset() { //can't reset the reader...we are SOL --- 135,147 ---- /// ; <c>false</c> if the enumerator has passed the end of the query results. ///</returns> ! public bool MoveNext() { PostMoveNext( _reader.Read() ); ! return _hasNext; } ! /// <summary></summary> ! public void Reset() { //can't reset the reader...we are SOL *************** *** 150,152 **** } ! } --- 150,152 ---- } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:51:18
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12457 Modified Files: CriteriaImpl.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CriteriaImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CriteriaImpl.cs 2 Sep 2004 04:00:41 -0000 1.7 --- CriteriaImpl.cs 31 Dec 2004 19:51:05 -0000 1.8 *************** *** 1,14 **** - using System; using System.Collections; - using NHibernate.Engine; using NExpression = NHibernate.Expression; ! namespace NHibernate.Impl { /// <summary> /// Implementation of the <see cref="ICriteria"/> interface /// </summary> ! internal class CriteriaImpl : ICriteria { private IList expressions = new ArrayList(); --- 1,12 ---- using System.Collections; using NHibernate.Engine; using NExpression = NHibernate.Expression; ! namespace NHibernate.Impl { /// <summary> /// Implementation of the <see cref="ICriteria"/> interface /// </summary> ! internal class CriteriaImpl : ICriteria { private IList expressions = new ArrayList(); *************** *** 19,115 **** private System.Type persistentClass; private SessionImpl session; ! private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); ! ! public ICriteria SetMaxResults(int maxResults) { selection.MaxRows = maxResults; return this; } ! ! public ICriteria SetFirstResult(int firstResult) { selection.FirstRow = firstResult; return this; } ! ! public ICriteria SetTimeout(int timeout) { selection.Timeout = timeout; return this; } ! ! public ICriteria Add(NExpression.Expression expression) { ! expressions.Add(expression); ! conjunction.Add(expression); return this; } ! //ADDED this ! public NExpression.Expression Expression { ! get {return conjunction;} } ! ! public RowSelection Selection { get { return selection; } } ! ! public CriteriaImpl(System.Type persistentClass, SessionImpl session) { this.persistentClass = persistentClass; this.session = session; } ! ! public IList List() { ! return session.Find(this); } ! ! public IEnumerator IterateExpressions() { return expressions.GetEnumerator(); } ! ! public IEnumerator IterateOrderings() ! { ! return orderings.GetEnumerator(); ! } ! ! public System.Type PersistentClass { get { return persistentClass; } } ! ! public override string ToString() { return expressions.ToString(); } ! public ICriteria AddOrder(NExpression.Order ordering) ! { ! orderings.Add(ordering); ! return this; ! } ! public FetchMode GetFetchMode(string path) { ! if (fetchModes.Contains(path)) { ! return (FetchMode)fetchModes[path]; } else { ! return FetchMode.Default; } } ! public ICriteria SetFetchMode(string associationPath, FetchMode mode) { ! fetchModes[associationPath] = mode; return this; } } ! } --- 17,161 ---- private System.Type persistentClass; private SessionImpl session; ! private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); ! /// <summary> ! /// ! /// </summary> ! /// <param name="maxResults"></param> ! /// <returns></returns> ! public ICriteria SetMaxResults( int maxResults ) { selection.MaxRows = maxResults; return this; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="firstResult"></param> ! /// <returns></returns> ! public ICriteria SetFirstResult( int firstResult ) { selection.FirstRow = firstResult; return this; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="timeout"></param> ! /// <returns></returns> ! public ICriteria SetTimeout( int timeout ) { selection.Timeout = timeout; return this; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="expression"></param> ! /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { ! expressions.Add( expression ); ! conjunction.Add( expression ); return this; } ! //ADDED this ! /// <summary></summary> ! public NExpression.Expression Expression { ! get { return conjunction; } } ! ! /// <summary></summary> ! public RowSelection Selection { get { return selection; } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="persistentClass"></param> ! /// <param name="session"></param> ! public CriteriaImpl( System.Type persistentClass, SessionImpl session ) { this.persistentClass = persistentClass; this.session = session; } ! ! /// <summary></summary> ! public IList List() { ! return session.Find( this ); } ! ! /// <summary></summary> ! public IEnumerator IterateExpressions() { return expressions.GetEnumerator(); } ! ! /// <summary></summary> ! public IEnumerator IterateOrderings() ! { ! return orderings.GetEnumerator(); ! } ! ! /// <summary></summary> ! public System.Type PersistentClass { get { return persistentClass; } } ! ! /// <summary></summary> ! public override string ToString() ! { return expressions.ToString(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="ordering"></param> ! /// <returns></returns> ! public ICriteria AddOrder( NExpression.Order ordering ) ! { ! orderings.Add( ordering ); ! return this; ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="path"></param> ! /// <returns></returns> ! public FetchMode GetFetchMode( string path ) { ! if( fetchModes.Contains( path ) ) { ! return ( FetchMode ) fetchModes[ path ]; } else { ! return FetchMode.Default; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="associationPath"></param> ! /// <param name="mode"></param> ! /// <returns></returns> ! public ICriteria SetFetchMode( string associationPath, FetchMode mode ) { ! fetchModes[ associationPath ] = mode; return this; } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:51:05
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12394 Modified Files: CollectionEntry.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CollectionEntry.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CollectionEntry.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollectionEntry.cs 11 Dec 2004 20:58:46 -0000 1.2 --- CollectionEntry.cs 31 Dec 2004 19:50:54 -0000 1.3 *************** *** 1,5 **** using System; using System.Collections; ! using NHibernate.Collection; using NHibernate.Engine; --- 1,5 ---- using System; using System.Collections; ! using log4net; using NHibernate.Collection; using NHibernate.Engine; *************** *** 12,21 **** /// </summary> [Serializable] ! internal class CollectionEntry : ICollectionSnapshot { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(CollectionEntry) ); internal bool dirty; ! /// <summary> /// Indicates that the Collection can still be reached by an Entity --- 12,22 ---- /// </summary> [Serializable] ! internal class CollectionEntry : ICollectionSnapshot { ! private static readonly ILog log = LogManager.GetLogger( typeof( CollectionEntry ) ); + /// <summary></summary> internal bool dirty; ! /// <summary> /// Indicates that the Collection can still be reached by an Entity *************** *** 26,37 **** /// two Entities. /// </remarks> ! [NonSerialized] internal bool reached; ! /// <summary> /// Indicates that the Collection has been processed and is ready /// to have its state synchronized with the database. /// </summary> ! [NonSerialized] internal bool processed; ! /// <summary> /// Indicates that a Collection needs to be updated. --- 27,40 ---- /// two Entities. /// </remarks> ! [NonSerialized] ! internal bool reached; ! /// <summary> /// Indicates that the Collection has been processed and is ready /// to have its state synchronized with the database. /// </summary> ! [NonSerialized] ! internal bool processed; ! /// <summary> /// Indicates that a Collection needs to be updated. *************** *** 41,46 **** /// have been changed. /// </remarks> ! [NonSerialized] internal bool doupdate; ! /// <summary> /// Indicates that a Collection has old elements that need to be removed. --- 44,50 ---- /// have been changed. /// </remarks> ! [NonSerialized] ! internal bool doupdate; ! /// <summary> /// Indicates that a Collection has old elements that need to be removed. *************** *** 50,55 **** /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. /// </remarks> ! [NonSerialized] internal bool doremove; ! /// <summary> /// Indicates that a Collection needs to be recreated. --- 54,60 ---- /// the key changes and it has a loadedPersister - ie - it was loaded by NHibernate. /// </remarks> ! [NonSerialized] ! internal bool doremove; ! /// <summary> /// Indicates that a Collection needs to be recreated. *************** *** 59,69 **** /// or the owner changes. /// </remarks> ! [NonSerialized] internal bool dorecreate; ! /// <summary> /// Indicates that the Collection has been fully initialized. /// </summary> internal bool initialized; ! /// <summary> /// The <see cref="CollectionPersister"/> that is currently responsible --- 64,75 ---- /// or the owner changes. /// </remarks> ! [NonSerialized] ! internal bool dorecreate; ! /// <summary> /// Indicates that the Collection has been fully initialized. /// </summary> internal bool initialized; ! /// <summary> /// The <see cref="CollectionPersister"/> that is currently responsible *************** *** 74,79 **** /// unreachable collection. /// </remarks> ! [NonSerialized] internal CollectionPersister currentPersister; ! /// <summary> /// The <see cref="CollectionPersister"/> when the Collection was loaded. --- 80,86 ---- /// unreachable collection. /// </remarks> ! [NonSerialized] ! internal CollectionPersister currentPersister; ! /// <summary> /// The <see cref="CollectionPersister"/> when the Collection was loaded. *************** *** 83,92 **** /// was passed in along with a transient object. /// </remarks> ! [NonSerialized] internal CollectionPersister loadedPersister; ! [NonSerialized] internal object currentKey; internal object loadedKey; internal object snapshot; //session-start/post-flush persistent state internal string role; ! /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. --- 90,109 ---- /// was passed in along with a transient object. /// </remarks> ! [NonSerialized] ! internal CollectionPersister loadedPersister; ! ! /// <summary></summary> ! [NonSerialized] ! internal object currentKey; ! ! /// <summary></summary> internal object loadedKey; + + /// <summary></summary> internal object snapshot; //session-start/post-flush persistent state + + /// <summary></summary> internal string role; ! /// <summary> /// Initializes a new instance of <see cref="CollectionEntry"/>. *************** *** 96,100 **** /// has already been initialized. /// </remarks> ! public CollectionEntry() { this.dirty = false; --- 113,117 ---- /// has already been initialized. /// </remarks> ! public CollectionEntry() { this.dirty = false; *************** *** 108,117 **** /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> ! public CollectionEntry(CollectionPersister loadedPersister, object loadedID, bool initialized) { this.dirty = false; this.initialized = initialized; this.loadedKey = loadedID; ! SetLoadedPersister(loadedPersister); } --- 125,134 ---- /// <param name="loadedID">The identifier of the Entity that is the owner of this Collection.</param> /// <param name="initialized">A boolean indicating if the collection has been initialized.</param> ! public CollectionEntry( CollectionPersister loadedPersister, object loadedID, bool initialized ) { this.dirty = false; this.initialized = initialized; this.loadedKey = loadedID; ! SetLoadedPersister( loadedPersister ); } *************** *** 126,130 **** /// <c>cs</c> parameter. /// </remarks> ! public CollectionEntry(ICollectionSnapshot cs, ISessionFactoryImplementor factory) { this.dirty = cs.Dirty; --- 143,147 ---- /// <c>cs</c> parameter. /// </remarks> ! public CollectionEntry( ICollectionSnapshot cs, ISessionFactoryImplementor factory ) { this.dirty = cs.Dirty; *************** *** 144,148 **** /// default behavior; will be overridden in deep lazy collections /// </remarks> ! public virtual bool IsDirty(PersistentCollection coll) { // if this has already been marked as dirty or the collection can not --- 161,165 ---- /// default behavior; will be overridden in deep lazy collections /// </remarks> ! public virtual bool IsDirty( PersistentCollection coll ) { // if this has already been marked as dirty or the collection can not *************** *** 150,160 **** // wrappers are used) and the elements in the collection are not mutable // then return the dirty flag. ! if ( dirty || ( !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable ! ) ) { return dirty; ! } ! else { // need to have the coll determine if it is the same as the snapshot --- 167,177 ---- // wrappers are used) and the elements in the collection are not mutable // then return the dirty flag. ! if( dirty || ( !coll.IsDirectlyAccessible && !loadedPersister.ElementType.IsMutable ! ) ) { return dirty; ! } ! else { // need to have the coll determine if it is the same as the snapshot *************** *** 168,181 **** /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> ! public void PreFlush(PersistentCollection collection) { // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = ( initialized && loadedPersister!=null && IsDirty(collection) ) || ! (!initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache ! if ( log.IsDebugEnabled && dirty && loadedPersister!=null ) { ! log.Debug("Collection dirty: " + MessageHelper.InfoString(loadedPersister, loadedKey) ); } --- 185,198 ---- /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that this CollectionEntry will be responsible for flushing.</param> ! public void PreFlush( PersistentCollection collection ) { // if the collection is initialized and it was previously persistent // initialize the dirty flag ! dirty = ( initialized && loadedPersister != null && IsDirty( collection ) ) || ! ( !initialized && dirty ); //only need this so collection with queued adds will be removed from JCS cache ! if( log.IsDebugEnabled && dirty && loadedPersister != null ) { ! log.Debug( "Collection dirty: " + MessageHelper.InfoString( loadedPersister, loadedKey ) ); } *************** *** 194,201 **** /// </summary> /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> ! public void PostInitialize(PersistentCollection collection) { initialized = true; ! snapshot = collection.GetSnapshot(loadedPersister); } --- 211,218 ---- /// </summary> /// <param name="collection">The initialized <see cref="PersistentCollection"/> that this Entry is for.</param> ! public void PostInitialize( PersistentCollection collection ) { initialized = true; ! snapshot = collection.GetSnapshot( loadedPersister ); } *************** *** 204,213 **** /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> ! public void PostFlush(PersistentCollection collection) { // the CollectionEntry should be processed if we are in the PostFlush() ! if( !processed ) { ! throw new AssertionFailure("Hibernate has a bug processing collections"); } --- 221,230 ---- /// </summary> /// <param name="collection">The <see cref="PersistentCollection"/> that was flushed.</param> ! public void PostFlush( PersistentCollection collection ) { // the CollectionEntry should be processed if we are in the PostFlush() ! if( !processed ) { ! throw new AssertionFailure( "Hibernate has a bug processing collections" ); } *************** *** 218,222 **** SetLoadedPersister( currentPersister ); dirty = false; ! // collection needs to know its' representation in memory and with // the db is now in synch - esp important for collections like a bag --- 235,239 ---- SetLoadedPersister( currentPersister ); dirty = false; ! // collection needs to know its' representation in memory and with // the db is now in synch - esp important for collections like a bag *************** *** 226,232 **** // if it was initialized or any of the scheduled actions were performed then // need to resnpashot the contents of the collection. ! if ( initialized && ( doremove || dorecreate || doupdate ) ) { ! snapshot = collection.GetSnapshot(loadedPersister); //re-snapshot } } --- 243,249 ---- // if it was initialized or any of the scheduled actions were performed then // need to resnpashot the contents of the collection. ! if( initialized && ( doremove || dorecreate || doupdate ) ) { ! snapshot = collection.GetSnapshot( loadedPersister ); //re-snapshot } } *************** *** 234,267 **** #region Engine.ICollectionSnapshot Members ! public object Key { get { return loadedKey; } } ! ! public string Role { get { return role; } } ! ! public object Snapshot { get { return snapshot; } } ! public bool Dirty { get { return dirty; } } ! ! public void SetDirty() { dirty = true; } ! public bool IsInitialized { ! get { return initialized;} } - #endregion --- 251,290 ---- #region Engine.ICollectionSnapshot Members ! /// <summary></summary> ! public object Key { get { return loadedKey; } } ! ! /// <summary></summary> ! public string Role { get { return role; } } ! ! /// <summary></summary> ! public object Snapshot { get { return snapshot; } } ! /// <summary></summary> ! public bool Dirty { get { return dirty; } } ! ! /// <summary></summary> ! public void SetDirty() { dirty = true; } ! ! /// <summary></summary> ! public bool IsInitialized { ! get { return initialized; } } #endregion *************** *** 274,289 **** /// responsible for the Collection. /// </param> ! private void SetLoadedPersister(CollectionPersister persister) { loadedPersister = persister; ! if (persister!=null) { ! role=persister.Role; } } ! public bool SnapshotIsEmpty { ! get { //TODO: implementation here is non-extensible ... --- 297,313 ---- /// responsible for the Collection. /// </param> ! private void SetLoadedPersister( CollectionPersister persister ) { loadedPersister = persister; ! if( persister != null ) { ! role = persister.Role; } } ! /// <summary></summary> ! public bool SnapshotIsEmpty { ! get { //TODO: implementation here is non-extensible ... *************** *** 294,313 **** // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array // ); ! // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able // to just cast it to a ICollection instead of all the diff collections. ! return initialized && snapshot!=null && ( ! ( snapshot is IList && ( (IList) snapshot ).Count==0 ) || // if snapshot is a collection ! ( snapshot is IDictionary && ( (IDictionary) snapshot ).Count==0 ) || // if snapshot is a map ! (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array ! ); } ! } ! public bool IsNew { // TODO: is this correct implementation - h2.0.3 ! get { return initialized && (snapshot==null); } } } ! ! } --- 318,339 ---- // (snapshot.GetType().IsArray && ( (Array) snapshot).Length==0 )// if snapshot is an array // ); ! // TODO: in .NET an IList, IDictionary, and Array are all collections so we might be able // to just cast it to a ICollection instead of all the diff collections. ! return initialized && snapshot != null && ( ! ( snapshot is IList && ( ( IList ) snapshot ).Count == 0 ) || // if snapshot is a collection ! ( snapshot is IDictionary && ( ( IDictionary ) snapshot ).Count == 0 ) || // if snapshot is a map ! ( snapshot.GetType().IsArray && ( ( Array ) snapshot ).Length == 0 ) // if snapshot is an array ! ); } ! } ! ! /// <summary></summary> ! public bool IsNew { // TODO: is this correct implementation - h2.0.3 ! get { return initialized && ( snapshot == null ); } } } ! ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:50:54
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12365 Modified Files: CacheEntry.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CacheEntry.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CacheEntry.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CacheEntry.cs 28 Mar 2004 06:07:37 -0000 1.3 --- CacheEntry.cs 31 Dec 2004 19:50:45 -0000 1.4 *************** *** 1,12 **** using System; - using System.Data; - using System.Collections; - using NHibernate.Engine; using NHibernate.Persister; using NHibernate.Type; ! ! namespace NHibernate.Impl { /// <summary> --- 1,8 ---- using System; using NHibernate.Engine; using NHibernate.Persister; using NHibernate.Type; ! namespace NHibernate.Impl { /// <summary> *************** *** 14,64 **** /// </summary> [Serializable] ! internal class CacheEntry { ! ! object[] state; ! System.Type subclass; ! public System.Type Subclass { get { return subclass; } } ! public CacheEntry(object obj, IClassPersister persister, ISessionImplementor session) { ! state = Disassemble(obj, persister, session); subclass = obj.GetType(); } ! private object[] Disassemble(object obj, IClassPersister persister, ISessionImplementor session) { ! object[] values = persister.GetPropertyValues(obj); ! IType[] propertyTypes = persister.PropertyTypes; ! for (int i=0; i<values.Length; i++) { ! values[i] = propertyTypes[i].Disassemble(values[i], session); } return values; } ! public object[] Assemble(object instance, object id, IClassPersister persister, ISessionImplementor session) { ! if ( subclass!=persister.MappedClass ) throw new AssertionFailure("Tried to assemble a different subclass instance"); ! return Assemble(state, instance, id, persister, session); } ! private object[] Assemble(object[] values, object result, object id, IClassPersister persister, ISessionImplementor session) { ! IType[] propertyTypes = persister.PropertyTypes; ! object[] assembledProps = new object[propertyTypes.Length]; ! for (int i=0; i<values.Length; i++ ) { ! assembledProps[i] = propertyTypes[i].Assemble( values[i], session, result ); } ! persister.SetPropertyValues(result, assembledProps); ! persister.SetIdentifier(result, id); ! if ( persister.ImplementsLifecycle ) { ! ( (ILifecycle) result ).OnLoad(session, id); } --- 10,95 ---- /// </summary> [Serializable] ! internal class CacheEntry ! { ! private object[ ] state; ! private System.Type subclass; ! /// <summary></summary> ! public System.Type Subclass { get { return subclass; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <param name="persister"></param> ! /// <param name="session"></param> ! public CacheEntry( object obj, IClassPersister persister, ISessionImplementor session ) { ! state = Disassemble( obj, persister, session ); subclass = obj.GetType(); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="obj"></param> ! /// <param name="persister"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! private object[ ] Disassemble( object obj, IClassPersister persister, ISessionImplementor session ) { ! object[ ] values = persister.GetPropertyValues( obj ); ! IType[ ] propertyTypes = persister.PropertyTypes; ! for( int i = 0; i < values.Length; i++ ) { ! values[ i ] = propertyTypes[ i ].Disassemble( values[ i ], session ); } return values; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="instance"></param> ! /// <param name="id"></param> ! /// <param name="persister"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public object[ ] Assemble( object instance, object id, IClassPersister persister, ISessionImplementor session ) { ! if( subclass != persister.MappedClass ) ! { ! throw new AssertionFailure( "Tried to assemble a different subclass instance" ); ! } ! return Assemble( state, instance, id, persister, session ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="values"></param> ! /// <param name="result"></param> ! /// <param name="id"></param> ! /// <param name="persister"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! private object[ ] Assemble( object[ ] values, object result, object id, IClassPersister persister, ISessionImplementor session ) { ! IType[ ] propertyTypes = persister.PropertyTypes; ! object[ ] assembledProps = new object[propertyTypes.Length]; ! for( int i = 0; i < values.Length; i++ ) { ! assembledProps[ i ] = propertyTypes[ i ].Assemble( values[ i ], session, result ); } ! persister.SetPropertyValues( result, assembledProps ); ! persister.SetIdentifier( result, id ); ! if( persister.ImplementsLifecycle ) ! { ! ( ( ILifecycle ) result ).OnLoad( session, id ); } *************** *** 66,68 **** } } ! } --- 97,99 ---- } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 19:50:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12330 Modified Files: BatcherImpl.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BatcherImpl.cs 21 Dec 2004 20:43:40 -0000 1.13 --- BatcherImpl.cs 31 Dec 2004 19:50:33 -0000 1.14 *************** *** 2,25 **** using System.Collections; using System.Data; - using Iesi.Collections; ! using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlCommand; ! namespace NHibernate.Impl { /// <summary> /// Manages prepared statements and batching. Class exists to enfores seperation of concerns /// </summary> ! internal abstract class BatcherImpl : IBatcher { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(BatcherImpl)); private static int openCommandCount; private static int openReaderCount; protected readonly ISessionImplementor session; protected readonly ISessionFactoryImplementor factory; --- 2,27 ---- using System.Collections; using System.Data; using Iesi.Collections; ! using log4net; using NHibernate.Driver; using NHibernate.Engine; using NHibernate.SqlCommand; ! namespace NHibernate.Impl { /// <summary> /// Manages prepared statements and batching. Class exists to enfores seperation of concerns /// </summary> ! internal abstract class BatcherImpl : IBatcher { ! private static readonly ILog log = LogManager.GetLogger( typeof( BatcherImpl ) ); private static int openCommandCount; private static int openReaderCount; + /// <summary></summary> protected readonly ISessionImplementor session; + + /// <summary></summary> protected readonly ISessionFactoryImplementor factory; *************** *** 37,41 **** private IDictionary commands; ! public BatcherImpl(ISessionImplementor session) { this.session = session; --- 39,47 ---- private IDictionary commands; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! public BatcherImpl( ISessionImplementor session ) { this.session = session; *************** *** 47,60 **** /// Gets the current Command that is contained for this Batch /// </summary> ! protected IDbCommand GetCommand() { return batchCommand; } ! ! public IDbCommand Generate(SqlString sqlString) { IDbCommand cmd = commands[ sqlString ] as IDbCommand; ! if( cmd!=null ) { if( log.IsDebugEnabled ) --- 53,71 ---- /// Gets the current Command that is contained for this Batch /// </summary> ! protected IDbCommand GetCommand() { return batchCommand; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlString"></param> ! /// <returns></returns> ! public IDbCommand Generate( SqlString sqlString ) { IDbCommand cmd = commands[ sqlString ] as IDbCommand; ! if( cmd != null ) { if( log.IsDebugEnabled ) *************** *** 67,72 **** // need to build the IDbCommand from the sqlString bec ! cmd = factory.ConnectionProvider.Driver.GenerateCommand(factory.Dialect, sqlString); ! if(log.IsDebugEnabled) { log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() ); --- 78,83 ---- // need to build the IDbCommand from the sqlString bec ! cmd = factory.ConnectionProvider.Driver.GenerateCommand( factory.Dialect, sqlString ); ! if( log.IsDebugEnabled ) { log.Debug( "Building an IDbCommand object for the SqlString: " + sqlString.ToString() ); *************** *** 75,79 **** commands[ sqlString ] = cmd; return cmd; ! } --- 86,90 ---- commands[ sqlString ] = cmd; return cmd; ! } *************** *** 87,146 **** /// supports preparing commands. /// </remarks> ! private void Prepare(IDbCommand command) { ! try { ! if(log.IsInfoEnabled) { ! log.Info("Preparing " + command.CommandText); } ! if( command.Connection!=null ) { // make sure the commands connection is the same as the Sessions connection // these can be different when the session is disconnected and then reconnected ! if( command.Connection!=session.Connection ) { command.Connection = session.Connection; } } ! else { command.Connection = session.Connection; } ! if( session.Transaction!=null ) { session.Transaction.Enlist( command ); } ! if( factory.PrepareSql && factory.ConnectionProvider.Driver.SupportsPreparingCommands ) { command.Prepare(); } } ! catch(Exception e) { throw new ApplicationException( "While preparing " + command.CommandText + " an error occurred" ! , e); } } ! public IDbCommand PrepareBatchCommand(SqlString sql) { ! if ( !sql.Equals(batchCommandSql) ) { ! batchCommand = PrepareCommand(sql); // calls ExecuteBatch() ! batchCommandSql=sql; } return batchCommand; } ! public IDbCommand PrepareCommand(SqlString sql) { ExecuteBatch(); LogOpenPreparedCommands(); ! // do not actually prepare the Command here - instead just generate it because // if the command is associated with an ADO.NET Transaction/Connection while --- 98,167 ---- /// supports preparing commands. /// </remarks> ! private void Prepare( IDbCommand command ) { ! try { ! if( log.IsInfoEnabled ) { ! log.Info( "Preparing " + command.CommandText ); } ! if( command.Connection != null ) { // make sure the commands connection is the same as the Sessions connection // these can be different when the session is disconnected and then reconnected ! if( command.Connection != session.Connection ) { command.Connection = session.Connection; } } ! else { command.Connection = session.Connection; } ! if( session.Transaction != null ) { session.Transaction.Enlist( command ); } ! if( factory.PrepareSql && factory.ConnectionProvider.Driver.SupportsPreparingCommands ) { command.Prepare(); } } ! catch( Exception e ) { throw new ApplicationException( "While preparing " + command.CommandText + " an error occurred" ! , e ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sql"></param> ! /// <returns></returns> ! public IDbCommand PrepareBatchCommand( SqlString sql ) { ! if( !sql.Equals( batchCommandSql ) ) { ! batchCommand = PrepareCommand( sql ); // calls ExecuteBatch() ! batchCommandSql = sql; } return batchCommand; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sql"></param> ! /// <returns></returns> ! public IDbCommand PrepareCommand( SqlString sql ) { ExecuteBatch(); LogOpenPreparedCommands(); ! // do not actually prepare the Command here - instead just generate it because // if the command is associated with an ADO.NET Transaction/Connection while *************** *** 149,154 **** return Generate( sql ); } ! ! public IDbCommand PrepareQueryCommand(SqlString sql, bool scrollable) { //TODO: figure out what to do with scrollable - don't think it applies --- 170,181 ---- return Generate( sql ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sql"></param> ! /// <param name="scrollable"></param> ! /// <returns></returns> ! public IDbCommand PrepareQueryCommand( SqlString sql, bool scrollable ) { //TODO: figure out what to do with scrollable - don't think it applies *************** *** 160,171 **** // another open one Command is doing something then an exception will be // thrown. ! IDbCommand command = Generate( sql ); ! ! commandsToClose.Add(command); ! return command; } ! public void AbortBatch(Exception e) { // log the exception here --- 187,202 ---- // another open one Command is doing something then an exception will be // thrown. ! IDbCommand command = Generate( sql ); ! ! commandsToClose.Add( command ); ! return command; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="e"></param> ! public void AbortBatch( Exception e ) { // log the exception here *************** *** 176,180 **** } ! public int ExecuteNonQuery(IDbCommand cmd) { int rowsAffected = 0; --- 207,216 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <returns></returns> ! public int ExecuteNonQuery( IDbCommand cmd ) { int rowsAffected = 0; *************** *** 188,208 **** } ! public IDataReader ExecuteReader(IDbCommand cmd) { CheckReaders(); ! Prepare( cmd );; IDataReader reader; ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders==false ) { reader = new NHybridDataReader( cmd.ExecuteReader() ); } ! else { reader = cmd.ExecuteReader(); } ! readersToClose.Add(reader); LogOpenReaders(); return reader; --- 224,250 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <returns></returns> ! public IDataReader ExecuteReader( IDbCommand cmd ) { CheckReaders(); ! Prepare( cmd ); ! ; IDataReader reader; ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders == false ) { reader = new NHybridDataReader( cmd.ExecuteReader() ); } ! else { reader = cmd.ExecuteReader(); } ! readersToClose.Add( reader ); LogOpenReaders(); return reader; *************** *** 212,225 **** /// Ensures that the Driver's rules for Multiple Open DataReaders are being followed. /// </summary> ! private void CheckReaders() { // early exit because we don't need to move an open IDataReader into memory // since the Driver supports mult open readers. ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders ) { return; } ! foreach( NHybridDataReader reader in readersToClose ) { reader.ReadIntoMemory(); --- 254,267 ---- /// Ensures that the Driver's rules for Multiple Open DataReaders are being followed. /// </summary> ! private void CheckReaders() { // early exit because we don't need to move an open IDataReader into memory // since the Driver supports mult open readers. ! if( factory.ConnectionProvider.Driver.SupportsMultipleOpenReaders ) { return; } ! foreach( NHybridDataReader reader in readersToClose ) { reader.ReadIntoMemory(); *************** *** 227,231 **** } ! public void CloseCommand(IDbCommand cmd, IDataReader reader) { //TODO: fix this up a little bit - don't like it having the same name and just --- 269,278 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cmd"></param> ! /// <param name="reader"></param> ! public void CloseCommand( IDbCommand cmd, IDataReader reader ) { //TODO: fix this up a little bit - don't like it having the same name and just *************** *** 237,250 **** } ! public void CloseCommands() { ! foreach( IDataReader reader in readersToClose ) { ! try { LogCloseReaders(); reader.Close(); } ! catch( Exception e ) { log.Warn( "Could not close IDataReader", e ); --- 284,300 ---- } ! /// <summary> ! /// ! /// </summary> ! public void CloseCommands() { ! foreach( IDataReader reader in readersToClose ) { ! try { LogCloseReaders(); reader.Close(); } ! catch( Exception e ) { log.Warn( "Could not close IDataReader", e ); *************** *** 253,266 **** readersToClose.Clear(); ! foreach( IDbCommand cmd in commandsToClose ) { ! try { ! CloseQueryCommand(cmd); ! } ! catch(Exception e) { // no big deal ! log.Warn("Could not close a JDBC statement", e); } } --- 303,316 ---- readersToClose.Clear(); ! foreach( IDbCommand cmd in commandsToClose ) { ! try { ! CloseQueryCommand( cmd ); ! } ! catch( Exception e ) { // no big deal ! log.Warn( "Could not close a JDBC statement", e ); } } *************** *** 268,278 **** } ! private void CloseQueryCommand(IDbCommand cmd) { ! try { // no equiv to the java code in here } ! catch( Exception e ) { log.Warn( "exception clearing maxRows/queryTimeout", e ); --- 318,328 ---- } ! private void CloseQueryCommand( IDbCommand cmd ) { ! try { // no equiv to the java code in here } ! catch( Exception e ) { log.Warn( "exception clearing maxRows/queryTimeout", e ); *************** *** 284,298 **** } ! public void CloseQueryCommand(IDbCommand st, IDataReader reader) { ! commandsToClose.Remove(st); ! if( reader!=null ) { ! readersToClose.Remove(reader); } ! try { ! if( reader!=null) { LogCloseReaders(); --- 334,353 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="st"></param> ! /// <param name="reader"></param> ! public void CloseQueryCommand( IDbCommand st, IDataReader reader ) { ! commandsToClose.Remove( st ); ! if( reader != null ) { ! readersToClose.Remove( reader ); } ! try { ! if( reader != null ) { LogCloseReaders(); *************** *** 300,343 **** } } ! finally { ! CloseQueryCommand(st); } } ! public void ExecuteBatch() { ! if ( batchCommand!=null ) { IDbCommand ps = batchCommand; batchCommand = null; batchCommandSql = null; ! try { ! DoExecuteBatch(ps); } ! finally { ! CloseCommand(ps, null); } } } ! protected abstract void DoExecuteBatch(IDbCommand ps) ; ! public abstract void AddToBatch(int expectedRowCount); ! protected ISessionFactoryImplementor Factory { get { return factory; } } ! protected ISessionImplementor Session { get { return session; } } ! private static void LogOpenPreparedCommands() { ! if( log.IsDebugEnabled ) { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); --- 355,410 ---- } } ! finally { ! CloseQueryCommand( st ); } } ! /// <summary></summary> ! public void ExecuteBatch() { ! if( batchCommand != null ) { IDbCommand ps = batchCommand; batchCommand = null; batchCommandSql = null; ! try { ! DoExecuteBatch( ps ); } ! finally { ! CloseCommand( ps, null ); } } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="ps"></param> ! protected abstract void DoExecuteBatch( IDbCommand ps ); ! /// <summary> ! /// ! /// </summary> ! /// <param name="expectedRowCount"></param> ! public abstract void AddToBatch( int expectedRowCount ); ! ! /// <summary></summary> ! protected ISessionFactoryImplementor Factory { get { return factory; } } ! /// <summary></summary> ! protected ISessionImplementor Session { get { return session; } } ! private static void LogOpenPreparedCommands() { ! if( log.IsDebugEnabled ) { log.Debug( "about to open: " + openCommandCount + " open IDbCommands, " + openReaderCount + " open DataReaders" ); *************** *** 346,352 **** } ! private static void LogClosePreparedCommands() { ! if( log.IsDebugEnabled ) { openCommandCount--; --- 413,419 ---- } ! private static void LogClosePreparedCommands() { ! if( log.IsDebugEnabled ) { openCommandCount--; *************** *** 355,361 **** } ! private static void LogOpenReaders() { ! if( log.IsDebugEnabled ) { openReaderCount++; --- 422,428 ---- } ! private static void LogOpenReaders() { ! if( log.IsDebugEnabled ) { openReaderCount++; *************** *** 363,369 **** } ! private static void LogCloseReaders() { ! if( log.IsDebugEnabled ) { openReaderCount--; --- 430,436 ---- } ! private static void LogCloseReaders() { ! if( log.IsDebugEnabled ) { openReaderCount--; *************** *** 371,375 **** } ! } ! } --- 438,442 ---- } ! } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:58:38
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2467 Modified Files: UUIDHexGenerator.cs UUIDStringGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: UUIDStringGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/UUIDStringGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UUIDStringGenerator.cs 28 Mar 2004 06:06:40 -0000 1.3 --- UUIDStringGenerator.cs 31 Dec 2004 18:58:24 -0000 1.4 *************** *** 3,7 **** using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> --- 3,7 ---- using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 18,35 **** /// </para> /// </remarks> ! public class UUIDStringGenerator : IIdentifierGenerator { ! ! public object Generate(ISessionImplementor cache, object obj) { ! byte[] guidInBytes = new byte[16]; ! StringBuilder guidBuilder = new StringBuilder(16, 16); guidInBytes = Guid.NewGuid().ToByteArray(); // add each item in Byte[] to the string builder ! for(int i = 0; i < guidInBytes.Length; i++) { ! guidBuilder.Append((char)guidInBytes[i]); } --- 18,40 ---- /// </para> /// </remarks> ! 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]; ! StringBuilder guidBuilder = new StringBuilder( 16, 16 ); guidInBytes = Guid.NewGuid().ToByteArray(); // add each item in Byte[] to the string builder ! for( int i = 0; i < guidInBytes.Length; i++ ) { ! guidBuilder.Append( ( char ) guidInBytes[ i ] ); } *************** *** 37,39 **** } } ! } --- 42,44 ---- } } ! } \ No newline at end of file Index: UUIDHexGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/UUIDHexGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UUIDHexGenerator.cs 28 Mar 2004 06:06:40 -0000 1.1 --- UUIDHexGenerator.cs 31 Dec 2004 18:58:24 -0000 1.2 *************** *** 1,5 **** using System; using System.Collections; ! using NHibernate.Engine; using NHibernate.Type; --- 1,5 ---- using System; using System.Collections; ! using log4net; using NHibernate.Engine; using NHibernate.Type; *************** *** 24,28 **** /// <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> --- 24,28 ---- /// <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> *************** *** 37,47 **** /// </para> /// </remarks> ! public class UUIDHexGenerator : IIdentifierGenerator, IConfigurable { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(UUIDHexGenerator)); private string format = FormatWithDigitsOnly; private string sep = null; ! //"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" private const string FormatWithDigitsOnly = "N"; --- 37,47 ---- /// </para> /// </remarks> ! public class UUIDHexGenerator : IIdentifierGenerator, IConfigurable { ! private static readonly ILog log = LogManager.GetLogger( typeof( UUIDHexGenerator ) ); private string format = FormatWithDigitsOnly; private string sep = null; ! //"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" private const string FormatWithDigitsOnly = "N"; *************** *** 53,81 **** private const string FormatWithEnclosingParens = "P"; ! public object Generate(ISessionImplementor cache, object obj) { ! string guidString = Guid.NewGuid().ToString(format); ! if(format!=FormatWithDigitsOnly && sep!=null) { ! return StringHelper.Replace(guidString, "-", sep); } ! return guidString; } - #region IConfigurable Members ! public void Configure(IType type, IDictionary parms, Dialect.Dialect dialect) { ! format = PropertiesHelper.GetString("format", parms, FormatWithDigitsOnly); ! ! if(format!=FormatWithDigitsOnly) ! sep = PropertiesHelper.GetString("seperator", parms, null); ! } #endregion } ! } --- 53,94 ---- 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 ); ! if( format != FormatWithDigitsOnly && sep != null ) { ! return StringHelper.Replace( guidString, "-", sep ); } ! return guidString; } #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 ) { ! format = PropertiesHelper.GetString( "format", parms, FormatWithDigitsOnly ); ! ! if( format != FormatWithDigitsOnly ) ! { ! sep = PropertiesHelper.GetString( "seperator", parms, null ); ! } ! } #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:57:33
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2367 Modified Files: SequenceHiLoGenerator.cs TableGenerator.cs TableHiLoGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TableGenerator.cs 30 Nov 2004 18:36:50 -0000 1.11 --- TableGenerator.cs 31 Dec 2004 18:57:22 -0000 1.12 *************** *** 1,8 **** using System; - using System.Data; using System.Collections; using System.Runtime.CompilerServices; ! ! using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.SqlCommand; --- 1,7 ---- using System; using System.Collections; + using System.Data; using System.Runtime.CompilerServices; ! using log4net; using NHibernate.Engine; using NHibernate.SqlCommand; *************** *** 11,16 **** using NHibernate.Util; ! ! namespace NHibernate.Id { /// <summary> --- 10,14 ---- using NHibernate.Util; ! namespace NHibernate.Id { /// <summary> *************** *** 33,42 **** /// </para> /// </remarks> ! public class TableGenerator : IPersistentIdentifierGenerator, IConfigurable { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(TableGenerator)); public const string Column = "column"; public const string Table = "table"; public const string Schema = "schema"; --- 31,45 ---- /// </para> /// </remarks> ! public class TableGenerator : IPersistentIdentifierGenerator, IConfigurable { ! 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"; *************** *** 44,66 **** private string columnName; private string query; ! private SqlString updateSql; ! public virtual void Configure(IType type, IDictionary parms, Dialect.Dialect dialect) { ! this.tableName = PropertiesHelper.GetString(Table, parms, "hibernate_unique_key"); ! this.columnName = PropertiesHelper.GetString(Column, parms, "next_hi"); ! string schemaName = (string) parms[Schema]; ! if(schemaName!=null && tableName.IndexOf(StringHelper.Dot)<0) tableName = schemaName + "." + tableName; query = "select " + columnName + " from " + tableName; ! if ( dialect.SupportsForUpdate ) query += " for update"; ! // build the sql string for the Update since it uses parameters Parameter setParam = new Parameter(); setParam.Name = columnName; setParam.SqlType = new Int32SqlType(); ! Parameter whereParam = new Parameter(); whereParam.Name = columnName; --- 47,80 ---- private string columnName; private string query; ! 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 ) { ! this.tableName = PropertiesHelper.GetString( Table, parms, "hibernate_unique_key" ); ! this.columnName = PropertiesHelper.GetString( Column, parms, "next_hi" ); ! string schemaName = ( string ) parms[ Schema ]; ! if( schemaName != null && tableName.IndexOf( StringHelper.Dot ) < 0 ) ! { tableName = schemaName + "." + tableName; + } query = "select " + columnName + " from " + tableName; ! if( dialect.SupportsForUpdate ) ! { ! query += " for update"; ! } ! // build the sql string for the Update since it uses parameters Parameter setParam = new Parameter(); setParam.Name = columnName; setParam.SqlType = new Int32SqlType(); ! Parameter whereParam = new Parameter(); whereParam.Name = columnName; *************** *** 68,86 **** SqlStringBuilder builder = new SqlStringBuilder(); ! builder.Add("update " + tableName + " set ") ! .Add(columnName) ! .Add(" = ") ! .Add(setParam) ! .Add(" where ") ! .Add(columnName) ! .Add(" = ") ! .Add(whereParam); updateSql = builder.ToSqlString(); ! } ! [MethodImpl(MethodImplOptions.Synchronized)] ! public virtual object Generate(ISessionImplementor session, object obj) { //this has to be done using a different connection to the containing --- 82,106 ---- SqlStringBuilder builder = new SqlStringBuilder(); ! builder.Add( "update " + tableName + " set " ) ! .Add( columnName ) ! .Add( " = " ) ! .Add( setParam ) ! .Add( " where " ) ! .Add( columnName ) ! .Add( " = " ) ! .Add( whereParam ); updateSql = builder.ToSqlString(); ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! [MethodImpl( MethodImplOptions.Synchronized )] ! public virtual object Generate( ISessionImplementor session, object obj ) { //this has to be done using a different connection to the containing *************** *** 90,97 **** int result; int rows; ! try { IDbTransaction trans = conn.BeginTransaction(); ! do { //the loop ensure atomicitiy of the //select + uspdate even for no transaction --- 110,119 ---- int result; int rows; ! try ! { IDbTransaction trans = conn.BeginTransaction(); ! do ! { //the loop ensure atomicitiy of the //select + uspdate even for no transaction *************** *** 102,150 **** qps.CommandType = CommandType.Text; qps.Transaction = trans; ! try { IDataReader rs = qps.ExecuteReader(); ! if ( !rs.Read() ) { string err = "could not read a hi value - you need to populate the table: " + tableName; ! log.Error(err); ! throw new IdentifierGenerationException(err); } ! result = rs.GetInt32(0); rs.Close(); } ! // TODO: change to SqlException ! catch (Exception e) { ! log.Error("could not read a hi value", e); throw; ! } ! finally { } ! IDbCommand ups = session.Factory.ConnectionProvider.Driver.GenerateCommand(session.Factory.Dialect, updateSql); ups.Connection = conn; ups.Transaction = trans; ! try { ! ((IDbDataParameter)ups.Parameters[0]).Value = result + 1; ! ((IDbDataParameter)ups.Parameters[1]).Value = result; rows = ups.ExecuteNonQuery(); } ! // TODO: change to SqlException ! catch (Exception e) { ! log.Error("could not update hi value in: " + tableName, e); throw; ! } ! finally { } ! } while (rows==0); trans.Commit(); --- 124,173 ---- qps.CommandType = CommandType.Text; qps.Transaction = trans; ! try { IDataReader rs = qps.ExecuteReader(); ! if( !rs.Read() ) { string err = "could not read a hi value - you need to populate the table: " + tableName; ! log.Error( err ); ! throw new IdentifierGenerationException( err ); } ! result = rs.GetInt32( 0 ); rs.Close(); } ! // TODO: change to SqlException ! catch( Exception e ) { ! log.Error( "could not read a hi value", e ); throw; ! } ! finally { } ! IDbCommand ups = session.Factory.ConnectionProvider.Driver.GenerateCommand( session.Factory.Dialect, updateSql ); ups.Connection = conn; ups.Transaction = trans; ! try { ! ( ( IDbDataParameter ) ups.Parameters[ 0 ] ).Value = result + 1; ! ( ( IDbDataParameter ) ups.Parameters[ 1 ] ).Value = result; rows = ups.ExecuteNonQuery(); } ! // TODO: change to SqlException ! catch( Exception e ) { ! log.Error( "could not update hi value in: " + tableName, e ); throw; ! } ! finally { } ! } ! while( rows == 0 ); trans.Commit(); *************** *** 152,179 **** return result; ! } ! finally { ! session.Factory.CloseConnection(conn); } } ! public string[] SqlCreateStrings(Dialect.Dialect dialect) { // changed the first value to be "1" by default since an uninitialized Int32 is 0 - leaving // it at 0 would cause problems with an unsaved-value="0" which is what most people are // defaulting <id>'s with Int32 types at. ! return new string[] { ! "create table " + tableName + " ( " + columnName + " " + dialect.GetTypeName( SqlTypeFactory.GetInt32() ) + " )", ! "insert into " + tableName + " values ( 1 )" ! }; } ! public string SqlDropString(Dialect.Dialect dialect) { return "drop table " + tableName + dialect.CascadeConstraintsString; } ! public object GeneratorKey() { return tableName; --- 175,214 ---- return result; ! } ! finally { ! session.Factory.CloseConnection( conn ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string[ ] SqlCreateStrings( Dialect.Dialect dialect ) { // changed the first value to be "1" by default since an uninitialized Int32 is 0 - leaving // it at 0 would cause problems with an unsaved-value="0" which is what most people are // defaulting <id>'s with Int32 types at. ! return new string[ ] ! { ! "create table " + tableName + " ( " + columnName + " " + dialect.GetTypeName( SqlTypeFactory.GetInt32() ) + " )", ! "insert into " + tableName + " values ( 1 )" ! }; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="dialect"></param> ! /// <returns></returns> ! public string SqlDropString( Dialect.Dialect dialect ) { return "drop table " + tableName + dialect.CascadeConstraintsString; } ! /// <summary></summary> ! public object GeneratorKey() { return tableName; *************** *** 181,183 **** } ! } --- 216,218 ---- } ! } \ No newline at end of file Index: SequenceHiLoGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/SequenceHiLoGenerator.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SequenceHiLoGenerator.cs 12 Jul 2004 01:31:09 -0000 1.5 --- SequenceHiLoGenerator.cs 31 Dec 2004 18:57:22 -0000 1.6 *************** *** 1,14 **** - using System; - using System.Data; using System.Collections; using System.Runtime.CompilerServices; ! using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; - using NHibernate.Dialect; - ! namespace NHibernate.Id { /// <summary> --- 1,10 ---- using System.Collections; using System.Runtime.CompilerServices; ! using log4net; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.Id { /// <summary> *************** *** 26,33 **** /// </para> /// </remarks> ! public class SequenceHiLoGenerator : SequenceGenerator { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(SequenceHiLoGenerator)); public const string MaxLo = "max_lo"; --- 22,30 ---- /// </para> /// </remarks> ! public class SequenceHiLoGenerator : SequenceGenerator { ! private static readonly ILog log = LogManager.GetLogger( typeof( SequenceHiLoGenerator ) ); + /// <summary></summary> public const string MaxLo = "max_lo"; *************** *** 37,60 **** private System.Type returnClass; ! 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 returnClass = type.ReturnedClass; } ! [MethodImpl(MethodImplOptions.Synchronized)] ! public override object Generate(ISessionImplementor session, object obj) { ! if ( lo > maxLo ) { ! long hival = ( (long) base.Generate(session, obj) ); lo = 1; ! hi = hival * ( maxLo+1 ); ! log.Debug("new hi value: " + hival); } return IdentifierGeneratorFactory.CreateNumber( hi + lo++, returnClass ); } } ! } --- 34,69 ---- 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 returnClass = type.ReturnedClass; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! [MethodImpl( MethodImplOptions.Synchronized )] ! public override object Generate( ISessionImplementor session, object obj ) { ! if( lo > maxLo ) { ! long hival = ( ( long ) base.Generate( session, obj ) ); lo = 1; ! hi = hival*( maxLo + 1 ); ! log.Debug( "new hi value: " + hival ); } return IdentifierGeneratorFactory.CreateNumber( hi + lo++, returnClass ); } } ! } \ No newline at end of file Index: TableHiLoGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableHiLoGenerator.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TableHiLoGenerator.cs 12 Jul 2004 01:31:10 -0000 1.5 --- TableHiLoGenerator.cs 31 Dec 2004 18:57:22 -0000 1.6 *************** *** 1,14 **** - using System; - using System.Data; using System.Collections; using System.Runtime.CompilerServices; ! ! using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; ! ! namespace NHibernate.Id { /// <summary> --- 1,10 ---- using System.Collections; using System.Runtime.CompilerServices; ! using log4net; using NHibernate.Engine; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.Id { /// <summary> *************** *** 28,35 **** /// </para> /// </remarks> ! public class TableHiLoGenerator : TableGenerator { ! private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(TableHiLoGenerator)); public const string MaxLo = "max_lo"; --- 24,32 ---- /// </para> /// </remarks> ! public class TableHiLoGenerator : TableGenerator { ! private static readonly ILog log = LogManager.GetLogger( typeof( TableHiLoGenerator ) ); + /// <summary></summary> public const string MaxLo = "max_lo"; *************** *** 39,59 **** private System.Type returnClass; ! 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 returnClass = type.ReturnedClass; } ! [MethodImpl(MethodImplOptions.Synchronized)] ! public override object Generate(ISessionImplementor session, object obj) { ! if (lo > maxLo) { ! int hival = ( (int) base.Generate(session, obj) ); lo = 1; ! hi = hival * (maxLo+1); ! log.Debug("new hi value: " + hival); } --- 36,68 ---- 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 returnClass = type.ReturnedClass; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! [MethodImpl( MethodImplOptions.Synchronized )] ! public override object Generate( ISessionImplementor session, object obj ) { ! if( lo > maxLo ) { ! int hival = ( ( int ) base.Generate( session, obj ) ); lo = 1; ! hi = hival*( maxLo + 1 ); ! log.Debug( "new hi value: " + hival ); } *************** *** 61,63 **** } } ! } --- 70,72 ---- } } ! } \ No newline at end of file |
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 |
From: Kevin W. <kev...@us...> - 2004-12-31 18:57:02
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2270 Modified Files: IdentifierGenerationException.cs IdentifierGeneratorFactory.cs IdentityGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IdentifierGeneratorFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentifierGeneratorFactory.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IdentifierGeneratorFactory.cs 1 Nov 2004 16:26:04 -0000 1.12 --- IdentifierGeneratorFactory.cs 31 Dec 2004 18:56:49 -0000 1.13 *************** *** 1,100 **** using System; - using System.Data; using System.Collections; ! using NHibernate.Type; ! namespace NHibernate.Id { /// <summary> /// Factory methods for <c>IdentifierGenerator</c> framework. /// </summary> ! public sealed class IdentifierGeneratorFactory { ! 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 { ! object identityValue = rs[0]; return Convert.ChangeType( identityValue, clazz ); } ! catch( Exception e ) { ! throw new IdentifierGenerationException("this id generator generates Int64, Int32, Int16", e); } } private static readonly Hashtable idgenerators = new Hashtable(); public static readonly string ShortCircuitIndicator = String.Empty; ! static IdentifierGeneratorFactory() { ! idgenerators.Add( "uuid.hex", typeof(UUIDHexGenerator) ); ! idgenerators.Add( "uuid.string", typeof(UUIDStringGenerator) ); ! idgenerators.Add( "hilo", typeof(TableHiLoGenerator) ); ! idgenerators.Add( "assigned", typeof(Assigned) ); ! idgenerators.Add( "identity", typeof(IdentityGenerator) ); ! idgenerators.Add( "sequence", typeof(SequenceGenerator) ); ! idgenerators.Add( "seqhilo", typeof(SequenceHiLoGenerator) ); ! idgenerators.Add( "vm", typeof(CounterGenerator) ); ! idgenerators.Add( "foreign", typeof(ForeignGenerator) ); ! idgenerators.Add( "guid", typeof(GuidGenerator) ); ! idgenerators.Add( "guid.comb", typeof(GuidCombGenerator) ); } ! private IdentifierGeneratorFactory() {} //cannot be instantiated ! public static IIdentifierGenerator Create(string strategy, IType type, IDictionary parms, Dialect.Dialect dialect) { ! try { ! System.Type clazz = (System.Type) idgenerators[strategy]; ! if ( "native".Equals(strategy) ) { ! if ( dialect.SupportsIdentityColumns ) { ! clazz = typeof(IdentityGenerator); } ! else if ( dialect.SupportsSequences ) { ! clazz = typeof(SequenceGenerator); } ! else { ! clazz = typeof(TableHiLoGenerator); } } ! if (clazz==null) clazz = System.Type.GetType(strategy); ! IIdentifierGenerator idgen = (IIdentifierGenerator) Activator.CreateInstance(clazz); ! if (idgen is IConfigurable) ((IConfigurable) idgen).Configure(type, parms, dialect); return idgen; ! } ! catch (Exception e) { ! throw new MappingException("could not instantiate id generator", e); } } ! internal static object CreateNumber(long value, System.Type type) { ! if (type==typeof(long)) { return value; ! } ! else if ( type==typeof(int)) { ! return (int) value; ! } ! else if ( type==typeof(short)) { ! return (short) value; ! } ! else { ! throw new IdentifierGenerationException("this id generator generates Int64, Int32, Int16"); } } } ! } --- 1,131 ---- using System; using System.Collections; ! using System.Data; using NHibernate.Type; ! namespace NHibernate.Id { /// <summary> /// 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 { ! object identityValue = rs[ 0 ]; return Convert.ChangeType( identityValue, clazz ); } ! catch( Exception e ) { ! throw new IdentifierGenerationException( "this id generator generates Int64, Int32, Int16", e ); } } private static readonly Hashtable idgenerators = new Hashtable(); + + /// <summary></summary> public static readonly string ShortCircuitIndicator = String.Empty; ! /// <summary></summary> ! static IdentifierGeneratorFactory() { ! idgenerators.Add( "uuid.hex", typeof( UUIDHexGenerator ) ); ! idgenerators.Add( "uuid.string", typeof( UUIDStringGenerator ) ); ! idgenerators.Add( "hilo", typeof( TableHiLoGenerator ) ); ! idgenerators.Add( "assigned", typeof( Assigned ) ); ! idgenerators.Add( "identity", typeof( IdentityGenerator ) ); ! idgenerators.Add( "sequence", typeof( SequenceGenerator ) ); ! idgenerators.Add( "seqhilo", typeof( SequenceHiLoGenerator ) ); ! idgenerators.Add( "vm", typeof( CounterGenerator ) ); ! idgenerators.Add( "foreign", typeof( ForeignGenerator ) ); ! idgenerators.Add( "guid", typeof( GuidGenerator ) ); ! idgenerators.Add( "guid.comb", typeof( GuidCombGenerator ) ); } ! 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 ) { ! try { ! System.Type clazz = ( System.Type ) idgenerators[ strategy ]; ! if( "native".Equals( strategy ) ) { ! if( dialect.SupportsIdentityColumns ) { ! clazz = typeof( IdentityGenerator ); } ! else if( dialect.SupportsSequences ) { ! clazz = typeof( SequenceGenerator ); } ! else { ! clazz = typeof( TableHiLoGenerator ); } } ! if( clazz == null ) ! { ! clazz = System.Type.GetType( strategy ); ! } ! IIdentifierGenerator idgen = ( IIdentifierGenerator ) Activator.CreateInstance( clazz ); ! if( idgen is IConfigurable ) ! { ! ( ( IConfigurable ) idgen ).Configure( type, parms, dialect ); ! } return idgen; ! } ! catch( Exception e ) { ! throw new MappingException( "could not instantiate id generator", e ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="value"></param> ! /// <param name="type"></param> ! /// <returns></returns> ! internal static object CreateNumber( long value, System.Type type ) ! { ! if( type == typeof( long ) ) { return value; ! } ! else if( type == typeof( int ) ) { ! return ( int ) value; ! } ! else if( type == typeof( short ) ) { ! return ( short ) value; ! } ! else { ! throw new IdentifierGenerationException( "this id generator generates Int64, Int32, Int16" ); } } } ! } \ No newline at end of file Index: IdentifierGenerationException.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentifierGenerationException.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentifierGenerationException.cs 22 Nov 2004 03:53:59 -0000 1.4 --- IdentifierGenerationException.cs 31 Dec 2004 18:56:49 -0000 1.5 *************** *** 1,5 **** using System; ! namespace NHibernate.Id { /// <summary> --- 1,5 ---- using System; ! namespace NHibernate.Id { /// <summary> *************** *** 7,15 **** /// </summary> [Serializable] ! public class IdentifierGenerationException : HibernateException { ! public IdentifierGenerationException(string message) : base(message) {} ! public IdentifierGenerationException(string message, Exception e) : base(message, e) {} } ! } --- 7,28 ---- /// </summary> [Serializable] ! public class IdentifierGenerationException : HibernateException { ! /// <summary> ! /// ! /// </summary> ! /// <param name="message"></param> ! public IdentifierGenerationException( string message ) : base( message ) ! { ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="message"></param> ! /// <param name="e"></param> ! public IdentifierGenerationException( string message, Exception e ) : base( message, e ) ! { ! } } ! } \ No newline at end of file Index: IdentityGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IdentityGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentityGenerator.cs 9 Dec 2004 17:53:14 -0000 1.3 --- IdentityGenerator.cs 31 Dec 2004 18:56:49 -0000 1.4 *************** *** 1,6 **** - using System; using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> --- 1,5 ---- using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 18,22 **** /// </para> /// </remarks> ! public class IdentityGenerator : IIdentifierGenerator { /// <summary> --- 17,21 ---- /// </para> /// </remarks> ! public class IdentityGenerator : IIdentifierGenerator { /// <summary> *************** *** 31,38 **** /// generated id. /// </returns> ! public object Generate(ISessionImplementor s, object obj) { return null; } } ! } --- 30,37 ---- /// generated id. /// </returns> ! public object Generate( ISessionImplementor s, object obj ) { return null; } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:56:49
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2243 Modified Files: GuidCombGenerator.cs GuidGenerator.cs IConfigurable.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IConfigurable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/IConfigurable.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IConfigurable.cs 28 Mar 2004 06:06:40 -0000 1.2 --- IConfigurable.cs 31 Dec 2004 18:56:22 -0000 1.3 *************** *** 1,13 **** - using System; using System.Collections; using NHibernate.Type; ! namespace NHibernate.Id { - /// <summary> /// An <c>IdentiferGenerator</c> that supports "configuration". /// </summary> ! public interface IConfigurable { /// <summary> --- 1,11 ---- using System.Collections; using NHibernate.Type; ! namespace NHibernate.Id { /// <summary> /// An <c>IdentiferGenerator</c> that supports "configuration". /// </summary> ! public interface IConfigurable { /// <summary> *************** *** 19,23 **** /// <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); } ! } --- 17,21 ---- /// <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 ); } ! } \ No newline at end of file Index: GuidCombGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/GuidCombGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuidCombGenerator.cs 11 Oct 2004 23:57:54 -0000 1.1 --- GuidCombGenerator.cs 31 Dec 2004 18:56:22 -0000 1.2 *************** *** 14,54 **** public class GuidCombGenerator : IIdentifierGenerator { - #region IIdentifierGenerator Members ! public object Generate(ISessionImplementor session, object obj) { return GenerateComb(); } private Guid GenerateComb() { ! byte[] guidArray = System.Guid.NewGuid().ToByteArray(); ! DateTime baseDate = new DateTime(1900,1,1); ! DateTime now = DateTime.Now; // Get the days and milliseconds which will be used to build the byte string ! TimeSpan days = new TimeSpan(now.Ticks - baseDate.Ticks); ! TimeSpan msecs = new TimeSpan(now.Ticks - (new DateTime(now.Year, now.Month, now.Day).Ticks)); // Convert to a byte array // Note that SQL Server is accurate to 1/300th of a millisecond so we divide by 3.333333 ! byte[] daysArray = BitConverter.GetBytes(days.Days); ! byte[] msecsArray = BitConverter.GetBytes((long)(msecs.TotalMilliseconds/3.333333)); // Reverse the bytes to match SQL Servers ordering ! Array.Reverse(daysArray); ! Array.Reverse(msecsArray); // Copy the bytes into the guid ! Array.Copy(daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2); ! Array.Copy(msecsArray, msecsArray.Length - 4, guidArray, guidArray.Length - 4, 4); ! return new Guid(guidArray); } - #endregion } ! } --- 14,59 ---- public class GuidCombGenerator : IIdentifierGenerator { #region IIdentifierGenerator Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor session, object obj ) { return GenerateComb(); } + /// <summary></summary> private Guid GenerateComb() { ! byte[ ] guidArray = Guid.NewGuid().ToByteArray(); ! DateTime baseDate = new DateTime( 1900, 1, 1 ); ! DateTime now = DateTime.Now; // Get the days and milliseconds which will be used to build the byte string ! TimeSpan days = new TimeSpan( now.Ticks - baseDate.Ticks ); ! TimeSpan msecs = new TimeSpan( now.Ticks - ( new DateTime( now.Year, now.Month, now.Day ).Ticks ) ); // Convert to a byte array // Note that SQL Server is accurate to 1/300th of a millisecond so we divide by 3.333333 ! byte[ ] daysArray = BitConverter.GetBytes( days.Days ); ! byte[ ] msecsArray = BitConverter.GetBytes( ( long ) ( msecs.TotalMilliseconds/3.333333 ) ); // Reverse the bytes to match SQL Servers ordering ! Array.Reverse( daysArray ); ! Array.Reverse( msecsArray ); // Copy the bytes into the guid ! Array.Copy( daysArray, daysArray.Length - 2, guidArray, guidArray.Length - 6, 2 ); ! Array.Copy( msecsArray, msecsArray.Length - 4, guidArray, guidArray.Length - 4, 4 ); ! return new Guid( guidArray ); } #endregion } ! } \ No newline at end of file Index: GuidGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/GuidGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GuidGenerator.cs 28 Mar 2004 06:06:40 -0000 1.1 --- GuidGenerator.cs 31 Dec 2004 18:56:22 -0000 1.2 *************** *** 1,7 **** using System; - using NHibernate.Engine; - namespace NHibernate.Id { --- 1,5 ---- *************** *** 11,18 **** public class GuidGenerator : IIdentifierGenerator { - #region IIdentifierGenerator Members ! public object Generate(ISessionImplementor session, object obj) { return Guid.NewGuid(); --- 9,21 ---- public class GuidGenerator : IIdentifierGenerator { #region IIdentifierGenerator Members ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor session, object obj ) { return Guid.NewGuid(); *************** *** 21,23 **** #endregion } ! } --- 24,26 ---- #endregion } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:56:07
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2135 Modified Files: Assigned.cs CounterGenerator.cs ForeignGenerator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: CounterGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/CounterGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CounterGenerator.cs 28 Mar 2004 06:06:40 -0000 1.2 --- CounterGenerator.cs 31 Dec 2004 18:55:56 -0000 1.3 *************** *** 2,6 **** using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> --- 2,6 ---- using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 8,23 **** /// time and a counter value. Not safe for use in a clustser! /// </summary> ! public class CounterGenerator : IIdentifierGenerator { ! ! private static short counter = (short)0; ! protected short Count { ! get { ! lock(typeof(CounterGenerator)) { ! if (counter<0) counter=0; return counter++; } --- 8,26 ---- /// time and a counter value. Not safe for use in a clustser! /// </summary> ! public class CounterGenerator : IIdentifierGenerator { ! private static short counter = ( short ) 0; ! /// <summary></summary> ! protected short Count { ! get { ! lock( typeof( CounterGenerator ) ) { ! if( counter < 0 ) ! { ! counter = 0; ! } return counter++; } *************** *** 25,29 **** } ! public object Generate(ISessionImplementor cache, object obj) { return ( DateTime.Now.Ticks << 16 ) + Count; --- 28,38 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="cache"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor cache, object obj ) { return ( DateTime.Now.Ticks << 16 ) + Count; *************** *** 31,33 **** } ! } --- 40,42 ---- } ! } \ No newline at end of file Index: Assigned.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/Assigned.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Assigned.cs 28 Mar 2004 06:06:40 -0000 1.2 --- Assigned.cs 31 Dec 2004 18:55:56 -0000 1.3 *************** *** 1,7 **** - using System; - using NHibernate.Engine; using NHibernate.Collection; ! namespace NHibernate.Id { /// <summary> --- 1,6 ---- using NHibernate.Collection; + using NHibernate.Engine; ! namespace NHibernate.Id { /// <summary> *************** *** 9,31 **** /// assigned to an instance /// </summary> ! public class Assigned : IIdentifierGenerator { ! public static readonly Assigned Instance = new Assigned(); ! public object Generate(ISessionImplementor session, object obj) { ! if ( obj is PersistentCollection) throw new IdentifierGenerationException( ! "Illegal use of assigned id generation fro a toplevel collection" ! ); ! ! object id = session.GetPersister(obj).GetIdentifier(obj); ! if (id==null) throw new IdentifierGenerationException( ! "ids for this class must be manually assigned before calling save(): " + obj.GetType().FullName ! ); return id; } } ! } --- 8,40 ---- /// assigned to an instance /// </summary> ! public class Assigned : IIdentifierGenerator { ! /// <summary></summary> 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 ) { ! if( obj is PersistentCollection ) ! { throw new IdentifierGenerationException( ! "Illegal use of assigned id generation fro a toplevel collection" ! ); ! } ! ! object id = session.GetPersister( obj ).GetIdentifier( obj ); ! if( id == null ) ! { throw new IdentifierGenerationException( ! "ids for this class must be manually assigned before calling save(): " + obj.GetType().FullName ! ); ! } return id; } } ! } \ No newline at end of file Index: ForeignGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/ForeignGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ForeignGenerator.cs 21 Sep 2004 09:58:24 -0000 1.3 --- ForeignGenerator.cs 31 Dec 2004 18:55:56 -0000 1.4 *************** *** 1,5 **** - using System; using System.Collections; - using NHibernate.Engine; using NHibernate.Type; --- 1,3 ---- *************** *** 16,29 **** private string propertyName; ! public object Generate(ISessionImplementor session, object obj) { object associatedObject = session.Factory .GetClassMetadata( obj.GetType() ) ! .GetPropertyValue(obj, propertyName); //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! object id = session.Save(associatedObject); ! if ( session.Contains(obj) ) { //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"); } --- 14,34 ---- private string propertyName; ! /// <summary> ! /// ! /// </summary> ! /// <param name="session"></param> ! /// <param name="obj"></param> ! /// <returns></returns> ! public object Generate( ISessionImplementor session, object obj ) { object associatedObject = session.Factory .GetClassMetadata( obj.GetType() ) ! .GetPropertyValue( obj, propertyName ); //return session.getEntityIdentifierIfNotUnsaved(associatedObject); ! object id = session.Save( associatedObject ); ! if( session.Contains( obj ) ) ! { //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"); } *************** *** 31,40 **** } ! public void Configure(IType type, IDictionary parms, Dialect.Dialect d) { ! propertyName = (string)parms["property"]; ! if(propertyName==null || propertyName.Length == 0) ! throw new MappingException("param named \"property\" is required for foreign id generation strategy"); } } ! } --- 36,53 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="type"></param> ! /// <param name="parms"></param> ! /// <param name="d"></param> ! public void Configure( IType type, IDictionary parms, Dialect.Dialect d ) { ! propertyName = ( string ) parms[ "property" ]; ! if( propertyName == null || propertyName.Length == 0 ) ! { ! throw new MappingException( "param named \"property\" is required for foreign id generation strategy" ); ! } } } ! } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:41:56
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31709 Modified Files: PathExpressionParser.cs Log Message: fixing xml comments and letting ReSharper do reformatting also added to "undefined alias" error message to hint to missing mapping Index: PathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/PathExpressionParser.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PathExpressionParser.cs 21 Nov 2004 22:56:28 -0000 1.18 --- PathExpressionParser.cs 31 Dec 2004 18:41:47 -0000 1.19 *************** *** 2,7 **** using System.Collections; using System.Text; - - using NHibernate; using NHibernate.Collection; using NHibernate.Persister; --- 2,5 ---- *************** *** 10,14 **** using NHibernate.Util; [...1294 lines suppressed...] ! string[ ] cols = memberPersister.ElementColumnNames; ! if( cols.Length != 1 ) ! { ! throw new QueryException( "composite collection element in minElement" ); ! } ! collectionElementColumns = new string[ ] {"min(" + cols[ 0 ] + StringHelper.ClosedParen}; collectionElementType = memberPersister.ElementType; ! } ! else { ! throw new QueryException( "expecting 'elements' or 'indices' after " + path ); } } + /// <summary></summary> public String CollectionOwnerName { ! get { return collectionOwnerName; } } } |
From: Kevin W. <kev...@us...> - 2004-12-31 18:23:45
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28167 Modified Files: ClauseParser.cs FilterTranslator.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ClauseParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/ClauseParser.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ClauseParser.cs 22 Nov 2004 03:53:07 -0000 1.7 --- ClauseParser.cs 31 Dec 2004 18:23:33 -0000 1.8 *************** *** 1,84 **** - using System; using System.Collections; - using NHibernate; using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary> /// Parses the hibernate query into its constituent clauses. /// </summary> ! public class ClauseParser : IParser { ! private IParser child; ! private IList selectTokens; ! private bool cacheSelectTokens = false; ! private bool byExpected = false; private int parenCount = 0; ! ! public virtual void Token(string token, QueryTranslator q) { string lcToken = token.ToLower(); ! ! if ( token.Equals(StringHelper.OpenParen ) ) { parenCount++; } ! else if ( token.Equals(StringHelper.ClosedParen ) ) { parenCount--; } ! if (byExpected && !lcToken.Equals("by")) { ! throw new QueryException("BY expected after GROUP or ORDER: " + token); } - - bool isClauseStart = parenCount==0; //ignore subselect keywords ! if (isClauseStart) { ! if (lcToken.Equals("select")) { selectTokens = new ArrayList(); cacheSelectTokens = true; ! } ! else if (lcToken.Equals("from")) { child = new FromParser(); ! child.Start(q); cacheSelectTokens = false; ! } ! else if (lcToken.Equals("where")) { ! EndChild(q); child = new WhereParser( q.Dialect ); ! child.Start(q); ! } ! else if (lcToken.Equals("order")) { ! EndChild(q); child = new OrderByParser(); byExpected = true; ! } ! else if (lcToken.Equals("having")) { ! EndChild(q); child = new HavingParser( q.Dialect ); ! child.Start(q); ! } ! else if (lcToken.Equals("group")) { ! EndChild(q); child = new GroupByParser(); byExpected = true; ! } ! else if (lcToken.Equals("by")) { ! if (!byExpected) throw new QueryException("GROUP or ORDER expected before BY"); ! child.Start(q); byExpected = false; ! } ! else { isClauseStart = false; --- 1,90 ---- using System.Collections; using NHibernate.Util; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the hibernate query into its constituent clauses. /// </summary> ! public class ClauseParser : IParser ! { private IParser child; ! private IList selectTokens; ! private bool cacheSelectTokens = false; ! private bool byExpected = false; private int parenCount = 0; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public virtual void Token( string token, QueryTranslator q ) { string lcToken = token.ToLower(); ! ! if( token.Equals( StringHelper.OpenParen ) ) { parenCount++; } ! else if( token.Equals( StringHelper.ClosedParen ) ) { parenCount--; } ! if( byExpected && !lcToken.Equals( "by" ) ) { ! throw new QueryException( "BY expected after GROUP or ORDER: " + token ); } ! bool isClauseStart = parenCount == 0; //ignore subselect keywords ! ! if( isClauseStart ) { ! if( lcToken.Equals( "select" ) ) { selectTokens = new ArrayList(); cacheSelectTokens = true; ! } ! else if( lcToken.Equals( "from" ) ) { child = new FromParser(); ! child.Start( q ); cacheSelectTokens = false; ! } ! else if( lcToken.Equals( "where" ) ) { ! EndChild( q ); child = new WhereParser( q.Dialect ); ! child.Start( q ); ! } ! else if( lcToken.Equals( "order" ) ) { ! EndChild( q ); child = new OrderByParser(); byExpected = true; ! } ! else if( lcToken.Equals( "having" ) ) { ! EndChild( q ); child = new HavingParser( q.Dialect ); ! child.Start( q ); ! } ! else if( lcToken.Equals( "group" ) ) { ! EndChild( q ); child = new GroupByParser(); byExpected = true; ! } ! else if( lcToken.Equals( "by" ) ) { ! if( !byExpected ) ! { ! throw new QueryException( "GROUP or ORDER expected before BY" ); ! } ! child.Start( q ); byExpected = false; ! } ! else { isClauseStart = false; *************** *** 86,138 **** } ! if (!isClauseStart) { ! if (cacheSelectTokens) { ! selectTokens.Add(token); ! } ! else { ! if (child == null) { ! throw new QueryException("query must begin with SELECT or FROM: " + token); } ! else { ! child.Token(token, q); } } } } ! ! private void EndChild(QueryTranslator q) { ! if (child == null) { //null child could occur for no from clause in a filter cacheSelectTokens = false; ! } ! else { ! child.End(q); } } ! ! public virtual void Start(QueryTranslator q) { } ! ! public virtual void End(QueryTranslator q) { ! EndChild(q); ! if (selectTokens != null) { child = new SelectParser(); ! child.Start(q); ! foreach (string item in selectTokens) { ! Token(item, q); } ! child.End(q); } byExpected = false; --- 92,152 ---- } ! if( !isClauseStart ) { ! if( cacheSelectTokens ) { ! selectTokens.Add( token ); ! } ! else { ! if( child == null ) { ! throw new QueryException( "query must begin with SELECT or FROM: " + token ); } ! else { ! child.Token( token, q ); } } } } ! ! private void EndChild( QueryTranslator q ) { ! if( child == null ) { //null child could occur for no from clause in a filter cacheSelectTokens = false; ! } ! else { ! child.End( q ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void Start( QueryTranslator q ) { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void End( QueryTranslator q ) { ! EndChild( q ); ! if( selectTokens != null ) { child = new SelectParser(); ! child.Start( q ); ! foreach( string item in selectTokens ) { ! Token( item, q ); } ! child.End( q ); } byExpected = false; Index: FilterTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FilterTranslator.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FilterTranslator.cs 21 Nov 2004 22:56:28 -0000 1.8 --- FilterTranslator.cs 31 Dec 2004 18:23:33 -0000 1.9 *************** *** 1,14 **** - using System; using System.Collections; - using NHibernate; - using NHibernate.Engine; using System.Runtime.CompilerServices; ! namespace NHibernate.Hql { ! ! public class FilterTranslator : QueryTranslator { ! public FilterTranslator(Dialect.Dialect d) : base(d) { } --- 1,16 ---- using System.Collections; using System.Runtime.CompilerServices; + using NHibernate.Engine; ! namespace NHibernate.Hql { ! /// <summary></summary> ! public class FilterTranslator : QueryTranslator { ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! public FilterTranslator( Dialect.Dialect d ) : base( d ) { } *************** *** 18,29 **** /// times. Subsequent invocations are no-ops. /// </summary> ! [MethodImpl(MethodImplOptions.Synchronized)] ! public void Compile(string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar) { ! if (!Compiled) { this.factory = factory; // yick! ! AddFromCollection("this", collectionRole); ! base.Compile(factory, queryString, replacements, scalar); } } --- 20,31 ---- /// times. Subsequent invocations are no-ops. /// </summary> ! [MethodImpl( MethodImplOptions.Synchronized )] ! public void Compile( string collectionRole, ISessionFactoryImplementor factory, string queryString, IDictionary replacements, bool scalar ) { ! if( !Compiled ) { this.factory = factory; // yick! ! AddFromCollection( "this", collectionRole ); ! base.Compile( factory, queryString, replacements, scalar ); } } |
From: Kevin W. <kev...@us...> - 2004-12-31 18:23:31
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28087 Modified Files: FromParser.cs FromPathExpressionParser.cs GroupByParser.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: GroupByParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/GroupByParser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** GroupByParser.cs 14 Apr 2004 11:35:53 -0000 1.4 --- GroupByParser.cs 31 Dec 2004 18:23:05 -0000 1.5 *************** *** 1,50 **** - using System; - using System.Collections; - using NHibernate; using NHibernate.Util; ! namespace NHibernate.Hql { - /// <summary> /// Parses the GROUP BY clause of an aggregate query /// </summary> ! public class GroupByParser : IParser { //this is basically a copy/paste of OrderByParser ... might be worth refactoring ! // This uses a PathExpressionParser but notice that compound paths are not valid, // only bare names and simple paths: ! // SELECT p FROM p IN CLASS eg.Person GROUP BY p.Name, p.Address, p ! // The reason for this is SQL doesn't let you sort by an expression you are // not returning in the result set. ! private PathExpressionParser pathExpressionParser = new PathExpressionParser(); ! ! public void Token(string token, QueryTranslator q) { ! ! if (q.IsName(StringHelper.Root(token))) { ! ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q); ! q.AppendGroupByToken(pathExpressionParser.WhereColumn); ! pathExpressionParser.AddAssociation(q); ! } ! else { ! q.AppendGroupByToken(token); } } ! ! public void Start(QueryTranslator q) { } ! ! public void End(QueryTranslator q) { } public GroupByParser() { --- 1,59 ---- using NHibernate.Util; ! namespace NHibernate.Hql { /// <summary> /// Parses the GROUP BY clause of an aggregate query /// </summary> ! public class GroupByParser : IParser { //this is basically a copy/paste of OrderByParser ... might be worth refactoring ! // This uses a PathExpressionParser but notice that compound paths are not valid, // only bare names and simple paths: ! // SELECT p FROM p IN CLASS eg.Person GROUP BY p.Name, p.Address, p ! // The reason for this is SQL doesn't let you sort by an expression you are // not returning in the result set. ! private PathExpressionParser pathExpressionParser = new PathExpressionParser(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public void Token( string token, QueryTranslator q ) { ! if( q.IsName( StringHelper.Root( token ) ) ) { ! ParserHelper.Parse( pathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! q.AppendGroupByToken( pathExpressionParser.WhereColumn ); ! pathExpressionParser.AddAssociation( q ); ! } ! else { ! q.AppendGroupByToken( token ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void Start( QueryTranslator q ) { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void End( QueryTranslator q ) { } + /// <summary></summary> public GroupByParser() { Index: FromParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FromParser.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** FromParser.cs 20 Aug 2004 17:39:02 -0000 1.11 --- FromParser.cs 31 Dec 2004 18:23:05 -0000 1.12 *************** *** 1,17 **** - using System; using System.Collections; - - using NHibernate; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary> /// Parses the from clause of a hibernate query, looking for tables and /// aliases for the SQL query. /// </summary> ! public class FromParser : IParser { private PathExpressionParser peParser = new FromPathExpressionParser(); private string entityName; --- 1,15 ---- using System.Collections; using NHibernate.Persister; using NHibernate.SqlCommand; using NHibernate.Util; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the from clause of a hibernate query, looking for tables and /// aliases for the SQL query. /// </summary> ! public class FromParser : IParser ! { private PathExpressionParser peParser = new FromPathExpressionParser(); private string entityName; *************** *** 25,115 **** private bool afterJoinType; private bool afterFetch; ! private SqlCommand.JoinType joinType = SqlCommand.JoinType.None; private static IDictionary joinTypes = new Hashtable(); ! static FromParser() { ! joinTypes.Add( "left", SqlCommand.JoinType.LeftOuterJoin ); ! joinTypes.Add( "right", SqlCommand.JoinType.RightOuterJoin ); ! joinTypes.Add( "full", SqlCommand.JoinType.FullJoin ); ! joinTypes.Add( "inner", SqlCommand.JoinType.InnerJoin ); } ! ! public void Token(string token, QueryTranslator q) { ! // start by looking for HQL keywords.... string lcToken = token.ToLower(); ! if ( lcToken.Equals(StringHelper.Comma) ) { ! if ( !(expectingJoin|expectingAs) ) throw new QueryException("unexpected token: ,"); expectingJoin = false; expectingAs = false; ! } ! else if ( lcToken.Equals("join") ) { ! if (!afterJoinType) { ! if ( !(expectingJoin|expectingAs) ) throw new QueryException("unexpected token: join"); // inner joings can be abbreviated to 'join' joinType = JoinType.InnerJoin; expectingJoin = false; expectingAs = false; ! } ! else { afterJoinType = false; } ! } ! else if ( lcToken.Equals("fetch") ) { ! if ( q.IsShallowQuery ) throw new QueryException("fetch may not be used with scroll() or iterate()"); ! if (joinType==JoinType.None) throw new QueryException("unexpected token: fetch"); ! if (joinType==JoinType.FullJoin || joinType==JoinType.RightOuterJoin) ! throw new QueryException("fetch may only be used with inner join or left outer join"); afterFetch = true; } ! else if ( lcToken.Equals("outer") ) { // 'outer' is optional and is ignored) ! if ( !afterJoinType || (joinType!=JoinType.LeftOuterJoin && joinType!=JoinType.RightOuterJoin) ) { ! throw new QueryException("unexpected token: outer"); } ! } ! else if ( joinTypes.Contains(lcToken) ) { ! if ( !(expectingJoin|expectingAs) ) throw new QueryException("unexpected token: " + token); ! joinType = (JoinType) joinTypes[lcToken]; afterJoinType = true; expectingJoin = false; expectingAs = false; ! } ! else if (lcToken.Equals("class")) { ! if (!afterIn) throw new QueryException("unexpected token: class"); ! if (joinType!=JoinType.None) throw new QueryException("outer or full join must be followed by path expression"); afterClass = true; ! } ! else if ( lcToken.Equals("in") ) { ! if (!expectingIn) throw new QueryException("unexpected token: in"); afterIn = true; expectingIn = false; ! } ! else if ( lcToken.Equals("as") ) { ! if (!expectingAs) throw new QueryException("unexpected token: as"); afterAs = true; expectingAs = false; ! } ! else { ! if (afterJoinType) throw new QueryException("join expected: " + token); ! if (expectingJoin) throw new QueryException("unexpected token: " + token); ! if (expectingIn) throw new QueryException("in expected: " + token); // now anything that is not a HQL keyword ! if ( afterAs || expectingAs ) { // (AS is always optional, for consistentcy with SQL/OQL --- 23,158 ---- private bool afterJoinType; private bool afterFetch; ! private JoinType joinType = JoinType.None; private static IDictionary joinTypes = new Hashtable(); ! /// <summary></summary> ! static FromParser() ! { ! joinTypes.Add( "left", JoinType.LeftOuterJoin ); ! joinTypes.Add( "right", JoinType.RightOuterJoin ); ! joinTypes.Add( "full", JoinType.FullJoin ); ! joinTypes.Add( "inner", JoinType.InnerJoin ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public void Token( string token, QueryTranslator q ) ! { // start by looking for HQL keywords.... string lcToken = token.ToLower(); ! if( lcToken.Equals( StringHelper.Comma ) ) { ! if( !( expectingJoin | expectingAs ) ) ! { ! throw new QueryException( "unexpected token: ," ); ! } expectingJoin = false; expectingAs = false; ! } ! else if( lcToken.Equals( "join" ) ) { ! if( !afterJoinType ) { ! if( !( expectingJoin | expectingAs ) ) ! { ! throw new QueryException( "unexpected token: join" ); ! } // inner joings can be abbreviated to 'join' joinType = JoinType.InnerJoin; expectingJoin = false; expectingAs = false; ! } ! else { afterJoinType = false; } ! } ! else if( lcToken.Equals( "fetch" ) ) { ! if( q.IsShallowQuery ) ! { ! throw new QueryException( "fetch may not be used with scroll() or iterate()" ); ! } ! if( joinType == JoinType.None ) ! { ! throw new QueryException( "unexpected token: fetch" ); ! } ! if( joinType == JoinType.FullJoin || joinType == JoinType.RightOuterJoin ) ! { ! throw new QueryException( "fetch may only be used with inner join or left outer join" ); ! } afterFetch = true; } ! else if( lcToken.Equals( "outer" ) ) { // 'outer' is optional and is ignored) ! if( !afterJoinType || ( joinType != JoinType.LeftOuterJoin && joinType != JoinType.RightOuterJoin ) ) { ! throw new QueryException( "unexpected token: outer" ); } ! } ! else if( joinTypes.Contains( lcToken ) ) { ! if( !( expectingJoin | expectingAs ) ) ! { ! throw new QueryException( "unexpected token: " + token ); ! } ! joinType = ( JoinType ) joinTypes[ lcToken ]; afterJoinType = true; expectingJoin = false; expectingAs = false; ! } ! else if( lcToken.Equals( "class" ) ) { ! if( !afterIn ) ! { ! throw new QueryException( "unexpected token: class" ); ! } ! if( joinType != JoinType.None ) ! { ! throw new QueryException( "outer or full join must be followed by path expression" ); ! } afterClass = true; ! } ! else if( lcToken.Equals( "in" ) ) { ! if( !expectingIn ) ! { ! throw new QueryException( "unexpected token: in" ); ! } afterIn = true; expectingIn = false; ! } ! else if( lcToken.Equals( "as" ) ) { ! if( !expectingAs ) ! { ! throw new QueryException( "unexpected token: as" ); ! } afterAs = true; expectingAs = false; ! } ! else { ! if( afterJoinType ) ! { ! throw new QueryException( "join expected: " + token ); ! } ! if( expectingJoin ) ! { ! throw new QueryException( "unexpected token: " + token ); ! } ! if( expectingIn ) ! { ! throw new QueryException( "in expected: " + token ); ! } // now anything that is not a HQL keyword ! if( afterAs || expectingAs ) { // (AS is always optional, for consistentcy with SQL/OQL *************** *** 119,129 **** // AS construction ! if (entityName!=null) { ! q.SetAliasName(token, entityName); ! } ! else { ! throw new QueryException("unexpected: as " + token); } afterAs = false; --- 162,172 ---- // AS construction ! if( entityName != null ) { ! q.SetAliasName( token, entityName ); ! } ! else { ! throw new QueryException( "unexpected: as " + token ); } afterAs = false; *************** *** 131,160 **** expectingAs = false; entityName = null; ! } ! else if (afterIn) { // process the "old" HQL style where aliases appear _first // ie using the IN or IN CLASS constructions ! if (alias==null) throw new QueryException("alias not specified for: " + token); ! if (joinType!=JoinType.None) throw new QueryException("outer or full join must be followed by path expressions"); ! if (afterClass) { // treat it as a classname ! IQueryable p = q.GetPersisterUsingImports(token); ! if (p==null) throw new QueryException("persister not found: " + token); ! q.AddFromClass(alias, p); ! } ! else { // treat it as a path expression peParser.JoinType = JoinType.InnerJoin; peParser.UseThetaStyleJoin = true; ! ParserHelper.Parse(peParser, q.Unalias(token), ParserHelper.PathSeparators, q); ! if ( !peParser.IsCollectionValued ) throw new QueryException("pathe expression did not resolve to collection: " + token); ! string nm = peParser.AddFromCollection(q); ! q.SetAliasName(alias, nm); } --- 174,215 ---- expectingAs = false; entityName = null; ! } ! else if( afterIn ) { // process the "old" HQL style where aliases appear _first // ie using the IN or IN CLASS constructions ! if( alias == null ) ! { ! throw new QueryException( "alias not specified for: " + token ); ! } ! if( joinType != JoinType.None ) ! { ! throw new QueryException( "outer or full join must be followed by path expressions" ); ! } ! if( afterClass ) { // treat it as a classname ! IQueryable p = q.GetPersisterUsingImports( token ); ! if( p == null ) ! { ! throw new QueryException( "persister not found: " + token ); ! } ! q.AddFromClass( alias, p ); ! } ! else { // treat it as a path expression peParser.JoinType = JoinType.InnerJoin; peParser.UseThetaStyleJoin = true; ! ParserHelper.Parse( peParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! if( !peParser.IsCollectionValued ) ! { ! throw new QueryException( "pathe expression did not resolve to collection: " + token ); ! } ! string nm = peParser.AddFromCollection( q ); ! q.SetAliasName( alias, nm ); } *************** *** 163,182 **** afterClass = false; expectingJoin = true; ! } ! else { // handle a path expression or class name that appears // at the start, in the "new" HQL style or an alias that // appears at the start in the "old HQL stype ! IQueryable p = q.GetPersisterUsingImports(token); ! if (p!=null) { // starts with the name of a mapped class (new style) ! if (joinType!=JoinType.None) throw new QueryException("outer or full join must be followed by path expression"); entityName = q.CreateNameFor( p.MappedClass ); q.AddFromClass( entityName, p ); expectingAs = true; ! } ! else if ( token.IndexOf('.') < 0 ) { // starts with an alias (old style) --- 218,240 ---- afterClass = false; expectingJoin = true; ! } ! else { // handle a path expression or class name that appears // at the start, in the "new" HQL style or an alias that // appears at the start in the "old HQL stype ! IQueryable p = q.GetPersisterUsingImports( token ); ! if( p != null ) { // starts with the name of a mapped class (new style) ! if( joinType != JoinType.None ) ! { ! throw new QueryException( "outer or full join must be followed by path expression" ); ! } entityName = q.CreateNameFor( p.MappedClass ); q.AddFromClass( entityName, p ); expectingAs = true; ! } ! else if( token.IndexOf( '.' ) < 0 ) { // starts with an alias (old style) *************** *** 184,189 **** alias = token; expectingIn = true; ! } ! else { // starts with a path expression (new style) --- 242,247 ---- alias = token; expectingIn = true; ! } ! else { // starts with a path expression (new style) *************** *** 191,197 **** // force HQL style: from Person p inner join p.cars c //if (joinType==JoinType.None) throw new QueryException("path expression must be preceded by full, left, right or inner join"); ! //allow ODMG OQL style: from Person p, p.cars c ! if (joinType!=JoinType.None) { peParser.JoinType = joinType; --- 249,255 ---- // force HQL style: from Person p inner join p.cars c //if (joinType==JoinType.None) throw new QueryException("path expression must be preceded by full, left, right or inner join"); ! //allow ODMG OQL style: from Person p, p.cars c ! if( joinType != JoinType.None ) { peParser.JoinType = joinType; *************** *** 203,227 **** peParser.UseThetaStyleJoin = q.IsSubquery; ! ParserHelper.Parse(peParser, q.Unalias(token), ParserHelper.PathSeparators, q); ! if ( peParser.IsCollectionValued ) { ! entityName = peParser.AddFromCollection(q); ! } ! else { ! entityName = peParser.AddFromAssociation(q); } joinType = JoinType.None; peParser.JoinType = JoinType.InnerJoin; ! if (afterFetch) { ! ! if ( peParser.IsCollectionValued ) { q.SetCollectionToFetch( peParser.CollectionRole, peParser.CollectionName, peParser.CollectionOwnerName ); } ! q.AddEntityToFetch(entityName); ! afterFetch = false; } --- 261,284 ---- peParser.UseThetaStyleJoin = q.IsSubquery; ! ParserHelper.Parse( peParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! if( peParser.IsCollectionValued ) { ! entityName = peParser.AddFromCollection( q ); ! } ! else { ! entityName = peParser.AddFromAssociation( q ); } joinType = JoinType.None; peParser.JoinType = JoinType.InnerJoin; ! if( afterFetch ) { ! if( peParser.IsCollectionValued ) { q.SetCollectionToFetch( peParser.CollectionRole, peParser.CollectionName, peParser.CollectionOwnerName ); } ! q.AddEntityToFetch( entityName ); ! afterFetch = false; } *************** *** 232,237 **** } } ! ! public virtual void Start(QueryTranslator q) { entityName = null; --- 289,298 ---- } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void Start( QueryTranslator q ) { entityName = null; *************** *** 245,250 **** joinType = JoinType.None; } ! ! public virtual void End(QueryTranslator q) { } --- 306,315 ---- joinType = JoinType.None; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void End( QueryTranslator q ) { } Index: FromPathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/FromPathExpressionParser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FromPathExpressionParser.cs 20 Aug 2004 17:39:02 -0000 1.5 --- FromPathExpressionParser.cs 31 Dec 2004 18:23:05 -0000 1.6 *************** *** 1,38 **** - using System; - using NHibernate.Type; ! namespace NHibernate.Hql { /// <summary> /// FromPathExpressionParser /// </summary> ! public class FromPathExpressionParser : PathExpressionParser { ! ! public override void End(QueryTranslator q) { ! if ( !IsCollectionValued ) { ! IType type = GetPropertyType(q); ! if ( type.IsEntityType ) { // "finish off" the join ! Token(".", q); ! Token(null, q); } ! else if ( type.IsPersistentCollectionType ) { // default to element set if no elements() specified ! Token(".", q); ! Token(CollectionElements, q); } } ! base.End(q); } ! ! protected override void SetExpectingCollectionIndex() { ! throw new QueryException("expecting .elements or .indices after collection path expression in from"); } } --- 1,40 ---- using NHibernate.Type; ! namespace NHibernate.Hql { /// <summary> /// FromPathExpressionParser /// </summary> ! public class FromPathExpressionParser : PathExpressionParser { ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public override void End( QueryTranslator q ) { ! if( !IsCollectionValued ) { ! IType type = GetPropertyType( q ); ! if( type.IsEntityType ) { // "finish off" the join ! Token( ".", q ); ! Token( null, q ); } ! else if( type.IsPersistentCollectionType ) { // default to element set if no elements() specified ! Token( ".", q ); ! Token( CollectionElements, q ); } } ! base.End( q ); } ! ! /// <summary></summary> ! protected override void SetExpectingCollectionIndex() { ! throw new QueryException( "expecting .elements or .indices after collection path expression in from" ); } } |
From: Kevin W. <kev...@us...> - 2004-12-31 18:23:02
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28006 Modified Files: HavingParser.cs IParser.cs IQueryFunctionInfo.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: IQueryFunctionInfo.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/IQueryFunctionInfo.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IQueryFunctionInfo.cs 6 Apr 2004 00:31:07 -0000 1.1 --- IQueryFunctionInfo.cs 31 Dec 2004 18:22:46 -0000 1.2 *************** *** 1,4 **** - using System; - using NHibernate.Engine; using NHibernate.Type; --- 1,2 ---- *************** *** 17,25 **** public interface IQueryFunctionInfo { ! IType QueryFunctionType(IType columnType, IMapping mapping); bool IsFunctionArgs { get; } ! bool IsFunctionNoArgsUseParanthesis { get; } } ! } --- 15,35 ---- public interface IQueryFunctionInfo { ! /// <summary> ! /// ! /// </summary> ! /// <param name="columnType"></param> ! /// <param name="mapping"></param> ! /// <returns></returns> ! IType QueryFunctionType( IType columnType, IMapping mapping ); + /// <summary> + /// + /// </summary> bool IsFunctionArgs { get; } ! /// <summary> ! /// ! /// </summary> ! bool IsFunctionNoArgsUseParanthesis { get; } } ! } \ No newline at end of file Index: HavingParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/HavingParser.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** HavingParser.cs 4 Dec 2004 22:41:19 -0000 1.7 --- HavingParser.cs 31 Dec 2004 18:22:46 -0000 1.8 *************** *** 1,5 **** ! using System; ! ! namespace NHibernate.Hql { /// <summary> --- 1,3 ---- ! namespace NHibernate.Hql { /// <summary> *************** *** 7,25 **** /// SQL having clause. /// </summary> ! public class HavingParser : WhereParser { ! ! public HavingParser(Dialect.Dialect d) : base(d) { } ! protected override void AppendToken(QueryTranslator q, string token) { // a String.Empty can get passed in here. If that occurs // then don't create a new SqlString for it - just ignore // it since it adds nothing to the sql being generated. ! if( token!=null && token.Length>0 ) { ! q.AppendHavingToken(token); } } --- 5,31 ---- /// SQL having clause. /// </summary> ! public class HavingParser : WhereParser { ! /// <summary> ! /// ! /// </summary> ! /// <param name="d"></param> ! public HavingParser( Dialect.Dialect d ) : base( d ) { } ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! /// <param name="token"></param> ! protected override void AppendToken( QueryTranslator q, string token ) { // a String.Empty can get passed in here. If that occurs // then don't create a new SqlString for it - just ignore // it since it adds nothing to the sql being generated. ! if( token != null && token.Length > 0 ) { ! q.AppendHavingToken( token ); } } Index: IParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/IParser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IParser.cs 14 Apr 2004 11:35:53 -0000 1.4 --- IParser.cs 31 Dec 2004 18:22:46 -0000 1.5 *************** *** 1,5 **** ! using System; ! ! namespace NHibernate.Hql { /// <summary> /// A parser is a state machine that accepts a string of tokens, --- 1,4 ---- ! namespace NHibernate.Hql ! { /// <summary> /// A parser is a state machine that accepts a string of tokens, *************** *** 8,15 **** /// for more than one token stream. /// </summary> ! public interface IParser { ! void Token(string token, QueryTranslator q); ! void Start(QueryTranslator q); ! void End(QueryTranslator q); } } \ No newline at end of file --- 7,30 ---- /// for more than one token stream. /// </summary> ! public interface IParser ! { ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! void Token( string token, QueryTranslator q ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! void Start( QueryTranslator q ); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! void End( QueryTranslator q ); } } \ No newline at end of file |
From: Kevin W. <kev...@us...> - 2004-12-31 18:22:44
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27954 Modified Files: OrderByParser.cs ParserHelper.cs PreprocessingParser.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: ParserHelper.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/ParserHelper.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ParserHelper.cs 14 Apr 2004 11:35:53 -0000 1.6 --- ParserHelper.cs 31 Dec 2004 18:22:33 -0000 1.7 *************** *** 1,35 **** - using System; - using NHibernate; using NHibernate.Util; ! namespace NHibernate.Hql { ! public class ParserHelper { ! public const string HqlVariablePrefix = ":"; ! public const string HqlSeparators = " \n\r\f\t,()=<>&|+-=/*'^![]#~\\"; //NOTICE: no " or . since they are part of (compound) identifiers ! public const string PathSeparators = "."; ! public const string Whitespace = " \n\r\f\t"; ! ! public static bool IsWhitespace(string str) { ! return Whitespace.IndexOf(str) > - 1; } ! ! private ParserHelper() { } ! ! public static void Parse(IParser p, string text, string seperators, QueryTranslator q) { ! StringTokenizer tokens = new StringTokenizer(text, seperators, true); ! p.Start(q); ! foreach(string token in tokens) { ! p.Token(token, q); } ! p.End(q); } } --- 1,49 ---- using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary></summary> ! public class ParserHelper { ! /// <summary></summary> public const string HqlVariablePrefix = ":"; ! /// <summary></summary> ! public const string HqlSeparators = " \n\r\f\t,()=<>&|+-=/*'^![]#~\\"; //NOTICE: no " or . since they are part of (compound) identifiers ! /// <summary></summary> ! public const string PathSeparators = "."; ! /// <summary></summary> ! public const string Whitespace = " \n\r\f\t"; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="str"></param> ! /// <returns></returns> ! public static bool IsWhitespace( string str ) { ! return Whitespace.IndexOf( str ) > - 1; } ! ! private ParserHelper() { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="p"></param> ! /// <param name="text"></param> ! /// <param name="seperators"></param> ! /// <param name="q"></param> ! public static void Parse( IParser p, string text, string seperators, QueryTranslator q ) { ! StringTokenizer tokens = new StringTokenizer( text, seperators, true ); ! p.Start( q ); ! foreach( string token in tokens ) { ! p.Token( token, q ); } ! p.End( q ); } } Index: PreprocessingParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/PreprocessingParser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PreprocessingParser.cs 4 Dec 2004 22:41:20 -0000 1.5 --- PreprocessingParser.cs 31 Dec 2004 18:22:33 -0000 1.6 *************** *** 1,20 **** - using System; using System.Collections; using System.Text; - using Iesi.Collections; - using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary> ! /// </summary> ! public class PreprocessingParser : IParser { private static ISet operators; private static IDictionary collectionProps; ! static PreprocessingParser() { operators = new HashedSet(); --- 1,17 ---- using System.Collections; using System.Text; using Iesi.Collections; using NHibernate.Util; ! namespace NHibernate.Hql { ! /// <summary></summary> ! public class PreprocessingParser : IParser { private static ISet operators; private static IDictionary collectionProps; ! /// <summary></summary> ! static PreprocessingParser() { operators = new HashedSet(); *************** *** 34,48 **** operators.Add( "not between" ); operators.Add( "not exists" ); ! collectionProps = new Hashtable(); ! collectionProps.Add("elements", "elements"); ! collectionProps.Add("indices", "indices"); ! collectionProps.Add("size", "size"); ! collectionProps.Add("maxindex", "maxIndex"); ! collectionProps.Add("minindex", "minIndex"); ! collectionProps.Add("maxelement", "maxElement"); ! collectionProps.Add("minelement", "minElement"); } ! private IDictionary replacements; private bool quoted; --- 31,45 ---- operators.Add( "not between" ); operators.Add( "not exists" ); ! collectionProps = new Hashtable(); ! collectionProps.Add( "elements", "elements" ); ! collectionProps.Add( "indices", "indices" ); ! collectionProps.Add( "size", "size" ); ! collectionProps.Add( "maxindex", "maxIndex" ); ! collectionProps.Add( "minindex", "minIndex" ); ! collectionProps.Add( "maxelement", "maxElement" ); ! collectionProps.Add( "minelement", "minElement" ); } ! private IDictionary replacements; private bool quoted; *************** *** 51,152 **** private string lastToken; private string currentCollectionProp; ! ! ! public PreprocessingParser(IDictionary replacements) { this.replacements = replacements; } ! ! public void Token(string token, QueryTranslator q) { - //handle quoted strings ! if (quoted) { ! quotedString.Append(token); } ! if ("'".Equals(token)) { ! if (quoted) { token = quotedString.ToString(); ! } ! else { ! quotedString = new StringBuilder(20).Append(token); } quoted = !quoted; } ! if (quoted) return; ! //ignore whitespace ! if (ParserHelper.IsWhitespace(token)) return; ! //do replacements ! string substoken = (string) replacements[token]; ! token = (substoken == null) ? token : substoken; ! //handle HQL2 collection syntax ! if (currentCollectionProp != null) { ! if (StringHelper.OpenParen.Equals(token)) { return; ! } ! else if (StringHelper.ClosedParen.Equals(token)) { currentCollectionProp = null; ! return ; ! } ! else { token += StringHelper.Dot + currentCollectionProp; } } ! else { ! string prop = (string) collectionProps[token.ToLower()]; ! if (prop != null) { currentCollectionProp = prop; ! return ; } } ! ! //handle <=, >=, !=, is not, not between, not in ! if (lastToken == null) { lastToken = token; ! } ! else { ! string doubleToken = (token.Length > 1)? ! lastToken + ' ' + token : lastToken + token; ! if (operators.Contains(doubleToken.ToLower())) { ! parser.Token(doubleToken, q); lastToken = null; ! } ! else { ! parser.Token(lastToken, q); lastToken = token; } } ! } ! ! public virtual void Start(QueryTranslator q) { quoted = false; ! parser.Start(q); } ! ! public virtual void End(QueryTranslator q) { ! if (lastToken != null) parser.Token(lastToken, q); ! parser.End(q); lastToken = null; currentCollectionProp = null; --- 48,173 ---- private string lastToken; private string currentCollectionProp; ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="replacements"></param> ! public PreprocessingParser( IDictionary replacements ) { this.replacements = replacements; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public void Token( string token, QueryTranslator q ) { //handle quoted strings ! if( quoted ) { ! quotedString.Append( token ); } ! if( "'".Equals( token ) ) { ! if( quoted ) { token = quotedString.ToString(); ! } ! else { ! quotedString = new StringBuilder( 20 ).Append( token ); } quoted = !quoted; } ! if( quoted ) ! { ! return; ! } ! //ignore whitespace ! if( ParserHelper.IsWhitespace( token ) ) ! { ! return; ! } ! //do replacements ! string substoken = ( string ) replacements[ token ]; ! token = ( substoken == null ) ? token : substoken; ! //handle HQL2 collection syntax ! if( currentCollectionProp != null ) { ! if( StringHelper.OpenParen.Equals( token ) ) { return; ! } ! else if( StringHelper.ClosedParen.Equals( token ) ) { currentCollectionProp = null; ! return; ! } ! else { token += StringHelper.Dot + currentCollectionProp; } } ! else { ! string prop = ( string ) collectionProps[ token.ToLower() ]; ! if( prop != null ) { currentCollectionProp = prop; ! return; } } ! ! //handle <=, >=, !=, is not, not between, not in ! if( lastToken == null ) { lastToken = token; ! } ! else { ! string doubleToken = ( token.Length > 1 ) ? ! lastToken + ' ' + token : lastToken + token; ! if( operators.Contains( doubleToken.ToLower() ) ) { ! parser.Token( doubleToken, q ); lastToken = null; ! } ! else { ! parser.Token( lastToken, q ); lastToken = token; } } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void Start( QueryTranslator q ) { quoted = false; ! parser.Start( q ); } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public virtual void End( QueryTranslator q ) { ! if( lastToken != null ) ! { ! parser.Token( lastToken, q ); ! } ! parser.End( q ); lastToken = null; currentCollectionProp = null; Index: OrderByParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/OrderByParser.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OrderByParser.cs 30 Apr 2004 08:57:59 -0000 1.5 --- OrderByParser.cs 31 Dec 2004 18:22:33 -0000 1.6 *************** *** 1,45 **** - using System; - using System.Collections; using NHibernate.Util; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the ORDER BY clause of a query /// </summary> ! public class OrderByParser : IParser { // This uses a PathExpressionParser but notice that compound paths are not valid, // only bare names and simple paths: ! // SELECT p FROM p IN CLASS eg.Person ORDER BY p.Name, p.Address, p ! // The reason for this is SQL doesn't let you sort by an expression you are // not returning in the result set. private PathExpressionParser pathExpressionParser = new PathExpressionParser(); ! ! public void Token(string token, QueryTranslator q) { ! if (q.IsName(StringHelper.Root(token))) { ! ParserHelper.Parse(pathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q); ! q.AppendOrderByToken(pathExpressionParser.WhereColumn); ! pathExpressionParser.AddAssociation(q); ! } ! else { ! q.AppendOrderByToken(token); } } ! ! public void Start(QueryTranslator q) { } ! ! public void End(QueryTranslator q) { } public OrderByParser() { --- 1,57 ---- using NHibernate.Util; ! namespace NHibernate.Hql ! { /// <summary> /// Parses the ORDER BY clause of a query /// </summary> ! public class OrderByParser : IParser { // This uses a PathExpressionParser but notice that compound paths are not valid, // only bare names and simple paths: ! // SELECT p FROM p IN CLASS eg.Person ORDER BY p.Name, p.Address, p ! // The reason for this is SQL doesn't let you sort by an expression you are // not returning in the result set. private PathExpressionParser pathExpressionParser = new PathExpressionParser(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public void Token( string token, QueryTranslator q ) { ! if( q.IsName( StringHelper.Root( token ) ) ) { ! ParserHelper.Parse( pathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! q.AppendOrderByToken( pathExpressionParser.WhereColumn ); ! pathExpressionParser.AddAssociation( q ); ! } ! else { ! q.AppendOrderByToken( token ); } } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void Start( QueryTranslator q ) { } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void End( QueryTranslator q ) { } + /// <summary></summary> public OrderByParser() { |
From: Kevin W. <kev...@us...> - 2004-12-31 18:22:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27895 Modified Files: SelectParser.cs SelectPathExpressionParser.cs WhereParser.cs Log Message: fixing xml comments and letting ReSharper do reformatting Index: WhereParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/WhereParser.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** WhereParser.cs 4 Dec 2004 22:41:20 -0000 1.26 --- WhereParser.cs 31 Dec 2004 18:22:14 -0000 1.27 *************** *** 2,22 **** using System.Collections; using System.Text; - using Iesi.Collections; - using NHibernate.Persister; using NHibernate.Type; using NHibernate.Util; ! namespace NHibernate.Hql [...1127 lines suppressed...] } } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! /// <param name="token"></param> ! protected virtual void AppendToken( QueryTranslator q, SqlString token ) { ! if( expectingIndex > 0 ) { pathExpressionParser.LastCollectionElementIndexValue = token.ToString(); ! } ! else { ! q.AppendWhereToken( token ); } } Index: SelectParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/SelectParser.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SelectParser.cs 4 Dec 2004 22:41:20 -0000 1.9 --- SelectParser.cs 31 Dec 2004 18:22:14 -0000 1.10 *************** *** 1,26 **** using System; using System.Collections; - using System.Data; - using Iesi.Collections; - - using NHibernate; - using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.Hql { - /// <summary> /// Parsers the select clause of a hibernate query, looking /// for a table (well, really class) alias. /// </summary> ! public class SelectParser : IParser { private ArrayList aggregateFuncTokenList = new ArrayList(); private static IDictionary aggregateFunctions = new Hashtable(); private static ISet countArguments = new HashedSet(); ! ! static SelectParser() { countArguments.Add( "distinct" ); --- 1,22 ---- using System; using System.Collections; using Iesi.Collections; using NHibernate.Type; + using NHibernate.Util; ! namespace NHibernate.Hql { /// <summary> /// Parsers the select clause of a hibernate query, looking /// for a table (well, really class) alias. /// </summary> ! public class SelectParser : IParser { private ArrayList aggregateFuncTokenList = new ArrayList(); private static IDictionary aggregateFunctions = new Hashtable(); private static ISet countArguments = new HashedSet(); ! ! /// <summary></summary> ! static SelectParser() { countArguments.Add( "distinct" ); *************** *** 29,32 **** --- 25,29 ---- } + /// <summary></summary> public SelectParser() { *************** *** 36,40 **** aggregatePathExpressionParser.UseThetaStyleJoin = true; } ! private bool ready; private bool aggregate; --- 33,37 ---- aggregatePathExpressionParser.UseThetaStyleJoin = true; } ! private bool ready; private bool aggregate; *************** *** 45,118 **** private SelectPathExpressionParser pathExpressionParser = new SelectPathExpressionParser(); ! private PathExpressionParser aggregatePathExpressionParser = new PathExpressionParser(); ! ! public void Token(string token, QueryTranslator q) { - string lctoken = token.ToLower(); ! ! if (first) { first = false; ! if (lctoken.Equals("distinct")) { q.Distinct = true; ! return ; ! } ! else if (lctoken.Equals("all")) { q.Distinct = false; ! return ; } } ! ! if (afterNew) { ! afterNew=false; ! holderClass = q.GetImportedClass(token); ! if (holderClass==null) throw new QueryException("class not found: " + token); q.HolderClass = holderClass; insideNew = true; ! } ! else if (token.Equals(StringHelper.Comma)) { ! if (ready) throw new QueryException("alias or expression expected in SELECT"); ! q.AppendScalarSelectToken(StringHelper.CommaSpace); ready = true; ! } ! else if ( "new".Equals(lctoken) ) { ! afterNew=true; ! ready=false; ! } ! else if (StringHelper.OpenParen.Equals(token)) { ! if (!aggregate && holderClass!=null && !ready) { //opening paren in new Foo ( ... ) ! ready=true; ! } ! else if (aggregate) { ! q.AppendScalarSelectToken(token); ! } ! else { ! throw new QueryException("aggregate function expected before ( in SELECT"); } ready = true; ! } ! else if (StringHelper.ClosedParen.Equals(token)) { ! if (insideNew && !aggregate && !ready) ! { //if we are inside a new Result(), but not inside a nested function insideNew = false; } ! else if (aggregate && ready) { ! q.AppendScalarSelectToken(token); ! aggregateFuncTokenList.RemoveAt(0); ! if (aggregateFuncTokenList.Count < 1) { aggregate = false; --- 42,125 ---- private SelectPathExpressionParser pathExpressionParser = new SelectPathExpressionParser(); ! private PathExpressionParser aggregatePathExpressionParser = new PathExpressionParser(); ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="token"></param> ! /// <param name="q"></param> ! public void Token( string token, QueryTranslator q ) { string lctoken = token.ToLower(); ! ! if( first ) { first = false; ! if( lctoken.Equals( "distinct" ) ) { q.Distinct = true; ! return; ! } ! else if( lctoken.Equals( "all" ) ) { q.Distinct = false; ! return; } } ! ! if( afterNew ) { ! afterNew = false; ! holderClass = q.GetImportedClass( token ); ! if( holderClass == null ) ! { ! throw new QueryException( "class not found: " + token ); ! } q.HolderClass = holderClass; insideNew = true; ! } ! else if( token.Equals( StringHelper.Comma ) ) { ! if( ready ) ! { ! throw new QueryException( "alias or expression expected in SELECT" ); ! } ! q.AppendScalarSelectToken( StringHelper.CommaSpace ); ready = true; ! } ! else if( "new".Equals( lctoken ) ) { ! afterNew = true; ! ready = false; ! } ! else if( StringHelper.OpenParen.Equals( token ) ) { ! if( !aggregate && holderClass != null && !ready ) { //opening paren in new Foo ( ... ) ! ready = true; ! } ! else if( aggregate ) { ! q.AppendScalarSelectToken( token ); ! } ! else { ! throw new QueryException( "aggregate function expected before ( in SELECT" ); } ready = true; ! } ! else if( StringHelper.ClosedParen.Equals( token ) ) { ! if( insideNew && !aggregate && !ready ) ! { //if we are inside a new Result(), but not inside a nested function insideNew = false; } ! else if( aggregate && ready ) { ! q.AppendScalarSelectToken( token ); ! aggregateFuncTokenList.RemoveAt( 0 ); ! if( aggregateFuncTokenList.Count < 1 ) { aggregate = false; *************** *** 120,154 **** } ! } ! else { ! throw new QueryException("( expected before ) in select"); } ! } ! else if (countArguments.Contains(lctoken)) { ! if (!ready || !aggregate) throw new QueryException(token + " only allowed inside aggregate function in SELECT"); ! q.AppendScalarSelectToken(token); ! if ( "*".Equals(token) ) q.AddSelectScalar(NHibernate.Int32); //special case ! } ! else if (aggregateFunctions.Contains(lctoken)) { ! if (!ready) throw new QueryException(", expected before aggregate function in SELECT: " + token); aggregate = true; ! aggregateFuncTokenList.Insert(0, lctoken); ready = false; ! q.AppendScalarSelectToken(token); ! if( !AggregateHasArgs(lctoken, q) ) { ! q.AddSelectScalar( AggregateType(aggregateFuncTokenList, null, q) ); ! if ( !AggregateFuncNoArgsHasParenthesis(lctoken, q) ) { ! aggregateFuncTokenList.RemoveAt(0); ! if (aggregateFuncTokenList.Count < 1) { aggregate = false; ready = false; } ! else { ready = true; --- 127,170 ---- } ! } ! else { ! throw new QueryException( "( expected before ) in select" ); } ! } ! else if( countArguments.Contains( lctoken ) ) { ! if( !ready || !aggregate ) ! { ! throw new QueryException( token + " only allowed inside aggregate function in SELECT" ); ! } ! q.AppendScalarSelectToken( token ); ! if( "*".Equals( token ) ) ! { ! q.AddSelectScalar( NHibernate.Int32 ); ! } //special case ! } ! else if( aggregateFunctions.Contains( lctoken ) ) { ! if( !ready ) ! { ! throw new QueryException( ", expected before aggregate function in SELECT: " + token ); ! } aggregate = true; ! aggregateFuncTokenList.Insert( 0, lctoken ); ready = false; ! q.AppendScalarSelectToken( token ); ! if( !AggregateHasArgs( lctoken, q ) ) { ! q.AddSelectScalar( AggregateType( aggregateFuncTokenList, null, q ) ); ! if( !AggregateFuncNoArgsHasParenthesis( lctoken, q ) ) { ! aggregateFuncTokenList.RemoveAt( 0 ); ! if( aggregateFuncTokenList.Count < 1 ) { aggregate = false; ready = false; } ! else { ready = true; *************** *** 157,229 **** } ! } ! else if (aggregate) { ! if (!ready) throw new QueryException("( expected after aggregate function in SELECT"); ! ParserHelper.Parse(aggregatePathExpressionParser, q.Unalias(token), ParserHelper.PathSeparators, q); ! ! if (aggregatePathExpressionParser.IsCollectionValued) { q.AddCollection( ! aggregatePathExpressionParser.CollectionName, ! aggregatePathExpressionParser.CollectionRole); } ! q.AppendScalarSelectToken(aggregatePathExpressionParser.WhereColumn); ! q.AddSelectScalar( AggregateType(aggregateFuncTokenList, aggregatePathExpressionParser.WhereColumnType, q) ); ! aggregatePathExpressionParser.AddAssociation(q); ! } ! else { ! if (!ready) throw new QueryException(", expected in SELECT"); ! ! ParserHelper.Parse(pathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q); ! if (pathExpressionParser.IsCollectionValued) { q.AddCollection( ! pathExpressionParser.CollectionName, ! pathExpressionParser.CollectionRole); ! } ! else if (pathExpressionParser.WhereColumnType.IsEntityType) { ! q.AddSelectClass(pathExpressionParser.SelectName); } ! q.AppendScalarSelectTokens(pathExpressionParser.WhereColumns); ! q.AddSelectScalar(pathExpressionParser.WhereColumnType); ! pathExpressionParser.AddAssociation(q); ! ready = false; } } ! public bool AggregateHasArgs(String funcToken, QueryTranslator q) { IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = (IQueryFunctionInfo)funcMap[funcToken]; return funcInfo.IsFunctionArgs; } ! public bool AggregateFuncNoArgsHasParenthesis(String funcToken, QueryTranslator q) { IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = (IQueryFunctionInfo)funcMap[funcToken]; return funcInfo.IsFunctionNoArgsUseParanthesis; } ! public IType AggregateType( ArrayList funcTokenList, IType type, QueryTranslator q) ! { IDictionary funcMap = q.AggregateFunctions; IType argType = type; IType retType = type; ! for (int i=0; i<funcTokenList.Count; i++) { argType = retType; ! String funcToken = (String) funcTokenList[i]; ! IQueryFunctionInfo funcInfo = (IQueryFunctionInfo)funcMap[funcToken]; retType = funcInfo.QueryFunctionType( argType, q.factory ); } ! return retType; ! } ! public void Start(QueryTranslator q) { ready = true; --- 173,274 ---- } ! } ! else if( aggregate ) { ! if( !ready ) ! { ! throw new QueryException( "( expected after aggregate function in SELECT" ); ! } ! ParserHelper.Parse( aggregatePathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! ! if( aggregatePathExpressionParser.IsCollectionValued ) { q.AddCollection( ! aggregatePathExpressionParser.CollectionName, ! aggregatePathExpressionParser.CollectionRole ); } ! q.AppendScalarSelectToken( aggregatePathExpressionParser.WhereColumn ); ! q.AddSelectScalar( AggregateType( aggregateFuncTokenList, aggregatePathExpressionParser.WhereColumnType, q ) ); ! aggregatePathExpressionParser.AddAssociation( q ); ! } ! else { ! if( !ready ) ! { ! throw new QueryException( ", expected in SELECT" ); ! } ! ! ParserHelper.Parse( pathExpressionParser, q.Unalias( token ), ParserHelper.PathSeparators, q ); ! if( pathExpressionParser.IsCollectionValued ) { q.AddCollection( ! pathExpressionParser.CollectionName, ! pathExpressionParser.CollectionRole ); ! } ! else if( pathExpressionParser.WhereColumnType.IsEntityType ) { ! q.AddSelectClass( pathExpressionParser.SelectName ); } ! q.AppendScalarSelectTokens( pathExpressionParser.WhereColumns ); ! q.AddSelectScalar( pathExpressionParser.WhereColumnType ); ! pathExpressionParser.AddAssociation( q ); ! ready = false; } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="funcToken"></param> ! /// <param name="q"></param> ! /// <returns></returns> ! public bool AggregateHasArgs( String funcToken, QueryTranslator q ) { IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; return funcInfo.IsFunctionArgs; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="funcToken"></param> ! /// <param name="q"></param> ! /// <returns></returns> ! public bool AggregateFuncNoArgsHasParenthesis( String funcToken, QueryTranslator q ) { IDictionary funcMap = q.AggregateFunctions; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; return funcInfo.IsFunctionNoArgsUseParanthesis; } ! /// <summary> ! /// ! /// </summary> ! /// <param name="funcTokenList"></param> ! /// <param name="type"></param> ! /// <param name="q"></param> ! /// <returns></returns> ! public IType AggregateType( ArrayList funcTokenList, IType type, QueryTranslator q ) ! { IDictionary funcMap = q.AggregateFunctions; IType argType = type; IType retType = type; ! for( int i = 0; i < funcTokenList.Count; i++ ) { argType = retType; ! String funcToken = ( String ) funcTokenList[ i ]; ! IQueryFunctionInfo funcInfo = ( IQueryFunctionInfo ) funcMap[ funcToken ]; retType = funcInfo.QueryFunctionType( argType, q.factory ); } ! return retType; ! } ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void Start( QueryTranslator q ) { ready = true; *************** *** 235,240 **** aggregateFunctions = q.AggregateFunctions; } ! ! public void End(QueryTranslator q) { } --- 280,289 ---- aggregateFunctions = q.AggregateFunctions; } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public void End( QueryTranslator q ) { } Index: SelectPathExpressionParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/SelectPathExpressionParser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SelectPathExpressionParser.cs 14 Apr 2004 11:35:53 -0000 1.4 --- SelectPathExpressionParser.cs 31 Dec 2004 18:22:14 -0000 1.5 *************** *** 1,33 **** ! using System; ! using System.Collections; ! ! namespace NHibernate.Hql ! { ! public class SelectPathExpressionParser : PathExpressionParser { ! ! ! public override void End(QueryTranslator q) { ! if (currentProperty != null && !q.IsShallowQuery) { // "finish off" the join ! Token(".", q); ! Token(null, q); } ! base.End(q); } ! ! protected override void SetExpectingCollectionIndex() { ! throw new QueryException("expecting .elements or .indices after collection path expression in select"); } ! public string SelectName { ! get ! { ! return currentName; ! } } } --- 1,32 ---- ! namespace NHibernate.Hql ! { ! /// <summary></summary> ! public class SelectPathExpressionParser : PathExpressionParser { ! /// <summary> ! /// ! /// </summary> ! /// <param name="q"></param> ! public override void End( QueryTranslator q ) { ! if( currentProperty != null && !q.IsShallowQuery ) { // "finish off" the join ! Token( ".", q ); ! Token( null, q ); } ! base.End( q ); } ! ! /// <summary></summary> ! protected override void SetExpectingCollectionIndex() { ! throw new QueryException( "expecting .elements or .indices after collection path expression in select" ); } ! /// <summary></summary> ! public string SelectName { ! get { return currentName; } } } |