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: Sergey K. <jus...@us...> - 2005-03-15 11:56:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6948/src/NHibernate.Test/NHSpecificTest Modified Files: GetTest.cs Log Message: * NH-230 bug fix * Implemented GetFilterTranslator closer to the H2.1 implementation * Added forgotten Flush in GetTest.GetAndModify Index: GetTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/GetTest.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GetTest.cs 8 Mar 2005 14:43:41 -0000 1.2 --- GetTest.cs 15 Mar 2005 11:56:33 -0000 1.3 *************** *** 51,68 **** { A a = new A( "name" ); ! ISession s = sessions.OpenSession(); ! s.Save( a ); ! s.Close(); ! s = sessions.OpenSession(); ! a = s.Get( typeof(A), a.Id ) as A; ! a.Name = "modified"; ! s.Flush(); ! s.Close(); ! s = sessions.OpenSession(); ! a = s.Get( typeof(A), a.Id ) as A; ! Assert.AreEqual( "modified", a.Name, "the name was modified" ); ! s.Close(); } } --- 51,72 ---- { A a = new A( "name" ); ! using( ISession s = sessions.OpenSession() ) ! { ! s.Save( a ); ! s.Flush(); ! } ! using( ISession s = sessions.OpenSession() ) ! { ! a = s.Get( typeof(A), a.Id ) as A; ! a.Name = "modified"; ! s.Flush(); ! } ! using( ISession s = sessions.OpenSession() ) ! { ! a = s.Get( typeof(A), a.Id ) as A; ! Assert.AreEqual( "modified", a.Name, "the name was modified" ); ! } } } |
From: Sergey K. <jus...@us...> - 2005-03-15 08:28:57
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20075/src/NHibernate/Impl Modified Files: SessionImpl.cs Log Message: Fix for a typo causing a bug in MasterDetailTest Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** SessionImpl.cs 14 Mar 2005 18:52:52 -0000 1.71 --- SessionImpl.cs 15 Mar 2005 08:28:47 -0000 1.72 *************** *** 2423,2427 **** persister.SetIdentifier( obj, id ); object version = Versioning.GetVersion( values, persister ); ! AddEntry( obj, Status.Loaded, values, id, version, lockMode, true, persister, false ); if( log.IsDebugEnabled && version != null ) --- 2423,2427 ---- persister.SetIdentifier( obj, id ); object version = Versioning.GetVersion( values, persister ); ! AddEntry( obj, Status.Loading, values, id, version, lockMode, true, persister, false ); if( log.IsDebugEnabled && version != null ) |
From: Paul H. <pha...@us...> - 2005-03-14 22:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Id In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Id Modified Files: TableGenerator.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: TableGenerator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Id/TableGenerator.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TableGenerator.cs 11 Feb 2005 05:12:34 -0000 1.16 --- TableGenerator.cs 14 Mar 2005 22:41:16 -0000 1.17 *************** *** 130,133 **** --- 130,134 ---- IDbCommand qps = conn.CreateCommand(); + IDataReader rs = null; qps.CommandText = query; qps.CommandType = CommandType.Text; *************** *** 135,139 **** try { ! IDataReader rs = qps.ExecuteReader(); if( !rs.Read() ) { --- 136,140 ---- try { ! rs = qps.ExecuteReader(); if( !rs.Read() ) { *************** *** 142,148 **** throw new IdentifierGenerationException( err ); } - result = Convert.ToInt32( rs[ 0 ] ); - rs.Close(); } // TODO: change to SqlException --- 143,147 ---- *************** *** 154,157 **** --- 153,158 ---- finally { + if ( rs != null ) rs.Close(); + qps.Dispose(); } *************** *** 175,178 **** --- 176,180 ---- finally { + ups.Dispose(); } *************** *** 183,188 **** return result; - } finally { --- 185,190 ---- return result; } + // TODO: Shouldn't we have a Catch with a rollback here? finally { |
From: Paul H. <pha...@us...> - 2005-03-14 22:42:20
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Hql Modified Files: QueryTranslator.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** QueryTranslator.cs 14 Mar 2005 18:52:35 -0000 1.56 --- QueryTranslator.cs 14 Mar 2005 22:41:15 -0000 1.57 *************** *** 1293,1296 **** --- 1293,1297 ---- parameters, false, session ); + // TODO: 2.1 - Check that something tidies up this cmd/reader IDataReader rs = GetResultSet( st, parameters.RowSelection, session ); return new EnumerableImpl( rs, st, session, ReturnTypes, ScalarColumnNames, parameters.RowSelection ); |
From: Paul H. <pha...@us...> - 2005-03-14 22:41:55
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Collection Modified Files: BasicCollectionPersister.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: BasicCollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/BasicCollectionPersister.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicCollectionPersister.cs 14 Mar 2005 18:51:48 -0000 1.3 --- BasicCollectionPersister.cs 14 Mar 2005 22:41:14 -0000 1.4 *************** *** 179,182 **** --- 179,183 ---- { //TODO: change to SqlException + // NB This calls cmd.Dispose session.Batcher.AbortBatch( e ); throw; |
From: Paul H. <pha...@us...> - 2005-03-14 22:41:50
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Persister Modified Files: EntityPersister.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** EntityPersister.cs 14 Mar 2005 18:53:15 -0000 1.37 --- EntityPersister.cs 14 Mar 2005 22:41:38 -0000 1.38 *************** *** 1197,1201 **** if( IsVersioned ) { ! //TODO: add some logging. } else --- 1197,1201 ---- if( IsVersioned ) { ! session.Batcher.CloseCommand( deleteCmd, null ); } else *************** *** 1205,1216 **** throw; } - finally - { - if( IsVersioned ) - { - session.Batcher.CloseCommand( deleteCmd, null ); - } - } - } --- 1205,1208 ---- |
From: Paul H. <pha...@us...> - 2005-03-14 22:41:50
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6385/nhibernate/src/NHibernate/Impl Modified Files: BatcherImpl.cs Log Message: Addresses disposal of IDbCommand as per NH-217 Index: BatcherImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/BatcherImpl.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** BatcherImpl.cs 6 Mar 2005 12:44:42 -0000 1.18 --- BatcherImpl.cs 14 Mar 2005 22:41:16 -0000 1.19 *************** *** 282,291 **** public void CloseCommand( IDbCommand cmd, IDataReader reader ) { - //TODO: fix this up a little bit - don't like it having the same name and just - // turning around and calling a diff method. CloseQueryCommand( cmd, reader ); - // CloseQueryCommand contains the logging so we don't need to call it - // here - putting it in CloseQueryCommand(IDbCommand) will ensure it always gets called. - //LogClosePreparedCommands(); } --- 282,286 ---- *************** *** 329,332 **** --- 324,331 ---- { // no equiv to the java code in here + if ( cmd != null ) + { + cmd.Dispose(); + } } catch( Exception e ) |
From: Paul H. <pha...@us...> - 2005-03-14 22:36:04
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4864/nhibernate/src/NHibernate/Loader Modified Files: OneToManyLoader.cs Log Message: Fixes NH-229/NH-230, silly bug where a new SqlString was constructed but not assigned! Index: OneToManyLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OneToManyLoader.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** OneToManyLoader.cs 14 Mar 2005 18:53:03 -0000 1.16 --- OneToManyLoader.cs 14 Mar 2005 22:35:52 -0000 1.17 *************** *** 125,129 **** if( collectionPersister.HasWhere ) { ! whereSqlString.Append( " and " ).Append( collectionPersister.GetSQLWhereString( alias ) ); } --- 125,129 ---- if( collectionPersister.HasWhere ) { ! whereSqlString = whereSqlString.Append( " and " ).Append( collectionPersister.GetSQLWhereString( alias ) ); } |
From: Paul H. <pha...@us...> - 2005-03-14 19:04:51
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10039/nhibernate/src/NHibernate.DomainModel Modified Files: Master.cs Log Message: Refactored as per 2.1 Index: Master.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/Master.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Master.cs 18 Nov 2004 02:45:43 -0000 1.5 --- Master.cs 14 Mar 2005 19:04:36 -0000 1.6 *************** *** 44,48 **** { get { return _details; } ! set { _details = value; } } --- 44,52 ---- { get { return _details; } ! set ! { ! System.Diagnostics.Trace.WriteLine( "Details assigned" ); ! _details = value; ! } } |
From: Paul H. <pha...@us...> - 2005-03-14 19:04:29
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9971/nhibernate/src/NHibernate.DomainModel Modified Files: CustomPersister.cs Log Message: Refactored as per 2.1 Index: CustomPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.DomainModel/CustomPersister.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CustomPersister.cs 6 Mar 2005 12:44:32 -0000 1.5 --- CustomPersister.cs 14 Mar 2005 19:04:11 -0000 1.6 *************** *** 18,22 **** public class CustomPersister : IClassPersister { - private static readonly Hashtable Instances = new Hashtable(); private static readonly IIdentifierGenerator Generator = new CounterGenerator(); --- 18,21 ---- *************** *** 60,63 **** --- 59,67 ---- } + public int[] FindModified(object[] x, object[] y, object owner, ISessionImplementor session) + { + return FindDirty( x, y, owner, session ); + } + public bool[] PropertyUpdateability { *************** *** 75,78 **** --- 79,87 ---- } + public bool IsCacheInvalidationRequired + { + get { return false; } + } + public bool HasCascades { *************** *** 229,233 **** } ! public void Update(object id, object[] fields, int[] dirtyFields, object oldVersion, object obj, ISessionImplementor session) { Instances[id] = ( (Custom)obj).Clone(); --- 238,242 ---- } ! public void Update(object id, object[] fields, int[] dirtyFields, object[] oldFields, object oldVersion, object obj, ISessionImplementor session) { Instances[id] = ( (Custom)obj).Clone(); *************** *** 299,302 **** --- 308,319 ---- } + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="version"></param> + /// <param name="obj"></param> + /// <param name="lockMode"></param> + /// <param name="session"></param> public void Lock(object id, object version, object obj, LockMode lockMode, ISessionImplementor session) { *************** *** 304,307 **** --- 321,346 ---- } + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="version"></param> + /// <param name="session"></param> + /// <returns></returns> + public object[] GetCurrentPersistentState( object id, object version, ISessionImplementor session ) + { + return null; + } + + /// <summary> + /// + /// </summary> + /// <param name="id"></param> + /// <param name="session"></param> + /// <returns></returns> + public object CurrentVersion( object id, ISessionImplementor session ) + { + return this; + } #endregion } |
From: Paul H. <pha...@us...> - 2005-03-14 19:02:32
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9338/nhibernate/src/NHibernate/Mapping Modified Files: Property.cs Log Message: Introduce new CascadeStyles as Loader now upgraded Index: Property.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Property.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Property.cs 14 Mar 2005 14:36:26 -0000 1.13 --- Property.cs 14 Mar 2005 19:02:12 -0000 1.14 *************** *** 112,118 **** else if( cascade.Equals( "all-delete-orphan" ) ) { ! // TODO: 2.1 - Reintroduce when Loader porting completed ! //return Cascades.CascadeStyle.StyleAllDeleteOrphan; ! return Cascades.CascadeStyle.StyleAllGC; } else if( cascade.Equals( "none" ) ) --- 112,116 ---- else if( cascade.Equals( "all-delete-orphan" ) ) { ! return Cascades.CascadeStyle.StyleAllDeleteOrphan; } else if( cascade.Equals( "none" ) ) *************** *** 130,136 **** else if( cascade.Equals( "delete-orphan" ) ) { ! // TODO: 2.1 - Reintroduce when Loader porting completed ! //return Cascades.CascadeStyle.StyleDeleteOrphan; ! return Cascades.CascadeStyle.StyleOnlyDelete; } else --- 128,132 ---- else if( cascade.Equals( "delete-orphan" ) ) { ! return Cascades.CascadeStyle.StyleDeleteOrphan; } else |
From: Paul H. <pha...@us...> - 2005-03-14 18:59:40
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8593/nhibernate/src/NHibernate/SqlCommand Added Files: WhereBuilder.cs Log Message: --- NEW FILE: WhereBuilder.cs --- using System; using NHibernate.Engine; using NHibernate.Type; namespace NHibernate.SqlCommand { /// <summary> /// Allows us to construct SQL WHERE fragments /// </summary> public class WhereBuilder : SqlBaseBuilder { /// <summary> /// /// </summary> /// <param name="factory"></param> public WhereBuilder( ISessionFactoryImplementor factory ) : base( factory ) { } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="columnNames"></param> /// <param name="whereType"></param> /// <returns></returns> public SqlString WhereClause( string alias, string[ ] columnNames, IType whereType ) { Parameter[ ] parameters = Parameter.GenerateParameters( Factory, alias, columnNames, whereType ); return ToWhereString( alias, columnNames, parameters ); } } } |
From: Paul H. <pha...@us...> - 2005-03-14 18:56:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7707/nhibernate/src/NHibernate.Test Modified Files: FooBarTest.cs MultiTableTest.cs Log Message: Refactored as per 2.1 Index: FooBarTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/FooBarTest.cs,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** FooBarTest.cs 6 Mar 2005 12:44:34 -0000 1.85 --- FooBarTest.cs 14 Mar 2005 18:56:13 -0000 1.86 *************** *** 1173,1176 **** --- 1173,1177 ---- s = sessions.OpenSession(); baz = (Baz) ( (object[])s.Find("select baz, baz from baz in class NHibernate.DomainModel.Baz")[0] )[1]; + Assert.AreEqual( 1, baz.CascadingBars.Count, "baz.CascadingBars.Count" ); Foo foo = new Foo(); s.Save(foo); *************** *** 1179,1188 **** baz.FooArray = new Foo[] { foo, foo, null, foo2 } ; baz.FooSet.Add(foo ); ! baz.Customs.Add( new string[] {"new", "custom"} ); baz.StringArray = null; baz.StringList[0] = "new value"; baz.StringSet = new Iesi.Collections.HashedSet(); ! Assert.AreEqual( 1, baz.StringGlarchMap.Count ); IList list; --- 1180,1191 ---- baz.FooArray = new Foo[] { foo, foo, null, foo2 } ; baz.FooSet.Add(foo ); ! baz.Customs.Add( new string[] { "new", "custom" } ); baz.StringArray = null; baz.StringList[0] = "new value"; baz.StringSet = new Iesi.Collections.HashedSet(); ! // HACK: 2.1 - The java (and old NH) version has the result of this as 1, I can't see why it should be since we explicitly put 2 items into StringGlarchMap? ! //Assert.AreEqual( 2, baz.StringGlarchMap.Count, "baz.StringGlarchMap.Count" ); ! Assert.AreEqual( 1, baz.StringGlarchMap.Count, "baz.StringGlarchMap.Count" ); IList list; *************** *** 1360,1364 **** } ! Assert.AreEqual( 1, s.Delete("from g in class Glarch") ); s.Flush(); s.Disconnect(); --- 1363,1367 ---- } ! Assert.AreEqual( 1, s.Delete("from g in class Glarch"), "Delete('from g in class Glarch')" ); s.Flush(); s.Disconnect(); Index: MultiTableTest.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/MultiTableTest.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MultiTableTest.cs 28 Nov 2004 03:13:43 -0000 1.7 --- MultiTableTest.cs 14 Mar 2005 18:56:13 -0000 1.8 *************** *** 248,252 **** simp = (Simple)s.Load( typeof(Simple), sid ); Assert.IsFalse( simp is Multi ); ! Assert.IsTrue( multi is Multi ); Assert.AreEqual( "extra23", multi.ExtraProp ); Assert.AreEqual( "newer name", multi.Name ); --- 248,253 ---- simp = (Simple)s.Load( typeof(Simple), sid ); Assert.IsFalse( simp is Multi ); ! // Can't see the point of this test since the variable is declared as Multi! ! //Assert.IsTrue( multi is Multi ); Assert.AreEqual( "extra23", multi.ExtraProp ); Assert.AreEqual( "newer name", multi.Name ); *************** *** 364,368 **** simp = (Simple)s.Load( typeof(Simple), simpId ); Assert.IsFalse( simp is Multi ); ! Assert.IsTrue( multi is Multi ); Assert.AreEqual( "extra23", multi.ExtraProp ); Assert.AreEqual( "newer name", multi.Name ); --- 365,370 ---- simp = (Simple)s.Load( typeof(Simple), simpId ); Assert.IsFalse( simp is Multi ); ! // Can't see the point of this test since the variable is declared as Multi! ! //Assert.IsTrue( multi is Multi ); Assert.AreEqual( "extra23", multi.ExtraProp ); Assert.AreEqual( "newer name", multi.Name ); |
From: Paul H. <pha...@us...> - 2005-03-14 18:55:14
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7392/nhibernate/src/NHibernate Modified Files: NHibernate-1.1.csproj Log Message: Refactored as per 2.1 Index: NHibernate-1.1.csproj =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/NHibernate-1.1.csproj,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** NHibernate-1.1.csproj 6 Mar 2005 12:44:39 -0000 1.76 --- NHibernate-1.1.csproj 14 Mar 2005 18:55:03 -0000 1.77 *************** *** 350,353 **** --- 350,358 ---- /> <File + RelPath = "Cache\ILockable.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Cache\ISoftLock.cs" SubType = "Code" *************** *** 450,458 **** /> <File - RelPath = "Collection\CollectionPersister.cs" - SubType = "Code" - BuildAction = "Compile" - /> - <File RelPath = "Collection\CollectionPropertyMapping.cs" SubType = "Code" --- 455,458 ---- *************** *** 1800,1803 **** --- 1800,1808 ---- /> <File + RelPath = "SqlCommand\WhereBuilder.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "SqlTypes\AnsiStringFixedLengthSqlType.cs" SubType = "Code" *************** *** 1945,1948 **** --- 1950,1958 ---- /> <File + RelPath = "Transform\IResultTransformer.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Type\AbstractType.cs" SubType = "Code" |
From: Paul H. <pha...@us...> - 2005-03-14 18:54:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7313/nhibernate/src/NHibernate Modified Files: ICriteria.cs Log Message: Refactored as per 2.1 Index: ICriteria.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/ICriteria.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ICriteria.cs 1 Jan 2005 03:32:56 -0000 1.7 --- ICriteria.cs 14 Mar 2005 18:54:43 -0000 1.8 *************** *** 115,118 **** --- 115,133 ---- /// <returns></returns> ICriteria SetFetchMode( string associationPath, FetchMode mode ); + + /// <summary> + /// Set the lock mode of the current entity + /// </summary> + /// <param name="lockMode">the lock mode</param> + /// <returns></returns> + ICriteria SetLockMode( LockMode lockMode ); + + /// <summary> + /// Set the lock mode of the aliased entity + /// </summary> + /// <param name="alias">an alias</param> + /// <param name="lockMode">the lock mode</param> + /// <returns></returns> + ICriteria SetLockMode( string alias, LockMode lockMode ); } } \ No newline at end of file |
From: Paul H. <pha...@us...> - 2005-03-14 18:54:31
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7196/nhibernate/src/NHibernate/Type Modified Files: AbstractType.cs ArrayType.cs BooleanType.cs ComponentType.cs IType.cs ManyToOneType.cs ObjectType.cs OneToOneType.cs PersistentCollectionType.cs TypeFactory.cs Log Message: Refactored as per 2.1 Index: AbstractType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/AbstractType.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** AbstractType.cs 31 Dec 2004 23:50:57 -0000 1.10 --- AbstractType.cs 14 Mar 2005 18:54:20 -0000 1.11 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Data; using NHibernate.Engine; *************** *** 59,62 **** --- 60,78 ---- /// <summary> + /// Says whether the value has been modified + /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <returns></returns> + public virtual bool IsModified( + object old, + object current, + ISessionImplementor session ) + { + return IsDirty( old, current, session ); + } + + /// <summary> /// Disassembles the object into a cacheable representation. /// </summary> *************** *** 138,141 **** --- 154,177 ---- } + + /// <summary> + /// + /// </summary> + /// <param name="original"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <param name="owner"></param> + /// <param name="copiedAlready"></param> + /// <returns></returns> + public virtual object Copy( object original, object current, ISessionImplementor session, object owner, IDictionary copiedAlready ) + { + if ( original == null ) + { + return null; + } + return Assemble( Disassemble( original, session ), session, owner ); + } + + /// <summary> /// Maps identifiers to Entities or Collections. Index: ObjectType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ObjectType.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ObjectType.cs 1 Mar 2005 16:24:50 -0000 1.11 --- ObjectType.cs 14 Mar 2005 18:54:20 -0000 1.12 *************** *** 4,7 **** --- 4,8 ---- using NHibernate.Loader; using NHibernate.Persister; + using NHibernate.Proxy; using NHibernate.SqlTypes; using NHibernate.Util; *************** *** 358,361 **** --- 359,384 ---- } + /// <summary> + /// + /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <returns></returns> + public override bool IsModified(object old, object current, ISessionImplementor session) + { + if ( old == null ) + { + return current != null; + } + if ( current == null ) + { + return old != null; + } + ObjectTypeCacheEntry holder = (ObjectTypeCacheEntry) old; + + return holder.clazz != NHibernateProxyHelper.GetClass( current ) || identifierType.IsModified( holder.id, Id( current, session ), session ); + } + /// <summary></summary> public override bool IsAssociationType Index: IType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/IType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** IType.cs 11 Feb 2005 21:01:17 -0000 1.12 --- IType.cs 14 Mar 2005 18:54:20 -0000 1.13 *************** *** 1,3 **** --- 1,4 ---- using System; + using System.Collections; using System.Data; using NHibernate.Engine; *************** *** 55,59 **** System.Type ReturnedClass { get; } - /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.Equals"]/*' --- 56,59 ---- *************** *** 66,69 **** --- 66,73 ---- bool IsDirty( object old, object current, ISessionImplementor session ); + /// <include file='IType.cs.xmldoc' + /// path='//members[@type="IType"]/member[@name="M:IType.IsModified"]/*' + /// /> + bool IsModified( object oldHydratedState, object currentState, ISessionImplementor session ); /// <include file='IType.cs.xmldoc' *************** *** 82,86 **** void NullSafeSet( IDbCommand st, object value, int index, ISessionImplementor session ); - /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="M:IType.ToXML"]/*' --- 86,89 ---- *************** *** 88,92 **** string ToXML( object value, ISessionFactoryImplementor factory ); - /// <include file='IType.cs.xmldoc' /// path='//members[@type="IType"]/member[@name="P:IType.Name"]/*' --- 91,94 ---- *************** *** 129,132 **** --- 131,138 ---- object ResolveIdentifier( object value, ISessionImplementor session, object owner ); + /// <include file='IType.cs.xmldoc' + /// path='//members[@type="IType"]/member[@name="M:IType.Copy"]/*' + /// /> + object Copy( object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready ); } } \ No newline at end of file Index: TypeFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/TypeFactory.cs,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** TypeFactory.cs 5 Mar 2005 10:43:51 -0000 1.45 --- TypeFactory.cs 14 Mar 2005 18:54:20 -0000 1.46 *************** *** 1097,1119 **** } ! /* /// <summary> ! /// Return <tt>-1</tt> if non-dirty, or the index of the first dirty value otherwise /// </summary> /// <param name="types"></param> ! /// <param name="x"></param> ! /// <param name="y"></param> ! /// <param name="owner"></param> ! /// <param name="factory"></param> /// <returns></returns> ! public static int FindDirty(IType[] types, object[] x, object[] y, object owner, ISessionFactoryImplementor factory) { ! for (int i=0; i<types.Length; i++) { ! if ( types[i].IsDirty( x[i], y[i], owner, factory ) ) { ! return i; } } ! return -1; } - */ } } \ No newline at end of file --- 1097,1138 ---- } ! /// <summary> ! /// Determine if any of the given field values are modified, ! /// returning an array containing indexes of ! /// the dirty fields or null if no fields are modified. /// </summary> /// <param name="types"></param> ! /// <param name="old"></param> ! /// <param name="current"></param> ! /// <param name="check"></param> ! /// <param name="session"></param> /// <returns></returns> ! public static int[ ] FindModified( IType[ ] types, object[ ] old, object[ ] current, bool[ ] check, ISessionImplementor session ) ! { ! int[ ] results = null; ! int count = 0; ! for( int i = 0; i < types.Length; i++ ) ! { ! if( check[ i ] && types[ i ].IsModified( old[ i ], current[ i ], session ) ) ! { ! if( results == null ) ! { ! results = new int[types.Length]; ! } ! results[ count++ ] = i; } } ! if( count == 0 ) ! { ! return null; ! } ! else ! { ! int[ ] trimmed = new int[count]; ! System.Array.Copy( results, 0, trimmed, 0, count ); ! return trimmed; ! } } } } \ No newline at end of file Index: PersistentCollectionType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/PersistentCollectionType.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PersistentCollectionType.cs 1 Mar 2005 16:24:50 -0000 1.22 --- PersistentCollectionType.cs 14 Mar 2005 18:54:20 -0000 1.23 *************** *** 46,51 **** public override sealed bool Equals( object x, object y ) { ! // proxies? - comment in h2.0.3 also ! return x == y; } --- 46,52 ---- public override sealed bool Equals( object x, object y ) { ! return x == y || ! ( x is PersistentCollection && ( (PersistentCollection) x ).IsWrapper( y ) ) || ! ( y is PersistentCollection && ( (PersistentCollection) y ).IsWrapper( x ) ); } *************** *** 173,186 **** { return null; - // commented out in h2.0.3 also - // if (value==null) { - // return null; - // } - // else { - // object id = session.GetLoadedCollectionKey( (PersistentCollection) value ); - // if (id==null) - // throw new AssertionFailure("Null collection id"); - // return id; - // } } --- 174,177 ---- *************** *** 202,205 **** --- 193,203 ---- } + private bool IsOwnerVersioned( ISessionImplementor session ) + { + System.Type ownerClass = session.Factory.GetCollectionPersister( role ).OwnerClass; + + return session.Factory.GetPersister( ownerClass ).IsVersioned; + } + /// <summary> /// *************** *** 211,225 **** public override bool IsDirty( object old, object current, ISessionImplementor session ) { ! System.Type ownerClass = session.Factory.GetCollectionPersister( role ).OwnerClass; ! if( !session.Factory.GetPersister( ownerClass ).IsVersioned ) ! { ! // collections don't dirty an unversioned parent entity ! return false; ! } ! else ! { ! return base.IsDirty( old, current, session ); ! } } --- 209,216 ---- public override bool IsDirty( object old, object current, ISessionImplementor session ) { ! // collections don't dirty an unversioned parent entity ! // TODO: I don't like this implementation; it would be better if this was handled by SearchForDirtyCollections(); ! return IsOwnerVersioned( session ) && base.IsDirty( old, current, session ); } *************** *** 262,268 **** public IJoinable GetJoinable( ISessionFactoryImplementor factory ) { ! // TODO: Uncomment once CollectionPersister knows about IJoinable ! //return (IJoinable) factory.GetCollectionPersister( role ); ! return null; } --- 253,257 ---- public IJoinable GetJoinable( ISessionFactoryImplementor factory ) { ! return (IJoinable) factory.GetCollectionPersister( role ); } *************** *** 326,329 **** --- 315,330 ---- /// /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <returns></returns> + public override bool IsModified(object old, object current, ISessionImplementor session) + { + return false; + } + + /// <summary> + /// + /// </summary> /// <param name="factory"></param> /// <returns></returns> *************** *** 332,338 **** try { ! // TODO: Uncomment once CollectionPersister knows about IQueryableCollection ! //IQueryableCollection collectionPersister = (IQueryableCollection) factory.GetCollectionPersister( role ); ! IQueryableCollection collectionPersister = null; if ( collectionPersister.ElementType.IsEntityType ) { --- 333,337 ---- try { ! IQueryableCollection collectionPersister = (IQueryableCollection) factory.GetCollectionPersister( role ); if ( collectionPersister.ElementType.IsEntityType ) { *************** *** 341,349 **** return collectionPersister.ElementPersister.MappedClass; } ! catch ( InvalidCastException ) { ! // TODO: Change to a mapping error ! throw; } } } --- 340,389 ---- return collectionPersister.ElementPersister.MappedClass; } ! catch ( InvalidCastException ice) { ! throw new MappingException( "collection role is not queryable", ice ); ! } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="original"></param> ! /// <param name="target"></param> ! /// <param name="session"></param> ! /// <param name="owner"></param> ! /// <param name="copiedAlready"></param> ! /// <returns></returns> ! public override object Copy( object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready ) ! { ! if ( original == null ) ! { ! return null; } + if ( !NHibernateUtil.IsInitialized( original ) ) + { + return target; + } + + IList originalCopy = new ArrayList( (IList) original ); + IList result = target == null ? (IList) Instantiate( session, session.Factory.GetCollectionPersister( role ) ) : (IList) target; + result.Clear(); + IType elemType = GetElementType( session.Factory ); + foreach ( object obj in originalCopy ) + { + result.Add( elemType.Copy( obj, null, session, owner, copiedAlready ) ); + } + + return result; + } + + /// <summary> + /// + /// </summary> + /// <param name="factory"></param> + /// <returns></returns> + public IType GetElementType( ISessionFactoryImplementor factory ) + { + return factory.GetCollectionPersister( Role ).ElementType; } } Index: ComponentType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ComponentType.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ComponentType.cs 1 Mar 2005 16:24:50 -0000 1.13 --- ComponentType.cs 14 Mar 2005 18:54:20 -0000 1.14 *************** *** 16,32 **** private static readonly ILog log = LogManager.GetLogger( typeof( ComponentType ) ); ! private System.Type componentClass; ! private ConstructorInfo contructor; ! private IType[ ] types; ! private IGetter[ ] getters; ! private ISetter[ ] setters; ! private string[ ] propertyNames; ! private int propertySpan; ! private Cascades.CascadeStyle[ ] cascade; ! private OuterJoinFetchStrategy[ ] joinedFetch; ! private string parentProperty; // not used !?! private ISetter parentSetter; ! //TODO: This is new... ! private IGetter parentGetter; // not used !?! /// <summary> --- 16,30 ---- private static readonly ILog log = LogManager.GetLogger( typeof( ComponentType ) ); ! private readonly System.Type componentClass; ! private readonly ConstructorInfo contructor; ! private readonly IType[ ] propertyTypes; ! private readonly IGetter[ ] getters; ! private readonly ISetter[ ] setters; ! private readonly string[ ] propertyNames; ! private readonly int propertySpan; ! private readonly Cascades.CascadeStyle[ ] cascade; ! private readonly OuterJoinFetchStrategy[ ] joinedFetch; private ISetter parentSetter; ! private IGetter parentGetter; /// <summary> *************** *** 38,46 **** { //not called at runtime so doesn't matter if its slow :) ! SqlType[ ] sqlTypes = new SqlType[GetColumnSpan( mapping )]; int n = 0; for( int i = 0; i < propertySpan; i++ ) { ! SqlType[ ] subtypes = types[ i ].SqlTypes( mapping ); for( int j = 0; j < subtypes.Length; j++ ) { --- 36,44 ---- { //not called at runtime so doesn't matter if its slow :) ! SqlType[ ] sqlTypes = new SqlType[ GetColumnSpan( mapping ) ]; int n = 0; for( int i = 0; i < propertySpan; i++ ) { ! SqlType[ ] subtypes = propertyTypes[ i ].SqlTypes( mapping ); for( int j = 0; j < subtypes.Length; j++ ) { *************** *** 61,65 **** for( int i = 0; i < propertySpan; i++ ) { ! span += types[ i ].GetColumnSpan( mapping ); } return span; --- 59,63 ---- for( int i = 0; i < propertySpan; i++ ) { ! span += propertyTypes[ i ].GetColumnSpan( mapping ); } return span; *************** *** 74,78 **** /// <param name="propertySetters"></param> /// <param name="foundCustomAcessor"></param> ! /// <param name="types"></param> /// <param name="joinedFetch"></param> /// <param name="cascade"></param> --- 72,76 ---- /// <param name="propertySetters"></param> /// <param name="foundCustomAcessor"></param> ! /// <param name="propertyTypes"></param> /// <param name="joinedFetch"></param> /// <param name="cascade"></param> *************** *** 84,88 **** ISetter[ ] propertySetters, bool foundCustomAcessor, // not used !?! ! IType[ ] types, OuterJoinFetchStrategy[ ] joinedFetch, Cascades.CascadeStyle[ ] cascade, --- 82,86 ---- ISetter[ ] propertySetters, bool foundCustomAcessor, // not used !?! ! IType[ ] propertyTypes, OuterJoinFetchStrategy[ ] joinedFetch, Cascades.CascadeStyle[ ] cascade, *************** *** 91,95 **** { this.componentClass = componentClass; ! this.types = types; propertySpan = properties.Length; getters = propertyGetters; --- 89,93 ---- { this.componentClass = componentClass; ! this.propertyTypes = propertyTypes; propertySpan = properties.Length; getters = propertyGetters; *************** *** 116,125 **** parentGetter = pa.GetGetter( componentClass, parentProperty ); } - this.parentProperty = parentProperty; this.propertyNames = properties; this.cascade = cascade; this.joinedFetch = joinedFetch; contructor = ReflectHelper.GetDefaultConstructor( componentClass ); - } --- 114,121 ---- *************** *** 166,170 **** for( int i = 0; i < propertySpan; i++ ) { ! if( !types[ i ].Equals( getters[ i ].Get( x ), getters[ i ].Get( y ) ) ) { return false; --- 162,166 ---- for( int i = 0; i < propertySpan; i++ ) { ! if( !propertyTypes[ i ].Equals( getters[ i ].Get( x ), getters[ i ].Get( y ) ) ) { return false; *************** *** 193,197 **** for( int i = 0; i < getters.Length; i++ ) { ! if( types[ i ].IsDirty( getters[ i ].Get( x ), getters[ i ].Get( y ), session ) ) { return true; --- 189,193 ---- for( int i = 0; i < getters.Length; i++ ) { ! if( propertyTypes[ i ].IsDirty( getters[ i ].Get( x ), getters[ i ].Get( y ), session ) ) { return true; *************** *** 216,222 **** for( int i = 0; i < propertySpan; i++ ) { ! int length = types[ i ].GetColumnSpan( session.Factory ); string[ ] range = ArrayHelper.Slice( names, begin, length ); ! object val = types[ i ].NullSafeGet( rs, range, session, owner ); if( val != null ) { --- 212,218 ---- for( int i = 0; i < propertySpan; i++ ) { ! int length = propertyTypes[ i ].GetColumnSpan( session.Factory ); string[ ] range = ArrayHelper.Slice( names, begin, length ); ! object val = propertyTypes[ i ].NullSafeGet( rs, range, session, owner ); if( val != null ) { *************** *** 255,260 **** for( int i = 0; i < propertySpan; i++ ) { ! types[ i ].NullSafeSet( st, subvalues[ i ], begin, session ); ! begin += types[ i ].GetColumnSpan( session.Factory ); } } --- 251,256 ---- for( int i = 0; i < propertySpan; i++ ) { ! propertyTypes[ i ].NullSafeSet( st, subvalues[ i ], begin, session ); ! begin += propertyTypes[ i ].GetColumnSpan( session.Factory ); } } *************** *** 350,354 **** public IType[ ] Subtypes { ! get { return types; } } --- 346,350 ---- public IType[ ] Subtypes { ! get { return propertyTypes; } } *************** *** 391,395 **** for( int i = 0; i < propertySpan; i++ ) { ! values[ i ] = types[ i ].DeepCopy( values[ i ] ); } --- 387,391 ---- for( int i = 0; i < propertySpan; i++ ) { ! values[ i ] = propertyTypes[ i ].DeepCopy( values[ i ] ); } *************** *** 466,472 **** { object[ ] values = GetPropertyValues( value ); ! for( int i = 0; i < types.Length; i++ ) { ! values[ i ] = types[ i ].Disassemble( values[ i ], session ); } return values; --- 462,468 ---- { object[ ] values = GetPropertyValues( value ); ! for( int i = 0; i < propertyTypes.Length; i++ ) { ! values[ i ] = propertyTypes[ i ].Disassemble( values[ i ], session ); } return values; *************** *** 491,497 **** object[ ] values = ( object[ ] ) obj; object[ ] assembled = new object[values.Length]; ! for( int i = 0; i < types.Length; i++ ) { ! assembled[ i ] = types[ i ].Assemble( values[ i ], session, owner ); } object result = Instantiate(); --- 487,493 ---- object[ ] values = ( object[ ] ) obj; object[ ] assembled = new object[values.Length]; ! for( int i = 0; i < propertyTypes.Length; i++ ) { ! assembled[ i ] = propertyTypes[ i ].Assemble( values[ i ], session, owner ); } object result = Instantiate(); *************** *** 517,521 **** --- 513,599 ---- } + /// <summary> + /// + /// </summary> + /// <param name="rs"></param> + /// <param name="names"></param> + /// <param name="session"></param> + /// <param name="owner"></param> + /// <returns></returns> + public override object Hydrate( IDataReader rs, string[] names, ISessionImplementor session, object owner ) + { + int begin = 0; + bool notNull = false; + object[] values = new object[ propertySpan ]; + for ( int i = 0; i < propertySpan; i++ ) + { + int length = propertyTypes[ i ].GetColumnSpan( session.Factory ); + string[] range = ArrayHelper.Slice( names, begin, length ); //cache this + object val = propertyTypes[ i ].Hydrate( rs, range, session, owner ); + if ( val != null ) + { + notNull = true; + } + values[ i ] = val; + begin += length; + } + + return notNull ? values : null; + } + + /// <summary> + /// + /// </summary> + /// <param name="value"></param> + /// <param name="session"></param> + /// <param name="owner"></param> + /// <returns></returns> + public override object ResolveIdentifier( object value, ISessionImplementor session, object owner ) + { + if ( value != null ) + { + object result = Instantiate( owner, session ); + object[] values = ( object[] ) value; + for ( int i = 0; i < values.Length; i++ ) + { + values[ i ] = propertyTypes[ i ].ResolveIdentifier( values[ i ], session, owner ); + } + SetPropertyValues( result, values ); + return result; + } + else + { + return null; + } + } + /// <summary> + /// + /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <returns></returns> + public override bool IsModified( object old, object current, ISessionImplementor session ) + { + if ( current == null ) + { + return old != null; + } + if ( old == null ) + { + return current != null; + } + object[] currentValues = GetPropertyValues( current, session ); + object[] oldValues = ( object[] ) old; + for ( int i = 0; i < currentValues.Length; i++ ) + { + if ( propertyTypes[ i ].IsModified( oldValues[ i ], currentValues[ i ], session ) ) + { + return true; + } + } + return false; + } } } \ No newline at end of file Index: OneToOneType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/OneToOneType.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OneToOneType.cs 1 Mar 2005 16:24:50 -0000 1.9 --- OneToOneType.cs 14 Mar 2005 18:54:20 -0000 1.10 *************** *** 76,79 **** --- 76,91 ---- } + /// <summary> + /// + /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="session"></param> + /// <returns></returns> + public override bool IsModified( object old, object current, ISessionImplementor session ) + { + return false; + } + /// <summary></summary> public override bool UsePrimaryKeyAsForeignKey Index: BooleanType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/BooleanType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** BooleanType.cs 14 Feb 2005 03:38:45 -0000 1.12 --- BooleanType.cs 14 Mar 2005 18:54:20 -0000 1.13 *************** *** 60,63 **** --- 60,71 ---- /// /// </summary> + public System.Type PrimitiveClass + { + get { return typeof( bool ); } + } + + /// <summary> + /// + /// </summary> public override System.Type ReturnedClass { Index: ManyToOneType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ManyToOneType.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ManyToOneType.cs 8 Mar 2005 16:48:16 -0000 1.11 --- ManyToOneType.cs 14 Mar 2005 18:54:20 -0000 1.12 *************** *** 65,68 **** --- 65,82 ---- /// <summary></summary> + public override bool IsModified(object old, object current, ISessionImplementor session) + { + if ( current == null ) + { + return old != null; + } + if ( old == null ) + { + return current != null ; + } + return GetIdentifierOrUniqueKeyType( session.Factory ).IsModified( old, GetIdentifier( current, session ), session ); + } + + /// <summary></summary> public override ForeignKeyType ForeignKeyType { Index: ArrayType.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Type/ArrayType.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ArrayType.cs 1 Mar 2005 16:24:50 -0000 1.10 --- ArrayType.cs 14 Mar 2005 18:54:20 -0000 1.11 *************** *** 9,14 **** public class ArrayType : PersistentCollectionType { ! //private System.Type elementClass; ! private System.Type arrayClass; /// <summary> --- 9,14 ---- public class ArrayType : PersistentCollectionType { ! private readonly System.Type elementClass; ! private readonly System.Type arrayClass; /// <summary> *************** *** 19,23 **** public ArrayType( string role, System.Type elementClass ) : base( role ) { ! //this.elementClass = elementClass; arrayClass = System.Array.CreateInstance( elementClass, 0 ).GetType(); } --- 19,23 ---- public ArrayType( string role, System.Type elementClass ) : base( role ) { ! this.elementClass = elementClass; arrayClass = System.Array.CreateInstance( elementClass, 0 ).GetType(); } *************** *** 95,98 **** --- 95,129 ---- get { return true; } } + + /// <summary> + /// + /// </summary> + /// <param name="original"></param> + /// <param name="target"></param> + /// <param name="session"></param> + /// <param name="owner"></param> + /// <param name="copiedAlready"></param> + /// <returns></returns> + public override object Copy( object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready ) + { + if ( original == null ) + { + return null; + } + if ( original == target ) + { + return target; + } + object[] orig = (object[]) original; + int length = orig.Length; + object[] result = (object[]) System.Array.CreateInstance( elementClass, length ); + + IType elemType = GetElementType( session.Factory ); + for ( int i = 0; i < length; i++ ) + { + result[ i ] = elemType.Copy( orig[ i ], null, session, owner, copiedAlready ); + } + return result; + } } } \ No newline at end of file |
From: Paul H. <pha...@us...> - 2005-03-14 18:54:17
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7150/nhibernate/src/NHibernate/Transaction Modified Files: AdoTransaction.cs Log Message: Refactored as per 2.1 Index: AdoTransaction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Transaction/AdoTransaction.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AdoTransaction.cs 30 Jan 2005 19:36:16 -0000 1.2 --- AdoTransaction.cs 14 Mar 2005 18:54:08 -0000 1.3 *************** *** 138,142 **** finally { ! session.AfterTransactionCompletion(); } } --- 138,142 ---- finally { ! session.AfterTransactionCompletion( true ); } } *************** *** 170,174 **** finally { ! session.AfterTransactionCompletion(); } } --- 170,174 ---- finally { ! session.AfterTransactionCompletion( false ); } } |
From: Paul H. <pha...@us...> - 2005-03-14 18:53:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6809/nhibernate/src/NHibernate/Persister Modified Files: AbstractEntityPersister.cs AbstractPropertyMapping.cs EntityPersister.cs IClassPersister.cs ILoadable.cs IOuterJoinLoadable.cs IQueryable.cs ISqlLoadable.cs NormalizedEntityPersister.cs PersisterFactory.cs Log Message: Refactored as per 2.1 Index: AbstractPropertyMapping.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractPropertyMapping.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractPropertyMapping.cs 1 Mar 2005 16:24:50 -0000 1.1 --- AbstractPropertyMapping.cs 14 Mar 2005 18:53:15 -0000 1.2 *************** *** 24,30 **** public abstract class AbstractPropertyMapping : IPropertyMapping { ! private Hashtable typesByPropertyPath = new Hashtable(); ! private Hashtable columnsByPropertyPath = new Hashtable(); ! private Hashtable formulaTemplatesByPropertyPath = new Hashtable(); /// <summary> --- 24,30 ---- public abstract class AbstractPropertyMapping : IPropertyMapping { ! private readonly Hashtable typesByPropertyPath = new Hashtable(); ! private readonly Hashtable columnsByPropertyPath = new Hashtable(); ! private readonly Hashtable formulaTemplatesByPropertyPath = new Hashtable(); /// <summary> *************** *** 96,99 **** --- 96,100 ---- { // HACK: Test for use so we don't attempt to duplicate - differs from the java code + /* if ( !typesByPropertyPath.ContainsKey( path ) ) { *************** *** 102,105 **** --- 103,110 ---- HandlePath( path, type ); } + */ + typesByPropertyPath[ path ] = type; + columnsByPropertyPath[ path ] = columns; + HandlePath( path, type ); } *************** *** 113,116 **** --- 118,122 ---- { // HACK: Test for use so we don't attempt to duplicate - differs from the java code + /* if ( !typesByPropertyPath.ContainsKey( path ) ) { *************** *** 119,122 **** --- 125,132 ---- HandlePath( path, type ); } + */ + typesByPropertyPath[ path ] = type ; + formulaTemplatesByPropertyPath[ path ] = template ; + HandlePath( path, type ); } Index: NormalizedEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/NormalizedEntityPersister.cs,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** NormalizedEntityPersister.cs 1 Mar 2005 16:24:50 -0000 1.40 --- NormalizedEntityPersister.cs 14 Mar 2005 18:53:15 -0000 1.41 *************** *** 31,42 **** // for the base class there is only 1 table private readonly string[ ] tableNames; - private readonly string[ ] naturalOrderTableNames; // two dimensional array that is indexed as tableKeyColumns[tableIndex][columnIndex] private readonly string[ ][ ] tableKeyColumns; - private readonly string[ ][ ] naturalOrderTableKeyColumns; - private readonly bool hasFormulaProperties; --- 31,39 ---- *************** *** 69,72 **** --- 66,70 ---- private readonly bool[ ] isClassOrSuperclassTable; + // SQL strings private SqlString[ ] sqlDeleteStrings; private SqlString[ ] sqlInsertStrings; *************** *** 85,93 **** // the array is indexed as propertyTables[propertyIndex] = tableIndex private readonly int[ ] propertyTables; - private readonly int[ ] naturalOrderPropertyTables; - - // TODO: understand this variable and its context/contents - //private readonly bool[] propertyHasColumns; private bool[ ] propertyHasColumns; --- 83,87 ---- *************** *** 99,103 **** // selecting a column. It is indexed the same as propertyColumnNames private readonly string[ ][ ] propertyColumnNameAliases; - private readonly string[ ] propertyFormulaTemplates; --- 93,96 ---- *************** *** 115,121 **** // the closure of all columns used by the entire hierarchy including // subclasses and superclasses of this class private readonly string[ ] subclassColumnClosure; private readonly string[ ] subclassColumnClosureAliases; ! private readonly int[ ] subclassColumnTableNumberClosure; // subclass discrimination works by assigning particular values to certain --- 108,117 ---- // the closure of all columns used by the entire hierarchy including // subclasses and superclasses of this class + private readonly int[ ] subclassColumnTableNumberClosure; private readonly string[ ] subclassColumnClosure; private readonly string[ ] subclassColumnClosureAliases; ! private readonly int[ ] subclassFormulaTableNumberClosure; ! private readonly string[ ] subclassFormulaTemplateClosure; ! private readonly string[ ] subclassFormulaAliasClosure; // subclass discrimination works by assigning particular values to certain *************** *** 124,137 **** // key = DiscrimatorValue, value = Subclass Type private readonly Hashtable subclassesByDiscriminatorValue = new Hashtable(); - - // the value the discrimator column will contain to indicate the type of object - // the row contains. - // the array is indexed as discriminatorValues[subclassIndex]. The subclassIndex comes - // from the field subclassClosure private readonly string[ ] discriminatorValues; - private readonly string[ ] notNullColumns; - - // TODO: figure out how this is used private readonly int[ ] tableNumbers; --- 120,125 ---- *************** *** 145,151 **** protected IUniqueEntityLoader loader; - // private static readonly string[ ] StringArray = {}; - // private static readonly IType[ ] TypeArray = {}; - private static readonly ILog log = LogManager.GetLogger( typeof( NormalizedEntityPersister ) ); --- 133,136 ---- *************** *** 227,240 **** this.naturalOrderTableKeyColumns = ( string[ ][ ] ) keyColumns.ToArray( typeof( string[ ] ) ); - // convert the local ArrayList variables into arrays for the fields in the class - this.tableNames = ( string[ ] ) tables.ToArray( typeof( string ) ); - this.tableKeyColumns = ( string[ ][ ] ) keyColumns.ToArray( typeof( string[ ] ) ); - // the description of these variables is the same as before ArrayList subtables = new ArrayList(); keyColumns = new ArrayList(); - subtables.Add( this.qualifiedTableName ); ! keyColumns.Add( IdentifierColumnNames ); foreach( Table tab in model.SubclassTableClosureCollection ) { --- 212,220 ---- this.naturalOrderTableKeyColumns = ( string[ ][ ] ) keyColumns.ToArray( typeof( string[ ] ) ); // the description of these variables is the same as before ArrayList subtables = new ArrayList(); keyColumns = new ArrayList(); subtables.Add( this.qualifiedTableName ); ! keyColumns.Add( base.IdentifierColumnNames ); foreach( Table tab in model.SubclassTableClosureCollection ) { *************** *** 256,260 **** this.subclassTableNameClosure = ( string[ ] ) subtables.ToArray( typeof( string ) ); this.subclassTableKeyColumns = ( string[ ][ ] ) keyColumns.ToArray( typeof( string[ ] ) ); - this.isClassOrSuperclassTable = new bool[this.subclassTableNameClosure.Length]; for( int j = 0; j < subclassTableNameClosure.Length; j++ ) --- 236,239 ---- *************** *** 279,324 **** this.propertyFormulaTemplates = new string[ HydrateSpan ]; ! Hashtable thisClassProperties = new Hashtable(); ! // just a dummy object for the value so I can treat Hashtable like a Set ! object thisClassPropertiesObject = new object(); ! int propertyIndex = 0; bool foundFormula = false; foreach( Mapping.Property prop in model.PropertyClosureCollection ) { ! thisClassProperties.Add( prop, thisClassPropertiesObject ); Table tab = prop.Value.Table; string tabname = tab.GetQualifiedName( Dialect, factory.DefaultSchema ); ! ! this.propertyTables[ propertyIndex ] = GetTableId( tabname, this.tableNames ); ! this.naturalOrderPropertyTables[ propertyIndex ] = GetTableId( tabname, this.naturalOrderTableNames ); ! this.propertyColumnSpans[ propertyIndex ] = prop.ColumnSpan; if ( prop.IsFormula ) { ! this.propertyColumnNames[ propertyIndex ] = new string[] { prop.Formula.Alias }; ! this.propertyColumnSpans[ propertyIndex ] = 1; ! this.propertyColumnNameAliases[ propertyIndex ] = new string[] { prop.Formula.GetTemplate( Dialect ) }; foundFormula = true; } else { ! string[ ] propCols = new string[propertyColumnSpans[ propertyIndex ]]; ! string[ ] propAliases = new string[propertyColumnSpans[ propertyIndex ]]; ! int columnIndex = 0; foreach( Column col in prop.ColumnCollection ) { string colname = col.GetQuotedName( Dialect ); ! propCols[ columnIndex ] = colname; ! propAliases[ columnIndex ] = col.Alias( Dialect, tab.UniqueInteger.ToString() + StringHelper.Underscore ); ! columnIndex++; } ! ! this.propertyColumnNames[ propertyIndex ] = propCols; ! this.propertyColumnNameAliases[ propertyIndex ] = propAliases; } ! propertyIndex++; } --- 258,300 ---- this.propertyFormulaTemplates = new string[ HydrateSpan ]; ! HashedSet thisClassProperties = new HashedSet(); ! int i = 0; bool foundFormula = false; foreach( Mapping.Property prop in model.PropertyClosureCollection ) { ! thisClassProperties.Add( prop ); Table tab = prop.Value.Table; string tabname = tab.GetQualifiedName( Dialect, factory.DefaultSchema ); ! this.propertyTables[ i ] = GetTableId( tabname, this.tableNames ); ! this.naturalOrderPropertyTables[ i ] = GetTableId( tabname, this.naturalOrderTableNames ); if ( prop.IsFormula ) { ! this.propertyColumnNames[ i ] = new string[] { prop.Formula.Alias }; ! this.propertyColumnSpans[ i ] = 1; ! this.propertyFormulaTemplates[ i ] = prop.Formula.GetTemplate( Dialect ); foundFormula = true; } else { ! this.propertyColumnSpans[ i ] = prop.ColumnSpan; ! string[ ] propCols = new string[propertyColumnSpans[ i ]]; ! string[ ] propAliases = new string[propertyColumnSpans[ i ]]; ! ! int j = 0; foreach( Column col in prop.ColumnCollection ) { string colname = col.GetQuotedName( Dialect ); ! propCols[ j ] = colname; ! propAliases[ j ] = col.Alias( Dialect, tab.UniqueInteger.ToString() + StringHelper.Underscore ); ! j++; } ! this.propertyColumnNames[ i ] = propCols; ! this.propertyColumnNameAliases[ i ] = propAliases; } ! i++; } *************** *** 339,348 **** ArrayList columns = new ArrayList(); //this.subclassColumnClosure ArrayList types = new ArrayList(); //this.subclassPropertyTypeClosure ArrayList names = new ArrayList(); //this.subclassPropertyNameClosure ArrayList propColumns = new ArrayList(); //this.subclassPropertyColumnNameClosure ArrayList coltables = new ArrayList(); //this.subclassColumnTableNumberClosure ArrayList joinedFetchesList = new ArrayList(); //this.subclassPropertyEnableJoinedFetch - ArrayList aliases = new ArrayList(); //this.subclassColumnClosureAlias ArrayList propTables = new ArrayList(); // this.subclassPropertyTableNameClosure ArrayList definedBySubclass = new ArrayList(); // this.propertyDefinedOnSubclass --- 315,327 ---- ArrayList columns = new ArrayList(); //this.subclassColumnClosure + ArrayList aliases = new ArrayList(); + ArrayList formulaAliases = new ArrayList(); + ArrayList formulaTemplates = new ArrayList(); ArrayList types = new ArrayList(); //this.subclassPropertyTypeClosure ArrayList names = new ArrayList(); //this.subclassPropertyNameClosure ArrayList propColumns = new ArrayList(); //this.subclassPropertyColumnNameClosure ArrayList coltables = new ArrayList(); //this.subclassColumnTableNumberClosure + ArrayList formtables = new ArrayList(); ArrayList joinedFetchesList = new ArrayList(); //this.subclassPropertyEnableJoinedFetch ArrayList propTables = new ArrayList(); // this.subclassPropertyTableNameClosure ArrayList definedBySubclass = new ArrayList(); // this.propertyDefinedOnSubclass *************** *** 354,371 **** Table tab = prop.Value.Table; string tabname = tab.GetQualifiedName( Dialect, factory.DefaultSchema ); - string[ ] cols = new string[prop.ColumnSpan]; - types.Add( prop.Type ); int tabnum = GetTableId( tabname, subclassTableNameClosure ); propTables.Add( tabnum ); ! int l = 0; ! foreach( Column col in prop.ColumnCollection ) { ! columns.Add( col.GetQuotedName( Dialect ) ); ! coltables.Add( tabnum ); ! cols[ l++ ] = col.GetQuotedName( Dialect ); ! aliases.Add( col.Alias( Dialect, tab.UniqueInteger.ToString() + StringHelper.Underscore ) ); } ! propColumns.Add( cols ); joinedFetchesList.Add( prop.Value.OuterJoinFetchSetting ); } --- 333,361 ---- Table tab = prop.Value.Table; string tabname = tab.GetQualifiedName( Dialect, factory.DefaultSchema ); int tabnum = GetTableId( tabname, subclassTableNameClosure ); propTables.Add( tabnum ); + types.Add( prop.Type ); ! if ( prop.IsFormula ) { ! formulaTemplates.Add( prop.Formula.GetTemplate( Dialect ) ); ! propColumns.Add( new string [] { } ) ; ! formulaAliases.Add( prop.Formula.Alias ); ! formtables.Add( tabnum ); } ! else ! { ! string[ ] cols = new string[prop.ColumnSpan]; ! int l = 0; ! foreach( Column col in prop.ColumnCollection ) ! { ! columns.Add( col.GetQuotedName( Dialect ) ); ! coltables.Add( tabnum ); ! cols[ l++ ] = col.GetQuotedName( Dialect ); ! aliases.Add( col.Alias( Dialect, tab.UniqueInteger.ToString() + StringHelper.Underscore ) ); ! } ! propColumns.Add( cols ); ! } ! joinedFetchesList.Add( prop.Value.OuterJoinFetchSetting ); } *************** *** 377,384 **** subclassPropertyNameClosure = ( string[ ] ) names.ToArray( typeof( string ) ); subclassPropertyTableNumberClosure = ( int[ ] ) propTables.ToArray( typeof( int ) ); ! subclassPropertyColumnNameClosure = ( string[ ][ ] ) propColumns.ToArray( typeof( string[ ] ) ); ! subclassPropertyEnableJoinedFetch = new OuterJoinFetchStrategy[joinedFetchesList.Count]; int n = 0; foreach( OuterJoinFetchStrategy ojlType in joinedFetchesList ) --- 367,376 ---- subclassPropertyNameClosure = ( string[ ] ) names.ToArray( typeof( string ) ); subclassPropertyTableNumberClosure = ( int[ ] ) propTables.ToArray( typeof( int ) ); ! subclassFormulaAliasClosure = ( string[ ] ) formulaAliases.ToArray( typeof( string ) ); ! subclassFormulaTemplateClosure = ( string[ ] ) formulaTemplates.ToArray( typeof( string ) ); ! subclassFormulaTableNumberClosure = ( int[ ] ) formtables.ToArray( typeof( int ) ); subclassPropertyColumnNameClosure = ( string[ ][ ] ) propColumns.ToArray( typeof( string[ ] ) ); ! subclassPropertyEnableJoinedFetch = new OuterJoinFetchStrategy[ joinedFetchesList.Count ]; int n = 0; foreach( OuterJoinFetchStrategy ojlType in joinedFetchesList ) *************** *** 387,391 **** } ! propertyDefinedOnSubclass = new bool[definedBySubclass.Count]; n = 0; foreach( bool pdos in definedBySubclass ) --- 379,383 ---- } ! propertyDefinedOnSubclass = new bool[ definedBySubclass.Count ]; n = 0; foreach( bool pdos in definedBySubclass ) *************** *** 394,398 **** } ! // moved the sql generation to PostIntantiate System.Type mappedClass = model.MappedClass; --- 386,390 ---- } ! // ****** Moved the sql generation to PostIntantiate ***** System.Type mappedClass = model.MappedClass; *************** *** 415,427 **** this.tableNumbers = new int[subclassSpan]; ! this.tableNumbers[ subclassSpan - 1 ] = GetTableId( model.Table.GetQualifiedName( Dialect, factory.DefaultSchema ), this.subclassTableNameClosure ); this.notNullColumns = new string[subclassSpan]; foreach( Column col in model.Table.PrimaryKey.ColumnCollection ) { notNullColumns[ subclassSpan - 1 ] = col.GetQuotedName( Dialect ); //only once } } else --- 407,423 ---- this.tableNumbers = new int[subclassSpan]; ! int id = GetTableId( model.Table.GetQualifiedName( Dialect, factory.DefaultSchema ), this.subclassTableNameClosure ); + this.tableNumbers[ subclassSpan - 1 ] = id; this.notNullColumns = new string[subclassSpan]; + this.notNullColumns[ subclassSpan - 1 ] = subclassTableKeyColumns[ id ][ 0 ]; + /* foreach( Column col in model.Table.PrimaryKey.ColumnCollection ) { notNullColumns[ subclassSpan - 1 ] = col.GetQuotedName( Dialect ); //only once } + */ } else *************** *** 443,454 **** subclassesByDiscriminatorValue.Add( disc, sc.MappedClass ); discriminatorValues[ p ] = disc.ToString(); ! tableNumbers[ p ] = GetTableId( sc.Table.GetQualifiedName( Dialect, factory.DefaultSchema ), ! subclassTableNameClosure ! ); foreach( Column col in sc.Table.PrimaryKey.ColumnCollection ) { notNullColumns[ p ] = col.GetQuotedName( Dialect ); //only once; } } } --- 439,453 ---- subclassesByDiscriminatorValue.Add( disc, sc.MappedClass ); discriminatorValues[ p ] = disc.ToString(); ! int id = GetTableId( sc.Table.GetQualifiedName( Dialect, factory.DefaultSchema ), ! this.subclassTableNameClosure ); ! tableNumbers[ p ] = id; ! notNullColumns[ p ] = subclassTableKeyColumns[ id ][ 0 ]; ! /* foreach( Column col in sc.Table.PrimaryKey.ColumnCollection ) { notNullColumns[ p ] = col.GetQuotedName( Dialect ); //only once; } + */ } } *************** *** 460,465 **** } ! // moved the propertyHasColumns into PostInstantiate } --- 459,468 ---- } ! // moved the propertyHasColumns into PostInstantiate as it needs the SQL strings + // needs identifier info so moved to PostInstatiate + //InitLockers( ); + + InitSubclassPropertyAliasesMap( model ); } *************** *** 476,479 **** --- 479,484 ---- CreateUniqueKeyLoaders( factory ); + InitLockers( ); + // initialize the Statements - these are in the PostInstantiate method because we need // to have every other IClassPersister loaded so we can resolve the IType for the *************** *** 493,500 **** sqlConcreteSelectString = GenerateConcreteSelectString(); ! InitLockers(); ! ! //TODO: find out why this was in the constructor in the spot it was... ! propertyHasColumns = new Boolean[sqlUpdateStrings.Length]; for( int m = 0; m < sqlUpdateStrings.Length; m++ ) { --- 498,503 ---- sqlConcreteSelectString = GenerateConcreteSelectString(); ! // This is used to determine updates for objects that came in via update() ! propertyHasColumns = new bool[sqlUpdateStrings.Length]; for( int m = 0; m < sqlUpdateStrings.Length; m++ ) { *************** *** 813,827 **** protected virtual SqlString[ ] GenerateUpdateStrings( bool[ ] includeProperty ) { ! SqlString[ ] updateStrings = new SqlString[naturalOrderTableNames.Length]; for( int j = 0; j < naturalOrderTableNames.Length; j++ ) { ! SqlUpdateBuilder updateBuilder = new SqlUpdateBuilder( factory ); ! updateBuilder.SetTableName( naturalOrderTableNames[ j ] ); //TODO: figure out what the hasColumns variable comes into play for?? bool hasColumns = false; - for( int i = 0; i < propertyColumnNames.Length; i++ ) { --- 816,834 ---- protected virtual SqlString[ ] GenerateUpdateStrings( bool[ ] includeProperty ) { ! SqlString[ ] results = new SqlString[naturalOrderTableNames.Length]; for( int j = 0; j < naturalOrderTableNames.Length; j++ ) { ! SqlUpdateBuilder updateBuilder = new SqlUpdateBuilder( factory ) ! .SetTableName( naturalOrderTableNames[ j ] ) ! .SetIdentityColumn( naturalOrderTableKeyColumns[ j ], IdentifierType ); ! if( j == 0 && IsVersioned ) ! { ! updateBuilder.SetVersionColumn( new string[ ] {VersionColumnName}, VersionType ); ! } //TODO: figure out what the hasColumns variable comes into play for?? bool hasColumns = false; for( int i = 0; i < propertyColumnNames.Length; i++ ) { *************** *** 832,849 **** } } ! ! updateBuilder.SetIdentityColumn( naturalOrderTableKeyColumns[ j ], IdentifierType ); ! ! if( j == 0 && IsVersioned ) ! { ! updateBuilder.SetVersionColumn( new string[ ] {VersionColumnName}, VersionType ); ! } ! ! updateStrings[ j ] = hasColumns ? ! updateBuilder.ToSqlString() : ! null; } ! return updateStrings; } --- 839,846 ---- } } ! results[ j ] = hasColumns ? updateBuilder.ToSqlString() : null; } ! return results; } *************** *** 1020,1082 **** /// <summary> - /// Do a version check - /// </summary> - /// <param name="id"></param> - /// <param name="version"></param> - /// <param name="obj"></param> - /// <param name="lockMode"></param> - /// <param name="session"></param> - public override void Lock( object id, object version, object obj, LockMode lockMode, ISessionImplementor session ) - { - if( lockMode != LockMode.None ) - { - if( log.IsDebugEnabled ) - { - log.Debug( "Locking entity: " + ClassName + '#' + id ); - if( IsVersioned ) - { - log.Debug( "Version: " + version ); - } - } - - IDbCommand st = session.Batcher.PrepareCommand( GetLockString( lockMode ) ); - IDataReader rs = null; - - try - { - IdentifierType.NullSafeSet( st, id, 0, session ); - if( IsVersioned ) - { - VersionType.NullSafeSet( st, version, IdentifierColumnNames.Length, session ); - } - - // IDataReader rs = st.ExecuteReader(); - rs = session.Batcher.ExecuteReader( st ); - // try - // { - if( !rs.Read() ) - { - throw new StaleObjectStateException( MappedClass, id ); - } - // } - // finally - // { - // rs.Close(); - // } - } - //TODO: change this to catch a Sql Exception and log it - catch( Exception e ) - { - log.Error( e.Message, e ); - throw; - } - finally - { - session.Batcher.CloseCommand( st, rs ); - } - } - } - - /// <summary> /// /// </summary> --- 1017,1020 ---- *************** *** 1336,1357 **** /// <summary> ! /// Update an object. /// </summary> - /// <param name="id"></param> - /// <param name="fields"></param> /// <param name="dirtyFields"></param> ! /// <param name="oldVersion"></param> ! /// <param name="obj"></param> ! /// <param name="session"></param> ! public override void Update( object id, object[ ] fields, int[ ] dirtyFields, object oldVersion, object obj, ISessionImplementor session ) { - bool[ ] tableUpdateNeeded; if( dirtyFields == null ) { ! tableUpdateNeeded = propertyHasColumns; //for object that came in via update() } else { ! tableUpdateNeeded = new bool[naturalOrderTableNames.Length]; for( int i = 0; i < dirtyFields.Length; i++ ) { --- 1274,1290 ---- /// <summary> ! /// Decide which tables need to be updated /// </summary> /// <param name="dirtyFields"></param> ! /// <returns></returns> ! private bool[] GetTableUpdateNeeded( int[] dirtyFields ) { if( dirtyFields == null ) { ! return propertyHasColumns; //for object that came in via update() } else { ! bool[ ] tableUpdateNeeded = new bool[naturalOrderTableNames.Length]; for( int i = 0; i < dirtyFields.Length; i++ ) { *************** *** 1362,1389 **** tableUpdateNeeded[ 0 ] = true; } } if( UseDynamicUpdate && dirtyFields != null ) { ! bool[ ] propsToUpdate = new bool[ HydrateSpan ]; ! for( int i = 0; i < HydrateSpan; i++ ) ! { ! bool dirty = false; ! for( int j = 0; j < dirtyFields.Length; j++ ) ! { ! if( dirtyFields[ j ] == i ) ! { ! dirty = true; ! } ! } ! propsToUpdate[ i ] = dirty || VersionProperty == i; ! } ! ! Update( id, fields, propsToUpdate, tableUpdateNeeded, oldVersion, obj, GenerateUpdateStrings( propsToUpdate ), session ); } else { ! Update( id, fields, PropertyUpdateability, tableUpdateNeeded, oldVersion, obj, SqlUpdateStrings, session ); } } --- 1295,1331 ---- tableUpdateNeeded[ 0 ] = true; } + return tableUpdateNeeded; } + } + /// <summary> + /// Update an object. + /// </summary> + /// <param name="id"></param> + /// <param name="fields"></param> + /// <param name="dirtyFields"></param> + /// <param name="oldFields"></param> + /// <param name="oldVersion"></param> + /// <param name="obj"></param> + /// <param name="session"></param> + public override void Update( object id, object[ ] fields, int[ ] dirtyFields, object[] oldFields, object oldVersion, object obj, ISessionImplementor session ) + { + bool[ ] tableUpdateNeeded = GetTableUpdateNeeded( dirtyFields ); + + SqlString[] updateStrings; + bool[] propsToUpdate; if( UseDynamicUpdate && dirtyFields != null ) { ! // decide which columns we really need to update ! propsToUpdate = GetPropertiesToUpdate( dirtyFields ); ! updateStrings = GenerateUpdateStrings( propsToUpdate ); } else { ! // just update them all ! propsToUpdate = PropertyUpdateability; ! updateStrings = SqlUpdateStrings; } + Update( id, fields, propsToUpdate, tableUpdateNeeded, oldVersion, obj, updateStrings, session ); } *************** *** 1485,1494 **** if ( type.IsAssociationType && ( (IAssociationType) type ).UsePrimaryKeyAsForeignKey ) { ! tableNumberByPropertyPath.Add( path, 0 ); } else { string propertyName = StringHelper.Root( path ); ! tableNumberByPropertyPath.Add( path, GetPropertyTableNumber( propertyName ) ); } } --- 1427,1436 ---- if ( type.IsAssociationType && ( (IAssociationType) type ).UsePrimaryKeyAsForeignKey ) { ! tableNumberByPropertyPath[ path ] = 0 ; } else { string propertyName = StringHelper.Root( path ); ! tableNumberByPropertyPath[ path ] = GetPropertyTableNumber( propertyName ); } } *************** *** 1521,1525 **** subclassTableNameClosure[ i ], Alias( name, i ), ! StringHelper.Prefix( IdentifierColumnNames, name + StringHelper.Dot ), subclassTableKeyColumns[ i ], innerJoin && isClassOrSuperclassTable[ i ] ? JoinType.InnerJoin : JoinType.LeftOuterJoin ); --- 1463,1467 ---- subclassTableNameClosure[ i ], Alias( name, i ), ! StringHelper.Qualify( name, IdentifierColumnNames ), subclassTableKeyColumns[ i ], innerJoin && isClassOrSuperclassTable[ i ] ? JoinType.InnerJoin : JoinType.LeftOuterJoin ); *************** *** 1546,1550 **** } ! throw new AssertionFailure( "table [" + tableName + "] not found" ); } --- 1488,1492 ---- } ! throw new AssertionFailure( string.Format( "table [{0}] not found", tableName ) ); } *************** *** 1597,1611 **** public override SqlString PropertySelectFragment( string alias, string suffix ) { - string[ ] cols = subclassColumnClosure; SelectFragment frag = new SelectFragment( factory.Dialect ) ! .SetSuffix( suffix ); ! for( int i = 0; i < cols.Length; i++ ) { ! frag.AddColumn( ! Alias( alias, subclassColumnTableNumberClosure[ i ] ), ! cols[ i ], ! subclassColumnClosureAliases[ i ] ! ); } --- 1539,1556 ---- public override SqlString PropertySelectFragment( string alias, string suffix ) { SelectFragment frag = new SelectFragment( factory.Dialect ) ! .SetSuffix( suffix ) ! .SetUsedAliases( IdentifierAliases ); ! for( int i = 0; i < subclassColumnClosure.Length; i++ ) { ! string subalias = Alias( alias, subclassColumnTableNumberClosure[ i ] ); ! frag.AddColumn( subalias, subclassColumnClosure[ i ], subclassColumnClosureAliases[ i ] ); ! } ! ! for( int i = 0; i < subclassFormulaTemplateClosure.Length; i++ ) ! { ! string subalias = Alias( alias, subclassFormulaTableNumberClosure[ i ] ); ! frag.AddColumn( subalias, subclassFormulaTemplateClosure[ i ], subclassFormulaAliasClosure[ i ] ); } *************** *** 1614,1621 **** SqlStringBuilder builder = new SqlStringBuilder( 3 ); ! builder.Add( ", " ); builder.Add( DiscriminatorFragment( alias ) ! .SetReturnColumnName( DiscriminatorColumnName, suffix ) .ToSqlStringFragment() ); --- 1559,1566 ---- SqlStringBuilder builder = new SqlStringBuilder( 3 ); ! builder.Add( StringHelper.CommaSpace ); builder.Add( DiscriminatorFragment( alias ) ! .SetReturnColumnName( DiscriminatorAlias, suffix ) .ToSqlStringFragment() ); *************** *** 1624,1628 **** return builder.ToSqlString(); - } else --- 1569,1572 ---- *************** *** 1654,1658 **** return name; } ! return Dialect.QuoteForAliasName( Dialect.UnQuote( name ) + StringHelper.Underscore + tableNumber ); } --- 1598,1602 ---- return name; } ! return Dialect.QuoteForAliasName( Dialect.UnQuote( name ) + StringHelper.Underscore + tableNumber + StringHelper.Underscore ); } *************** *** 1691,1702 **** { SqlString result = WhereJoinFragment( alias, innerJoin, includeSubclasses ); ! if( HasWhere ) { ! result = result.Append( " and " + GetSQLWhereString( alias ) ); } return result; - } --- 1635,1645 ---- { SqlString result = WhereJoinFragment( alias, innerJoin, includeSubclasses ); ! string rootAlias = Alias( alias, naturalOrderTableNames.Length - 1 ); // urgh, ugly!! if( HasWhere ) { ! result = result.Append( " and " + GetSQLWhereString( rootAlias ) ); } return result; } *************** *** 1714,1721 **** --- 1657,1676 ---- /// <summary></summary> + public override bool IsCacheInvalidationRequired + { + get { return hasFormulaProperties || ( !IsVersioned && UseDynamicUpdate ); } + } + + /// <summary></summary> protected override string VersionedTableName { get { return qualifiedTableName; } } + + /// <summary></summary> + protected override SqlString VersionSelectString + { + get { return sqlVersionSelectString; } + } } } \ No newline at end of file Index: IClassPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/IClassPersister.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IClassPersister.cs 6 Mar 2005 12:44:45 -0000 1.10 --- IClassPersister.cs 14 Mar 2005 18:53:15 -0000 1.11 *************** *** 153,156 **** --- 153,166 ---- /// <summary> + /// Compare the state of an instance to the current database state + /// </summary> + /// <param name="old"></param> + /// <param name="current"></param> + /// <param name="owner"></param> + /// <param name="session"></param> + /// <returns>return <c>null</c> or the indicies of the modified properties</returns> + int[ ] FindModified( object[ ] old, object[ ] current, object owner, ISessionImplementor session ); + + /// <summary> /// Does the class have a property holding the identifier value? /// </summary> *************** *** 270,277 **** /// <param name="fields"></param> /// <param name="dirtyFields"></param> /// <param name="oldVersion"></param> /// <param name="obj"></param> /// <param name="session"></param> ! void Update( object id, object[ ] fields, int[ ] dirtyFields, object oldVersion, object obj, ISessionImplementor session ); /// <summary> --- 280,288 ---- /// <param name="fields"></param> /// <param name="dirtyFields"></param> + /// <param name="oldFields"></param> /// <param name="oldVersion"></param> /// <param name="obj"></param> /// <param name="session"></param> ! void Update( object id, object[ ] fields, int[ ] dirtyFields, object[ ] oldFields, object oldVersion, object obj, ISessionImplementor session ); /// <summary> *************** *** 326,329 **** --- 337,345 ---- /// <summary> + /// Should we always invalidate the cache instead of recaching updated state + /// </summary> + bool IsCacheInvalidationRequired { get; } + + /// <summary> /// Does this class have a cache? /// </summary> *************** *** 345,355 **** bool IsBatchLoadable { get; } - /* TODO : 2.1 features - not sure if we need for SQL loading - - /// <summary> - /// Get the proxy interface that instances of <em>this</em> concrete class will be cast to (optional operation). - /// </summary> - object ConcreteProxyClass { get; } - /// <summary> /// Get the current database state of the object, in a "hydrated" form, without resolving identifiers --- 361,364 ---- *************** *** 370,374 **** /// <returns></returns> object CurrentVersion( object id, ISessionImplementor session ); - */ } } \ No newline at end of file --- 379,382 ---- Index: EntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/EntityPersister.cs,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** EntityPersister.cs 1 Mar 2005 16:24:49 -0000 1.36 --- EntityPersister.cs 14 Mar 2005 18:53:15 -0000 1.37 *************** *** 75,81 **** private static readonly object NotNullDiscriminator = new object(); - // private readonly string[ ] StringArray = {}; - // private readonly IType[ ] TypeArray = {}; - private static readonly ILog log = LogManager.GetLogger( typeof( EntityPersister ) ); --- 75,78 ---- *************** *** 124,127 **** --- 121,125 ---- discriminatorValue = null; discriminatorSQLString = "null"; + discriminatorInsertable = false; } else *************** *** 130,133 **** --- 128,132 ---- discriminatorSQLString = discriminatorType.ObjectToSQLString( discriminatorValue ); } + discriminatorSQLValue = discriminatorSQLString; } // TODO: add a ClassCastException here to catch illegal disc types *************** *** 142,146 **** distinctColumns.Add( discriminatorColumnName ); - } else --- 141,144 ---- *************** *** 148,151 **** --- 146,150 ---- forceDiscriminator = false; discriminatorColumnName = null; + discriminatorInsertable = false; discriminatorValue = null; discriminatorType = null; *************** *** 207,211 **** } ! if( discriminatorInsertable) { distinctColumns.Add( discriminatorColumnName ); --- 206,210 ---- } ! if( discriminatorInsertable ) { distinctColumns.Add( discriminatorColumnName ); *************** *** 218,221 **** --- 217,221 ---- discriminatorInsertable = false; discriminatorColumnName = null; + discriminatorAlias = null; discriminatorValue = null; discriminatorType = null; *************** *** 384,387 **** --- 384,392 ---- } } + + // This is in PostInstatiate as it needs identifier info + //InitLockers(); + + InitSubclassPropertyAliasesMap( model ); } *************** *** 635,640 **** protected virtual SqlString GenerateInsertString( bool identityInsert, bool[ ] includeProperty ) { ! SqlInsertBuilder builder = new SqlInsertBuilder( factory ); ! builder.SetTableName( TableName ); for( int i = 0; i < HydrateSpan; i++ ) --- 640,645 ---- protected virtual SqlString GenerateInsertString( bool identityInsert, bool[ ] includeProperty ) { ! SqlInsertBuilder builder = new SqlInsertBuilder( factory ) ! .SetTableName( TableName ); for( int i = 0; i < HydrateSpan; i++ ) *************** *** 703,711 **** if( HasSubclasses ) { ! // TODO: Investigate why this breaks NewSessionLifecycle test ! // NB Seems to actually be a cascaded failure to delete a transient object which has a null key ! // then trying to rollback the existing transaction - which fails badly. ! //builder.AddColumn( DiscriminatorColumnName, DiscriminatorAlias ); ! builder.AddColumn( DiscriminatorColumnName ); } --- 708,712 ---- if( HasSubclasses ) { ! builder.AddColumn( DiscriminatorColumnName, DiscriminatorAlias ); } *************** *** 1220,1250 **** /// <param name="fields"></param> /// <param name="dirtyFields"></param> /// <param name="oldVersion"></param> /// <param name="obj"></param> /// <param name="session"></param> ! public override void Update( object id, object[ ] fields, int[ ] dirtyFields, object oldVersion, object obj, ISessionImplementor session ) { if( UseDynamicUpdate && dirtyFields != null ) { ! bool[ ] propsToUpdate = new bool[ HydrateSpan ]; ! for( int i = 0; i < HydrateSpan; i++ ) ! { ! bool dirty = false; ! for( int j = 0; j < dirtyFields.Length; j++ ) ! { ! if( dirtyFields[ j ] == i ) ! { ! dirty = true; ! } ! } ! propsToUpdate[ i ] = dirty || VersionProperty == i; ! //don't need to check property mutability (dirty checking algorithm handles that) ! } ! Update( id, fields, propsToUpdate, oldVersion, obj, GenerateUpdateString( propsToUpdate ), session ); } else { ! Update( id, fields, PropertyUpdateability, oldVersion, obj, SqlUpdateString, session ); } } --- 1221,1244 ---- /// <param name="fields"></param> /// <param name="dirtyFields"></param> + /// <param name="oldFields"></param> /// <param name="oldVersion"></param> /// <param name="obj"></param> /// <param name="session"></param> ! public override void Update( object id, object[ ] fields, int[ ] dirtyFields, object[ ] oldFields, object oldVersion, object obj, ISessionImplementor session ) { + bool[] propsToUpdate; + SqlString updateString; + if( UseDynamicUpdate && dirtyFields != null ) { ! propsToUpdate = GetPropertiesToUpdate( dirtyFields ); ! updateString = GenerateUpdateString( propsToUpdate, oldFields ); } else { ! propsToUpdate = PropertyUpdateability; ! updateString = SqlUpdateString; } + Update( id, fields, propsToUpdate, oldVersion, obj, updateString, session ); } *************** *** 1428,1437 **** public override SqlString PropertySelectFragment( string alias, string suffix ) { ! SelectFragment frag = new SelectFragment( factory.Dialect ); ! ! frag.SetSuffix( suffix ); if( HasSubclasses ) { ! frag.AddColumn( alias, DiscriminatorColumnName ); } --- 1422,1431 ---- public override SqlString PropertySelectFragment( string alias, string suffix ) { ! SelectFragment frag = new SelectFragment( factory.Dialect ) ! .SetSuffix( suffix ) ! .SetUsedAliases( IdentifierAliases ); if( HasSubclasses ) { ! frag.AddColumn( alias, DiscriminatorColumnName, DiscriminatorAlias ); } *************** *** 1472,1479 **** --- 1466,1485 ---- /// <summary></summary> + public override bool IsCacheInvalidationRequired + { + get { return hasFormulaProperties || ( !IsVersioned && UseDynamicUpdate ); } + } + + /// <summary></summary> protected override string VersionedTableName { get { return qualifiedTableName; } } + + /// <summary></summary> + protected override SqlString VersionSelectString + { + get { return sqlVersionSelectString; } + } } } \ No newline at end of file Index: ILoadable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/ILoadable.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ILoadable.cs 1 Mar 2005 16:24:50 -0000 1.9 --- ILoadable.cs 14 Mar 2005 18:53:15 -0000 1.10 *************** *** 49,178 **** /// <returns></returns> string GetDiscriminatorAlias( string suffix ); - - // 2.03 features required currently by loader - - /// <summary> - /// How many properties are there, for this class and all subclasses? (optional operation) - /// </summary> - /// <returns></returns> - int CountSubclassProperties(); - - /// <summary> - /// The name of the column used as a discriminator - /// </summary> - string DiscriminatorColumnName { get; } - - /// <summary> - /// May this property be fetched using an SQL outerjoin? - /// </summary> - /// <param name="i"></param> - /// <returns></returns> - OuterJoinFetchStrategy EnableJoinedFetch( int i ); - - /// <summary> - /// Get the from clause part of any joins (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="innerJoin"></param> - /// <param name="includeSubclasses"></param> - /// <returns></returns> - SqlString FromJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); - - /// <summary> - /// Get the column names for the numbered property of <c>this</c> class - /// </summary> - /// <param name="i"></param> - /// <returns></returns> - string[ ] GetPropertyColumnNames( int i ); - - /// <summary> - /// The names of columns used to persist the identifier - /// </summary> - string[ ] IdentifierColumnNames { get; } - - /// <summary> - /// Is this property defined on a subclass of the mapped class? - /// </summary> - /// <param name="i"></param> - /// <returns></returns> - bool IsDefinedOnSubclass( int i ); - - /// <summary> - /// Get an array of the types of all properties of all subclasses (optional operation) - /// </summary> - /// <param name="i"></param> - /// <returns></returns> - IType GetSubclassPropertyType( int i ); - - /// <summary> - /// Get the name of the numbered property of the class or a subclass - /// (optional operation) - /// </summary> - /// <param name="i"></param> - /// <returns></returns> - string GetSubclassPropertyName( int i ); - - /// <summary> - /// Return the column names used to persist all properties of all sublasses of the persistent class - /// (optional operation) - /// </summary> - string[ ] GetSubclassPropertyColumnNames( int i ); - - /// <summary> - /// Return the table name used to persist the numbered property of - /// the class or a subclass - /// (optional operation) - /// </summary> - string GetSubclassPropertyTableName( int i ); - - /// <summary> - /// Given the number of a property of a subclass, and a table alias, return the aliased column names - /// (optional operation) - /// </summary> - /// <param name="name"></param> - /// <param name="i"></param> - /// <returns></returns> - string[ ] ToColumns( string name, int i ); - - /// <summary> - /// Given a query alias and an identifying suffix, render the identifier select fragment - /// </summary> - /// <param name="name"></param> - /// <param name="suffix"></param> - /// <returns></returns> - SqlString IdentifierSelectFragment( string name, string suffix ); - - /// <summary> - /// Given a query alias and an identifying suffix, render the property select fragment - /// (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="suffix"></param> - /// <returns></returns> - SqlString PropertySelectFragment( string alias, string suffix ); - - /// <summary> - /// Get the main from table fragment, given a query alias (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <returns></returns> - SqlString FromTableFragment( string alias ); - - /// <summary> - /// Get the where clause part of any joins (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="innerJoin"></param> - /// <param name="includeSubclasses"></param> - /// <returns></returns> - SqlString WhereJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); - - /* - /// These are in 2.03, but we can use IJoinables now - /// <summary> - /// The fully-qualified tablename used to persist this class - /// </summary> - string TableName { get; } - */ } } \ No newline at end of file --- 49,52 ---- Index: PersisterFactory.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/PersisterFactory.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PersisterFactory.cs 1 Mar 2005 16:24:50 -0000 1.3 --- PersisterFactory.cs 14 Mar 2005 18:53:15 -0000 1.4 *************** *** 92,98 **** public static ICollectionPersister CreateCollectionPersister( Configuration cfg, Mapping.Collection model, ISessionFactoryImplementor factory ) { return new CollectionPersister( model, cfg, factory ); - /* System.Type persisterClass = model.CollectionPersisterClass; if ( persisterClass == null ) --- 92,99 ---- public static ICollectionPersister CreateCollectionPersister( Configuration cfg, Mapping.Collection model, ISessionFactoryImplementor factory ) { + /* return new CollectionPersister( model, cfg, factory ); + */ System.Type persisterClass = model.CollectionPersisterClass; if ( persisterClass == null ) *************** *** 107,111 **** return Create( persisterClass, cfg, model, factory ); } - */ } --- 108,111 ---- Index: IOuterJoinLoadable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/IOuterJoinLoadable.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IOuterJoinLoadable.cs 1 Mar 2005 16:24:50 -0000 1.1 --- IOuterJoinLoadable.cs 14 Mar 2005 18:53:15 -0000 1.2 *************** *** 11,15 **** /// of a one-to-many association. /// </summary> ! public interface IOuterJoinLoadable { /// <summary> --- 11,15 ---- /// of a one-to-many association. /// </summary> ! public interface IOuterJoinLoadable : ILoadable, IJoinable { /// <summary> *************** *** 23,28 **** string DiscriminatorColumnName { get; } - //USED BY OuterJoinLoader + subclasses - /// <summary> /// How many properties are there, for this class and all subclasses? (optional operation) --- 23,26 ---- *************** *** 83,103 **** /// <summary> - /// Given a query alias and an identifying suffix, render the identifier select fragment - /// </summary> - /// <param name="name"></param> - /// <param name="suffix"></param> - /// <returns></returns> - SqlString IdentifierSelectFragment( string name, string suffix ); - - /// <summary> - /// Given a query alias and an identifying suffix, render the property select fragment - /// (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="suffix"></param> - /// <returns></returns> - SqlString PropertySelectFragment( string alias, string suffix ); - - /// <summary> /// Get the main from table fragment, given a query alias (optional operation) /// </summary> --- 81,84 ---- *************** *** 113,134 **** /// <returns></returns> SqlString SelectFragment( string alias, string suffix ); - - /// <summary> - /// Get the where clause part of any joins (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="innerJoin"></param> - /// <param name="includeSubclasses"></param> - /// <returns></returns> - SqlString WhereJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); - - /// <summary> - /// Get the from clause part of any joins (optional operation) - /// </summary> - /// <param name="alias"></param> - /// <param name="innerJoin"></param> - /// <param name="includeSubclasses"></param> - /// <returns></returns> - SqlString FromJoinFragment( string alias, bool innerJoin, bool includeSubclasses ); } } --- 94,97 ---- Index: IQueryable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/IQueryable.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IQueryable.cs 1 Mar 2005 16:24:50 -0000 1.10 --- IQueryable.cs 14 Mar 2005 18:53:15 -0000 1.11 *************** *** 39,51 **** SqlString QueryWhereFragment( string alias, bool innerJoin, bool includeSublcasses ); - /* /// <summary> ! /// Given a query alias and a property path, return the qualified column name /// </summary> /// <param name="alias"></param> ! /// <param name="property"></param> /// <returns></returns> ! string[ ] ToColumns( string alias, string property ); ! */ } } \ No newline at end of file --- 39,62 ---- SqlString QueryWhereFragment( string alias, bool innerJoin, bool includeSublcasses ); /// <summary> ! /// Given a query alias and an identifying suffix, render the intentifier select fragment. ! /// </summary> ! /// <param name="name"></param> ! /// <param name="suffix"></param> ! /// <returns></returns> ! SqlString IdentifierSelectFragment( string name, string suffix ); ! ! /// <summary> ! /// Given a query alias and an identifying suffix, render the property select fragment. /// </summary> /// <param name="alias"></param> ! /// <param name="suffix"></param> /// <returns></returns> ! SqlString PropertySelectFragment( string alias, string suffix ); ! ! /// <summary> ! /// Get the names of columns used to persist the identifier ! /// </summary> ! string[] IdentifierColumnNames { get; } } } \ No newline at end of file Index: AbstractEntityPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Persister/AbstractEntityPersister.cs,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** AbstractEntityPersister.cs 6 Mar 2005 12:44:45 -0000 1.34 --- AbstractEntityPersister.cs 14 Mar 2005 18:53:15 -0000 1.35 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Collections; + using System.Data; using System.Reflection; using Iesi.Collections; *************** *** 8,11 **** --- 9,13 ---- using NHibernate.Hql; using NHibernate.Id; + using NHibernate.Impl; using NHibernate.Loader; using NHibernate.Mapping; *************** *** 26,30 **** /// May be considred an immutable view of the mapping object /// </remarks> ! public abstract class AbstractEntityPersister : AbstractPropertyMapping, IQueryable, IClassMetadata { private static readonly ILog log = LogManager.GetLogger( typeof( AbstractEntityPersister ) ); --- 28,32 ---- /// May be considred an immutable view of the mapping object /// </remarks> ! public abstract class AbstractEntityPersister : AbstractPropertyMapping, IOuterJoinLoadable, IQueryable, IClassMetadata, IUniqueKeyLoadable, ISqlLoadable { private static readonly ILog log = LogManager.GetLogger( typeof( AbstractEntityPersister ) ); *************** *** 50,54 **** private readonly bool hasCascades; private readonly bool mutable; ! //private readonly bool selectBeforeUpdate; private readonly System.Type superclass; private readonly bool dynamicUpdate; --- 52,56 ---- private readonly bool hasCascades; private readonly bool mutable; ! private readonly bool selectBeforeUpdate; private readonly System.Type superclass; private readonly bool dynamicUpdate; *************** *** 59,63 **** private readonly IType entityType; private readonly ConstructorInfo constructor; ! //private readonly string rootClassName; // The optional SQL string defined in the where attribute --- 61,65 ---- private readonly IType entityType; private readonly ConstructorInfo constructor; ! private readonly string rootClassName; // The optional SQL string defined in the where attribute *************** *** 93,97 **** private readonly int versionProperty; //private Cascades.VersionValue unsavedVersionValues; ! private readonly bool jdbcBatchVersionData; // other properties (for this concrete class only, not the subclass closure) --- 95,99 ---- private readonly int versionProperty; //private Cascades.VersionValue unsavedVersionValues; ! //private readonly bool batchVersionData; // other properties (for this concrete class only, not the subclass closure) *************** *** 220,224 **** return new SelectFragment( Dialect ) .SetSuffix( suffix ) ! .AddColumns( name, IdentifierColumnNames ) .ToSqlStringFragment( false ); } --- 222,226 ---- return new SelectFragment( Dialect ) .SetSuffix( suffix ) ! .AddColumns( name, IdentifierColumnNames, IdentifierAliases ) .ToSqlStringFragment( false ); } *************** *** 227,230 **** --- 229,238 ---- /// /// </summary> + /// <returns></returns> + protected abstract SqlString VersionSelectString { get; } + + /// <summary> + /// + /// </summary> /// <param name="path"></param> /// <returns></returns> *************** *** 324,328 **** for( int i = 0; i < props.Length; i++ ) { ! log.Debug( className + StringHelper.Dot + propertyNames[ props[ i ] ] + " is dirty" ); } } --- 332,364 ---- for( int i = 0; i < props.Length; i++ ) { ! log.Debug( StringHelper.Qualify( className, propertyNames[ props[ i ] ] ) + " is dirty" ); ! } ! } ! return props; ! } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="old"></param> ! /// <param name="current"></param> ! /// <param name="obj"></param> ! /// <param name="session"></param> ! /// <returns></returns> ! public virtual int[ ] FindModified( object[ ] old, object[ ] current, object obj, ISessionImplementor session ) ! { ! int[ ] props = TypeFactory.FindModified( propertyTypes, old, current, propertyUpdateability, session ); ! if( props == null ) ! { ! return null; ! } ! else ! { ! if( log.IsDebugEnabled ) ! { ! for( int i = 0; i < props.Length; i++ ) ! { ! log.Debug( StringHelper.Qualify( className, propertyNames[ props[ i ] ] ) + " is dirty" ); } } *************** *** 658,668 **** // CLASS - className = model.MappedClass.FullName; ! //rootClassName = model.RootClass.FullName; mappedClass = model.MappedClass; mutable = model.IsMutable; ! //selectBeforeUpdate = model.HasSelectBeforeUpdate; dynamicUpdate = model.DynamicUpdate; dynamicInsert = model.DynamicInsert; --- 694,703 ---- // CLASS className = model.MappedClass.FullName; ! rootClassName = model.RootClazz.Name; mappedClass = model.MappedClass; mutable = model.IsMutable; ! selectBeforeUpdate = model.SelectBeforeUpdate; dynamicUpdate = model.DynamicUpdate; dynamicInsert = model.DynamicInsert; *************** *** 685,691 **** entityType = NHibernateUtil.Entity( mappedClass ); /* optimisticLockMode = model.OptimisticLockMode; ! if ( optmisticLockMode > Versiong.OptimisticLockVersion && !dynamicUpdate ) { throw new MappingException( string.Format( "optimistic-lock setting requires dynamic-update=\'true\': {0}", className ) ); --- 720,727 ---- entityType = NHibernateUtil.Entity( mappedClass ); + // TODO : 2.1 Implement OptimisiticLockVersion /* optimisticLockMode = model.OptimisticLockMode; ! if ( optimisticLockMode > Version.OptimisticLockVersion && !dynamicUpdate ) { throw new MappingException( string.Format( "optimistic-lock setting requires dynamic-update=\'true\': {0}", className ) ); *************** *** 701,705 **** // IDENTIFIER - hasEmbeddedIdentifier = model.HasEmbeddedIdentifier; IValue idValue = model.Identifier; --- 737,740 ---- *************** *** 750,758 **** // HYDRATE SPAN - hydrateSpan = model.PropertyClosureCollection.Count; // IDENTIFIER - int idColumnSpan = model.Identifier.ColumnSpan; identifierColumnNames = new string[ idColumnSpan ]; --- 785,791 ---- *************** *** 773,777 **** // UNSAVED-VALUE: - string unsavedValue = model.Identifier.NullValue; if( unsavedValue == null || "null".Equals( unsavedValue ) ) --- 806,809 ---- *************** *** 818,822 **** } ! // TODO: Bring versioning up to 2.1 standards if( model.IsVersioned ) { --- 850,854 ---- } ! // TODO: 2.1 Bring versioning up to standards if( model.IsVersioned ) { *************** *** 957,963 **** public string[] GetIdentifierAliases( string suffix ) { ! // NOTE: this assumes something about how propertySelectFragment is implemented by the subclass! // was toUnqotedAliasStrings( getIdentiferColumnNames() ) before - now tried ! // to remove that unqoting and missing aliases.. return new Alias(suffix).ToAliasStrings( IdentifierAliases, dialect ); } --- 989,995 ---- public string[] GetIdentifierAliases( string suffix ) { ! // NOTE: this assumes something about how PropertySelectFragment is implemented by the subclass! // was toUnqotedAliasStrings( getIdentiferColumnNames() ) before - now tried ! // to remove that unquoting and missing aliases.. return new Alias(suffix).ToAliasStrings( IdentifierAliases, dialect ); } *************** *** 971,975 **** public string[] GetPropertyAliases( string suffix, int i ) { ! // NOTE: this assumes something about how propertySelectFragment is implemented by the subclass! return new Alias(suffix).ToUnquotedAliasStrings( GetPropertyColumnNames( i ), dialect ); } --- 1003,1007 ---- public string[] GetPropertyAliases( string suffix, int i ) { ! // NOTE: this assumes something about how pPropertySelectFragment is implemented by the subclass! return new Alias(suffix).ToUnquotedAliasStrings( GetPropertyColumnNames( i ), dialect ); } *************** *** 982,988 **** public string GetDiscriminatorAlias( string suffix ) { ! // NOTE: this assumes something about how propertySelectFragment is implemented by the subclass! // was toUnqotedAliasStrings( getdiscriminatorColumnName() ) before - now tried ! // to remove that unqoting and missing aliases.. return hasSubclasses ? new Alias(suffix).ToAliasString( DiscriminatorAlias, dialect ) : --- 1014,1020 ---- public string GetDiscriminatorAlias( string suffix ) { ! // NOTE: this assumes something about how PropertySelectFragment is implemented by the subclass! // was toUnqotedAliasStrings( getdiscriminatorColumnName() ) before - now tried ! // to remove that unquoting and missing aliases.. return hasSubclasses ? new Alias(suffix).ToAliasString( DiscriminatorAlias, dialect ) : *************** *** 1002,1007 **** if ( HasIdentifierProperty ) { ! subclassPropertyAliases.Add( IdentifierPropertyName, identifierAliases ); ! subclassPropertyAliases.Add( PathExpressionParser.EntityID, identifierAliases ) ; } --- 1034,1039 ---- if ( HasIdentifierProperty ) ... [truncated message content] |
From: Paul H. <pha...@us...> - 2005-03-14 18:53:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6901/nhibernate/src/NHibernate/SqlCommand Modified Files: ForUpdateFragment.cs SelectFragment.cs SqlDeleteBuilder.cs SqlSelectBuilder.cs SqlUpdateBuilder.cs Log Message: Refactored as per 2.1 Index: SqlDeleteBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlDeleteBuilder.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SqlDeleteBuilder.cs 23 Jan 2005 15:48:00 -0000 1.6 --- SqlDeleteBuilder.cs 14 Mar 2005 18:53:13 -0000 1.7 *************** *** 91,95 **** public SqlDeleteBuilder AddWhereFragment( string whereSql ) { ! whereStrings.Add( new SqlString( whereSql ) ); return this; } --- 91,98 ---- public SqlDeleteBuilder AddWhereFragment( string whereSql ) { ! if ( whereSql != null && whereSql.Length > 0 ) ! { ! whereStrings.Add( new SqlString( whereSql ) ); ! } return this; } Index: SqlUpdateBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlUpdateBuilder.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SqlUpdateBuilder.cs 23 Jan 2005 15:48:00 -0000 1.6 --- SqlUpdateBuilder.cs 14 Mar 2005 18:53:13 -0000 1.7 *************** *** 159,163 **** public SqlUpdateBuilder AddWhereFragment( string whereSql ) { ! whereStrings.Add( new SqlString( whereSql ) ); return this; } --- 159,167 ---- public SqlUpdateBuilder AddWhereFragment( string whereSql ) { ! // Don't add empty condition's - we get extra ANDs ! if ( whereSql != null && whereSql.Length > 0 ) ! { ! whereStrings.Add( new SqlString( whereSql ) ); ! } return this; } Index: SqlSelectBuilder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SqlSelectBuilder.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SqlSelectBuilder.cs 31 Dec 2004 22:25:44 -0000 1.7 --- SqlSelectBuilder.cs 14 Mar 2005 18:53:13 -0000 1.8 *************** *** 170,174 **** public SqlSelectBuilder AddWhereClause( SqlString whereSqlString ) { ! whereSqlStrings.Add( whereSqlString ); return this; } --- 170,178 ---- public SqlSelectBuilder AddWhereClause( SqlString whereSqlString ) { ! // Don't add empty condition's - we get extra ANDs ! if ( whereSqlString.ToString() != string.Empty ) ! { ! whereSqlStrings.Add( whereSqlString ); ! } return this; } Index: ForUpdateFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/ForUpdateFragment.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ForUpdateFragment.cs 31 Dec 2004 22:24:48 -0000 1.6 --- ForUpdateFragment.cs 14 Mar 2005 18:53:13 -0000 1.7 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Text; + using NHibernate.Dialect; using NHibernate.Util; *************** *** 41,49 **** /// <summary></summary> ! public SqlString ToSqlStringFragment() { ! return aliases.Length == 0 ? ! new SqlString( String.Empty ) : ! new SqlString( " for update of " + aliases + ( nowait ? " nowait" : String.Empty ) ); } --- 42,62 ---- /// <summary></summary> ! public SqlString ToSqlStringFragment( Dialect.Dialect dialect ) { ! if ( aliases.Length == 0 ) ! { ! return new SqlString( String.Empty ); ! } ! bool nowait = NoWait && dialect.SupportsForUpdateNoWait; ! if ( dialect.SupportsForUpdateOf ) ! { ! return new SqlString( " for update of " + aliases + ( nowait ? " nowait" : String.Empty ) ); ! } ! else if ( dialect.SupportsForUpdate ) ! { ! return new SqlString( " for update" + ( nowait ? " nowait" : String.Empty ) ); ! } ! else ! return new SqlString( String.Empty ); } Index: SelectFragment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/SelectFragment.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SelectFragment.cs 14 Feb 2005 03:26:10 -0000 1.8 --- SelectFragment.cs 14 Mar 2005 18:53:13 -0000 1.9 *************** *** 1,4 **** --- 1,5 ---- using System.Collections; using System.Text; + using Iesi.Collections; using NHibernate.Util; *************** *** 14,17 **** --- 15,19 ---- private IList columnAliases = new ArrayList(); private Dialect.Dialect dialect; + private string[] usedAliases; /// <summary> *************** *** 27,30 **** --- 29,41 ---- /// /// </summary> + public SelectFragment SetUsedAliases( string[] usedAliases ) + { + this.usedAliases = usedAliases; + return this; + } + + /// <summary> + /// + /// </summary> /// <param name="suffix"></param> /// <returns></returns> *************** *** 173,189 **** { StringBuilder buf = new StringBuilder( columns.Count*10 ); for( int i = 0; i < columns.Count; i++ ) { string col = columns[ i ] as string; ! if( i > 0 || includeLeadingComma ) { ! buf.Append( StringHelper.CommaSpace ); ! } ! string columnAlias = columnAliases[ i ] as string; ! buf.Append( col ) ! .Append( " as " ) ! .Append( new Alias( suffix ).ToAliasString( columnAlias, dialect ) ); } return new SqlString( buf.ToString() ); --- 184,214 ---- { StringBuilder buf = new StringBuilder( columns.Count*10 ); + HashedSet columnsUnique = new HashedSet(); + + if ( usedAliases != null ) + { + columnsUnique.AddAll( usedAliases ); + } + bool found = false; for( int i = 0; i < columns.Count; i++ ) { string col = columns[ i ] as string; ! string columnAlias = columnAliases[ i ] as string; ! ! if ( columnsUnique.Add( columnAlias ) ) { ! if( found || includeLeadingComma ) ! { ! buf.Append( StringHelper.CommaSpace ); ! } ! buf.Append( col ) ! .Append( " as " ) ! .Append( new Alias( suffix ).ToAliasString( columnAlias, dialect ) ); ! ! // Set the flag for the next time ! found = true; ! } } return new SqlString( buf.ToString() ); |
From: Paul H. <pha...@us...> - 2005-03-14 18:53:25
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6750/nhibernate/src/NHibernate/Loader Modified Files: AbstractEntityLoader.cs CollectionLoader.cs CriteriaLoader.cs EntityLoader.cs ICollectionInitializer.cs Loader.cs OneToManyLoader.cs OuterJoinLoader.cs SimpleEntityLoader.cs SqlLoader.cs Log Message: Refactored as per 2.1 Index: ICollectionInitializer.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/ICollectionInitializer.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ICollectionInitializer.cs 6 Mar 2005 12:44:43 -0000 1.4 --- ICollectionInitializer.cs 14 Mar 2005 18:53:03 -0000 1.5 *************** *** 13,25 **** /// </summary> /// <param name="id"></param> - /// <param name="collection"></param> - /// <param name="owner"></param> - /// <param name="session"></param> - void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ); - - /// <summary> - /// - /// </summary> - /// <param name="id"></param> /// <param name="session"></param> void Initialize( object id, ISessionImplementor session); --- 13,16 ---- Index: EntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/EntityLoader.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** EntityLoader.cs 1 Mar 2005 16:24:48 -0000 1.9 --- EntityLoader.cs 14 Mar 2005 18:53:03 -0000 1.10 *************** *** 9,25 **** { /// <summary> ! /// Load an entity using outerjoin fetching to fetch associated entities /// </summary> public class EntityLoader : AbstractEntityLoader, IUniqueEntityLoader { ! private IType[ ] idType; /// <summary> /// ! /// </summary> /// <param name="persister"></param> /// <param name="batchSize"></param> /// <param name="factory"></param> ! public EntityLoader( ILoadable persister, int batchSize, ISessionFactoryImplementor factory ) : this( persister, persister.IdentifierColumnNames, persister.IdentifierType, batchSize, factory ) { } --- 9,30 ---- { /// <summary> ! /// Load an entity using outerjoin fetching to fetch associated entities. /// </summary> + /// <remarks> + /// The <tt>ClassPersister</tt> must implement <tt>Loadable</tt>. For other entities, + /// create a customized subclass of <tt>Loader</tt>. + /// </remarks> public class EntityLoader : AbstractEntityLoader, IUniqueEntityLoader { ! private readonly IType uniqueKeyType; ! private readonly bool batchLoader; /// <summary> /// ! /// </summary>C:\Devel\Sourceforge\NHibernate\nhibernate\src\NHibernate\Loader\EntityLoader.cs /// <param name="persister"></param> /// <param name="batchSize"></param> /// <param name="factory"></param> ! public EntityLoader( IOuterJoinLoadable persister, int batchSize, ISessionFactoryImplementor factory ) : this( persister, persister.IdentifierColumnNames, persister.IdentifierType, batchSize, factory ) { } *************** *** 33,47 **** /// <param name="batchSize"></param> /// <param name="factory"></param> ! public EntityLoader( ILoadable persister, string[] uniqueKey, IType uniqueKeyType, int batchSize, ISessionFactoryImplementor factory ) : base( persister, factory ) { ! idType = new IType[ ] {persister.IdentifierType}; ! ! SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ); ! selectBuilder.SetWhereClause( Alias, persister.IdentifierColumnNames, persister.IdentifierType ); ! RenderStatement( selectBuilder, factory ); ! this.SqlString = selectBuilder.ToSqlString(); PostInstantiate(); } --- 38,53 ---- /// <param name="batchSize"></param> /// <param name="factory"></param> ! public EntityLoader( IOuterJoinLoadable persister, string[] uniqueKey, IType uniqueKeyType, int batchSize, ISessionFactoryImplementor factory ) : base( persister, factory ) { ! this.uniqueKeyType = uniqueKeyType; ! IList associations = WalkTree( persister, Alias, factory ); ! InitClassPersisters( associations ); ! SqlString whereString = WhereString( factory, Alias, uniqueKey, uniqueKeyType, batchSize ); ! RenderStatement( associations, whereString, factory ); PostInstantiate(); + + batchLoader = batchSize > 1; } *************** *** 51,58 **** /// <param name="session"></param> /// <param name="id"></param> /// <returns></returns> ! public object LoadByUniqueKey( ISessionImplementor session, object id ) { ! return Load( session, id, null, null ); } --- 57,65 ---- /// <param name="session"></param> /// <param name="id"></param> + /// <param name="optionalObject"></param> /// <returns></returns> ! public object Load( ISessionImplementor session, object id, object optionalObject ) { ! return Load( session, id, optionalObject, id ); } *************** *** 62,70 **** /// <param name="session"></param> /// <param name="id"></param> - /// <param name="obj"></param> /// <returns></returns> ! public object Load( ISessionImplementor session, object id, object obj ) { ! return Load( session, id, obj, id ); } --- 69,76 ---- /// <param name="session"></param> /// <param name="id"></param> /// <returns></returns> ! public object LoadByUniqueKey( ISessionImplementor session, object id ) { ! return Load( session, id, null, null ); } *************** *** 74,83 **** /// <param name="session"></param> /// <param name="id"></param> ! /// <param name="obj"></param> /// <param name="optionalId"></param> /// <returns></returns> ! public object Load( ISessionImplementor session, object id, object obj, object optionalId ) { ! IList list = LoadEntity( session, new object[ ] {id}, idType, obj, optionalId, false ); if( list.Count == 1 ) { --- 80,89 ---- /// <param name="session"></param> /// <param name="id"></param> ! /// <param name="optionalObject"></param> /// <param name="optionalId"></param> /// <returns></returns> ! public object Load( ISessionImplementor session, object id, object optionalObject, object optionalId ) { ! IList list = LoadEntity( session, id, uniqueKeyType, optionalObject, optionalId ); if( list.Count == 1 ) { *************** *** 116,119 **** --- 122,131 ---- return row[ row.Length - 1 ]; } + + /// <summary></summary> + protected override bool IsSingleRowLoader + { + get { return !batchLoader; } + } } } \ No newline at end of file Index: AbstractEntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/AbstractEntityLoader.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractEntityLoader.cs 6 Mar 2005 12:44:43 -0000 1.15 --- AbstractEntityLoader.cs 14 Mar 2005 18:53:03 -0000 1.16 *************** *** 5,8 **** --- 5,9 ---- using NHibernate.Persister; using NHibernate.SqlCommand; + using NHibernate.Type; using NHibernate.Util; *************** *** 12,16 **** public abstract class AbstractEntityLoader : OuterJoinLoader { ! private ILoadable persister; private ICollectionPersister collectionPersister; private int collectionOwner; --- 13,17 ---- public abstract class AbstractEntityLoader : OuterJoinLoader { ! private readonly IOuterJoinLoadable persister; private ICollectionPersister collectionPersister; private int collectionOwner; *************** *** 23,104 **** /// <param name="persister"></param> /// <param name="factory"></param> ! public AbstractEntityLoader( ILoadable persister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { this.persister = persister; ! alias = ToAlias( persister.ClassName, 0 ); ! } ! ! /// <summary></summary> ! protected string Alias ! { ! get { return alias; } ! } ! ! /// <summary> ! /// Gets the <see cref="ILoadable"/> Persister. ! /// </summary> ! protected ILoadable Persister ! { ! get { return persister; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="selectBuilder"></param> ! /// <param name="factory"></param> ! protected void RenderStatement( SqlSelectBuilder selectBuilder, ISessionFactoryImplementor factory ) ! { ! RenderStatement( selectBuilder, String.Empty, factory ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="selectBuilder"></param> ! /// <param name="orderBy"></param> ! /// <param name="factory"></param> ! protected void RenderStatement( SqlSelectBuilder selectBuilder, string orderBy, ISessionFactoryImplementor factory ) ! { ! IList associations = WalkTree( persister, alias, factory ); ! ! int joins = associations.Count; ! Suffixes = new string[joins + 1]; ! for( int i = 0; i <= joins; i++ ) ! { ! Suffixes[ i ] = ( joins == 0 ) ? String.Empty : i.ToString() + StringHelper.Underscore; ! } ! ! JoinFragment ojf = OuterJoins( associations ); ! ! selectBuilder.SetSelectClause( ! ( joins == 0 ? String.Empty : SelectString( associations ) + "," ) + ! SelectString( persister, alias, Suffixes[ joins ] ) ! ) ! .SetFromClause ! ( ! persister.FromTableFragment( alias ).Append( ! persister.FromJoinFragment( alias, true, true ) ! ) ! ) ! .SetOuterJoins ! ( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString.Append( ! UseQueryWhereFragment ? ! ( ( IQueryable ) persister ).QueryWhereFragment( alias, true, true ) : ! persister.WhereJoinFragment( alias, true, true ) ! ) ! ) ! .SetOrderByClause( orderBy ); ! ! Persisters = new ILoadable[joins + 1]; ! // classPersisters = new ILoadable[joins+1]; ! LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); ! for( int i = 0; i < joins; i++ ) ! { ! Persisters[ i ] = ( ( OuterJoinableAssociation ) associations[ i ] ).Subpersister; ! } ! Persisters[ joins ] = persister; } --- 24,31 ---- /// <param name="persister"></param> /// <param name="factory"></param> ! public AbstractEntityLoader( IOuterJoinLoadable persister, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { this.persister = persister; ! alias = GenerateRootAlias( persister.ClassName ); } *************** *** 106,114 **** /// /// </summary> /// <param name="condition"></param> /// <param name="factory"></param> ! protected void RenderStatement( SqlString condition, ISessionFactoryImplementor factory ) { ! RenderStatement( condition, String.Empty, factory ); } --- 33,42 ---- /// /// </summary> + /// <param name="associations"></param> /// <param name="condition"></param> /// <param name="factory"></param> ! protected void RenderStatement( IList associations, SqlString condition, ISessionFactoryImplementor factory ) { ! InitStatementString( associations, condition, string.Empty, factory ); } *************** *** 116,179 **** /// /// </summary> ! /// <param name="condition"></param> ! /// <param name="orderBy"></param> ! /// <param name="factory"></param> ! protected void RenderStatement( SqlString condition, string orderBy, ISessionFactoryImplementor factory ) { ! SqlSelectBuilder sqlBuilder = new SqlSelectBuilder( factory ); ! ! IList associations = WalkTree( persister, alias, factory ); ! ! int joins = associations.Count; ! Suffixes = new string[joins + 1]; ! for( int i = 0; i <= joins; i++ ) ! { ! Suffixes[ i ] = ( joins == 0 ) ? String.Empty : i.ToString() + StringHelper.Underscore; ! } ! ! JoinFragment ojf = OuterJoins( associations ); ! sqlBuilder.SetSelectClause( ! ( joins == 0 ? String.Empty : SelectString( associations ) + "," ) + ! SelectString( persister, alias, Suffixes[ joins ] ) ! ); ! ! sqlBuilder.SetFromClause( ! persister.FromTableFragment( alias ).Append( ! persister.FromJoinFragment( alias, true, true ) ! ) ! ); ! ! sqlBuilder.AddWhereClause( condition ); ! ! sqlBuilder.SetOuterJoins( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString.Append ! ( ! UseQueryWhereFragment ? ! ( ( IQueryable ) persister ).QueryWhereFragment( alias, true, true ) : ! persister.WhereJoinFragment( alias, true, true ) ) ! ); ! ! sqlBuilder.SetOrderByClause( orderBy ); ! ! this.SqlString = sqlBuilder.ToSqlString(); ! ! Persisters = new ILoadable[joins + 1]; ! LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); ! for( int i = 0; i < joins; i++ ) { ! Persisters[ i ] = ( ( OuterJoinableAssociation ) associations[ i ] ).Subpersister; } - Persisters[ joins ] = persister; } /// <summary> ! /// Should we sue the discriminator, to narrow the select to ! /// instances of the queried subclass? /// </summary> ! /// <value>False, unless overridden</value> ! protected virtual bool UseQueryWhereFragment { ! get { return false; } } --- 44,63 ---- /// /// </summary> ! /// <param name="spaces"></param> ! protected void AddAllToPropertySpaces( object[] spaces ) { ! for ( int i = 0; i < spaces.Length; i++ ) { ! AddToPropertySpaces( spaces[ i ] ); } } /// <summary> ! /// /// </summary> ! /// <param name="space"></param> ! protected virtual void AddToPropertySpaces( object space ) { ! throw new NotSupportedException( "only criteria queries need to autoflush" ); } *************** *** 188,192 **** collectionOwner = -1; // if no collection found classPersisters = new ILoadable[ joins + 1 ]; ! owners = new int[ joins + 1 ]; aliases = new string[ joins + 1 ]; LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); --- 72,76 ---- collectionOwner = -1; // if no collection found classPersisters = new ILoadable[ joins + 1 ]; ! SetOwners( new int[ joins + 1 ] ); aliases = new string[ joins + 1 ]; LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); *************** *** 198,202 **** { classPersisters[ i ] = (ILoadable) subpersister; ! owners[ i ] = ToOwner( oj, joins, oj.IsOneToOne ); aliases[ i ] = oj.Subalias; if ( oj.JoinType == JoinType.InnerJoin ) --- 82,86 ---- { classPersisters[ i ] = (ILoadable) subpersister; ! Owners[ i ] = ToOwner( oj, joins, oj.IsOneToOne ); aliases[ i ] = oj.Subalias; if ( oj.JoinType == JoinType.InnerJoin ) *************** *** 229,238 **** } classPersisters[ joins ] = persister; ! owners[ joins ] = -1; aliases[ joins ] = alias; ! if ( ArrayHelper.IsAllNegative( owners ) ) { ! owners = null; } } --- 113,122 ---- } classPersisters[ joins ] = persister; ! Owners[ joins ] = -1; aliases[ joins ] = alias; ! if ( ArrayHelper.IsAllNegative( Owners ) ) { ! SetOwners( null ); } } *************** *** 241,251 **** /// /// </summary> ! /// <param name="spaces"></param> ! protected void AddAllToPropertySpaces( object[] spaces ) { ! for ( int i = 0; i < spaces.Length; i++ ) ! { ! AddToPropertySpaces( spaces[ i ] ); ! } } --- 125,199 ---- /// /// </summary> ! /// <param name="associations"></param> ! /// <param name="condition"></param> ! /// <param name="orderBy"></param> ! /// <param name="factory"></param> ! protected void InitStatementString( IList associations, SqlString condition, string orderBy, ISessionFactoryImplementor factory ) { ! int joins = CountClassPersisters( associations ); ! ! Suffixes = GenerateSuffixes( joins + 1 ); ! ! JoinFragment ojf = MergeOuterJoins( associations ); ! ! SqlString = new SqlSelectBuilder( factory ) ! .SetSelectClause( ! persister.SelectFragment( alias, Suffixes[ joins ] ) + ! SelectString( associations, factory ) ! ) ! .SetFromClause( ! persister.FromTableFragment( alias ).Append( ! persister.FromJoinFragment( alias, true, true ) ) ! ) ! .AddWhereClause( condition ) ! .SetOuterJoins( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString ! ) ! .AddWhereClause( GetWhereFragment() ) ! .SetOrderByClause( orderBy ) ! .ToSqlString(); ! } ! ! /// <summary> ! /// Don't bother with the discriminator, unless overridded by subclass ! /// </summary> ! /// <returns></returns> ! protected virtual SqlString GetWhereFragment( ) ! { ! return persister.WhereJoinFragment( alias, true, true ); ! } ! ! /// <summary> ! /// Gets the <see cref="ILoadable"/> Persister. ! /// </summary> ! protected ILoadable Persister ! { ! get { return persister; } ! } ! ! /// <summary></summary> ! protected string Alias ! { ! get { return alias; } ! set { Alias = value; } ! } ! ! /// <summary></summary> ! protected override ICollectionPersister CollectionPersister ! { ! get { return collectionPersister; } ! } ! ! /// <summary></summary> ! protected override int CollectionOwner ! { ! get { return collectionOwner; } ! } ! ! /// <summary></summary> ! protected string[] EntityAliases ! { ! get { return aliases; } } *************** *** 253,260 **** /// /// </summary> ! /// <param name="space"></param> ! protected void AddToPropertySpaces( object space ) { ! throw new NotSupportedException( "only criteria queries need to autoflush" ); } } --- 201,227 ---- /// /// </summary> ! /// <param name="type"></param> ! /// <param name="mappingDefault"></param> ! /// <param name="path"></param> ! /// <param name="table"></param> ! /// <param name="foreignKeyColumns"></param> ! /// <returns></returns> ! protected override bool IsJoinedFetchEnabled( ! IType type, ! bool mappingDefault, ! string path, ! string table, ! string[] foreignKeyColumns ) { ! return mappingDefault; ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <returns></returns> ! public override string ToString() ! { ! return this.GetType().Name + " for " + Persister.ClassName; } } Index: CollectionLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/CollectionLoader.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CollectionLoader.cs 6 Mar 2005 12:44:43 -0000 1.14 --- CollectionLoader.cs 14 Mar 2005 18:53:03 -0000 1.15 *************** *** 1,4 **** --- 1,5 ---- using System; using System.Collections; + using System.Text; using NHibernate.Collection; using NHibernate.Engine; *************** *** 15,20 **** public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private IQueryableCollection collectionPersister; ! private IType keyType; /// <summary> --- 16,21 ---- public class CollectionLoader : OuterJoinLoader, ICollectionInitializer { ! private readonly IQueryableCollection collectionPersister; ! private readonly IType keyType; /// <summary> *************** *** 35,93 **** public CollectionLoader( IQueryableCollection persister, int batchSize, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { ! keyType = persister.KeyType; ! ! string alias = ToAlias( persister.TableName, 0 ); ! ! //TODO: H2.0.3 the whereString is appended with the " and " - I don't think ! // that is needed because we are building SqlStrings differently and the Builder ! // probably already takes this into account. ! SqlString whereSqlString = null; ! if( persister.HasWhere ) ! { ! whereSqlString = new SqlString( persister.GetSQLWhereString( alias ) ); ! } IList associations = WalkCollectionTree( persister, alias, factory ); ! int joins = associations.Count; ! Suffixes = new string[joins]; ! for( int i = 0; i < joins; i++ ) ! { ! Suffixes[ i ] = i.ToString() + StringHelper.Underscore; ! } ! ! JoinFragment ojf = OuterJoins( associations ); ! SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ); ! selectBuilder.SetSelectClause( ! persister.SelectFragment( alias ).ToString() + ! ( joins == 0 ? String.Empty : ", " + SelectString( associations ) ) ! ) ! .SetFromClause( persister.TableName, alias ) ! .SetWhereClause( alias, persister.KeyColumnNames, persister.KeyType ) ! .SetOuterJoins( ojf.ToFromFragmentString, ojf.ToWhereFragmentString ); ! if( persister.HasWhere ) ! { ! selectBuilder.AddWhereClause( whereSqlString ); ! } ! if( persister.HasOrdering ) { ! selectBuilder.SetOrderByClause( persister.GetSQLOrderByString( alias ) ); } ! this.SqlString = selectBuilder.ToSqlString(); ! ! Persisters = new ILoadable[joins]; ! LockModeArray = CreateLockModeArray( joins, LockMode.None ); ! for( int i = 0; i < joins; i++ ) { ! Persisters[ i ] = ( ILoadable ) ( ( OuterJoinableAssociation ) associations[ i ] ).Subpersister; } - this.collectionPersister = persister; - - PostInstantiate(); - } --- 36,71 ---- public CollectionLoader( IQueryableCollection persister, int batchSize, ISessionFactoryImplementor factory ) : base( factory.Dialect ) { ! this.collectionPersister = persister; ! this.keyType = persister.KeyType; + string alias = GenerateRootAlias( persister.TableName ); IList associations = WalkCollectionTree( persister, alias, factory ); ! InitStatementString( persister, alias, associations, batchSize, factory ); ! InitClassPersisters( associations ); ! ! PostInstantiate(); ! } ! private void InitClassPersisters( IList associations ) ! { ! int joins = associations.Count; ! LockModeArray = CreateLockModeArray( joins, LockMode.None ); ! classPersisters = new ILoadable[ joins ]; ! SetOwners( new int[ joins ] ); ! int i = 0; ! foreach( OuterJoinableAssociation oj in associations ) { ! classPersisters[ i ] = (ILoadable) oj.Joinable; ! Owners[ i ] = ToOwner( oj, joins, oj.IsOneToOne ); ! i++; } ! if ( ArrayHelper.IsAllNegative( Owners ) ) { ! SetOwners( null ); } } *************** *** 102,111 **** /// </summary> /// <param name="id"></param> - /// <param name="collection"></param> - /// <param name="owner"></param> /// <param name="session"></param> ! public void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ) { ! LoadCollection( session, id, keyType, owner, collection ); } --- 80,117 ---- /// </summary> /// <param name="id"></param> /// <param name="session"></param> ! public void Initialize( object id, ISessionImplementor session ) { ! LoadCollection( session, id, keyType ); ! } ! ! private void InitStatementString( IQueryableCollection persister, string alias, IList associations, int batchSize, ISessionFactoryImplementor factory ) ! { ! Suffixes = GenerateSuffixes( associations.Count ); ! ! SqlString whereString = WhereString( factory, alias, persister.KeyColumnNames, persister.KeyType, batchSize ); ! if ( persister.HasWhere ) ! { ! whereString = whereString.Append( " and ").Append( persister.GetSQLWhereString( alias ) ); ! } ! ! JoinFragment ojf = MergeOuterJoins( associations ); ! SqlSelectBuilder select = new SqlSelectBuilder( factory ) ! .SetSelectClause( ! persister.SelectFragment( alias ).Append( ! SelectString( associations, factory ) ).ToString() ! ) ! .SetFromClause( persister.TableName, alias ) ! .AddWhereClause( whereString ) ! .SetOuterJoins( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString ! ); ! ! if ( persister.HasOrdering ) ! { ! select.SetOrderByClause( persister.GetSQLOrderByString( alias ) ); ! } ! SqlString = select.ToSqlString(); } *************** *** 113,121 **** /// /// </summary> ! /// <param name="id"></param> ! /// <param name="session"></param> ! public void Initialize( object id, ISessionImplementor session ) { ! LoadCollection( session, id, keyType ); } } --- 119,145 ---- /// /// </summary> ! /// <param name="type"></param> ! /// <param name="config"></param> ! /// <param name="path"></param> ! /// <param name="table"></param> ! /// <param name="foreignKeyColumns"></param> ! /// <param name="factory"></param> ! /// <returns></returns> ! protected override JoinType GetJoinType( ! IAssociationType type, ! OuterJoinFetchStrategy config, ! string path, ! string table, ! string[] foreignKeyColumns, ! ISessionFactoryImplementor factory ! ) { ! JoinType joinType = base.GetJoinType( type, config, path, table, foreignKeyColumns, factory ); ! // We can use an inner-join for the many-to-many ! if ( joinType == JoinType.LeftOuterJoin && path.Equals( string.Empty ) ) ! { ! joinType = JoinType.InnerJoin; ! } ! return joinType; } } Index: OneToManyLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OneToManyLoader.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** OneToManyLoader.cs 6 Mar 2005 12:44:43 -0000 1.15 --- OneToManyLoader.cs 14 Mar 2005 18:53:03 -0000 1.16 *************** *** 13,16 **** --- 13,20 ---- /// Loads one-to-many associations /// </summary> + /// <remarks> + /// The collection persister must implement IQueryableCollection. For + /// other collections, create a customized subclass of Loader. + /// </remarks> public class OneToManyLoader : OuterJoinLoader, ICollectionInitializer { *************** *** 38,108 **** idType = collectionPersister.KeyType; ! //ILoadable persister = ( ILoadable ) factory.GetPersister( ( ( EntityType ) collPersister.ElementType ).AssociatedClass ); ! ILoadable persister = ( ILoadable ) collPersister.ElementPersister; ! ! string alias = ToAlias( collectionPersister.TableName, 0 ); ! ! SqlString whereSqlString = null; ! ! if( collectionPersister.HasWhere ) ! { ! whereSqlString = new SqlString( collectionPersister.GetSQLWhereString( alias ) ); ! } IList associations = WalkTree( persister, alias, factory ); ! int joins = associations.Count; ! Suffixes = new string[joins + 1]; ! for( int i = 0; i <= joins; i++ ) ! { ! Suffixes[ i ] = ( joins == 0 ) ? String.Empty : i.ToString() + StringHelper.Underscore; ! } ! ! JoinFragment ojf = OuterJoins( associations ); ! ! SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ); ! ! selectBuilder.SetSelectClause( ! collectionPersister.SelectFragment( alias ).ToString() + ! ( joins == 0 ? String.Empty : "," + SelectString( associations ) ) + ! ", " + ! SelectString( persister, alias, Suffixes[ joins ] ) ! ); ! ! ! selectBuilder.SetFromClause( ! persister.FromTableFragment( alias ).Append( ! persister.FromJoinFragment( alias, true, true ) ! ) ! ); ! ! selectBuilder.SetWhereClause( alias, collectionPersister.KeyColumnNames, collectionPersister.KeyType ); ! if( collectionPersister.HasWhere ) ! { ! selectBuilder.AddWhereClause( whereSqlString ); ! } ! ! selectBuilder.SetOuterJoins( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString.Append( ! persister.WhereJoinFragment( alias, true, true ) ! ) ! ); ! ! if( collectionPersister.HasOrdering ) ! { ! selectBuilder.SetOrderByClause( collectionPersister.GetSQLOrderByString( alias ) ); ! } ! ! this.SqlString = selectBuilder.ToSqlString(); ! ! ! Persisters = new ILoadable[joins + 1]; ! LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); ! for( int i = 0; i < joins; i++ ) ! { ! Persisters[ i ] = ( ( OuterJoinableAssociation ) associations[ i ] ).Subpersister; ! } ! Persisters[ joins ] = persister; PostInstantiate(); --- 42,52 ---- idType = collectionPersister.KeyType; ! IOuterJoinLoadable persister = ( IOuterJoinLoadable ) collPersister.ElementPersister; + string alias = GenerateRootAlias( collPersister.Role ); IList associations = WalkTree( persister, alias, factory ); ! InitStatementString( collPersister, persister, alias, associations, batchSize, factory ); ! InitClassPersisters( persister, associations ); PostInstantiate(); *************** *** 110,115 **** /// <summary> ! /// /// </summary> /// <param name="mappingDefault"></param> /// <param name="path"></param> --- 54,60 ---- /// <summary> ! /// Disable a join back to this same association /// </summary> + /// <param name="type"></param> /// <param name="mappingDefault"></param> /// <param name="path"></param> *************** *** 117,125 **** /// <param name="foreignKeyColumns"></param> /// <returns></returns> ! protected override bool EnableJoinedFetch( bool mappingDefault, string path, string table, string[ ] foreignKeyColumns ) { ! return mappingDefault && ( ! !table.Equals( collectionPersister.TableName ) || ! !ArrayHelper.Equals( foreignKeyColumns, collectionPersister.KeyColumnNames ) ); } --- 62,70 ---- /// <param name="foreignKeyColumns"></param> /// <returns></returns> ! protected override bool IsJoinedFetchEnabled( IType type, bool mappingDefault, string path, string table, string[] foreignKeyColumns ) { ! return base.IsJoinedFetchEnabled( type, mappingDefault, path, table, foreignKeyColumns) && ( ! !table.Equals( collectionPersister.TableName ) || ! !ArrayHelper.Equals( foreignKeyColumns, collectionPersister.KeyColumnNames ) ); } *************** *** 135,154 **** /// </summary> /// <param name="id"></param> - /// <param name="collection"></param> - /// <param name="owner"></param> /// <param name="session"></param> ! public void Initialize( object id, PersistentCollection collection, object owner, ISessionImplementor session ) { ! LoadCollection( session, id, idType, owner, collection ); } ! /// <summary> ! /// ! /// </summary> ! /// <param name="id"></param> ! /// <param name="session"></param> ! public void Initialize( object id, ISessionImplementor session ) { ! LoadCollection( session, id, idType ); } } --- 80,157 ---- /// </summary> /// <param name="id"></param> /// <param name="session"></param> ! public void Initialize( object id, ISessionImplementor session ) { ! LoadCollection( session, id, idType ); } ! private void InitClassPersisters( IOuterJoinLoadable persister, IList associations ) { ! int joins = associations.Count; ! LockModeArray = CreateLockModeArray( joins + 1, LockMode.None ); ! ! Persisters = new ILoadable[joins + 1]; ! SetOwners( new int[ joins + 1 ] ); ! for( int i = 0; i < joins; i++ ) ! { ! OuterJoinableAssociation oj = ( OuterJoinableAssociation ) associations[ i ]; ! Persisters[ i ] = (ILoadable) oj.Joinable; ! Owners[ i ] = ToOwner( oj, joins, oj.IsOneToOne ); ! } ! Persisters[ joins ] = persister; ! Owners[ joins ] = -1; ! ! if ( ArrayHelper.IsAllNegative( Owners ) ) ! { ! SetOwners( null ); ! } ! } ! ! private void InitStatementString( ! IQueryableCollection collPersister, ! IOuterJoinLoadable persister, ! string alias, ! IList associations, ! int batchSize, ! ISessionFactoryImplementor factory ! ) ! { ! int joins = associations.Count; ! ! Suffixes = GenerateSuffixes( joins + 1 ); ! ! SqlString whereSqlString = WhereString( factory, alias, collPersister.KeyColumnNames, collPersister.KeyType, batchSize ); ! ! if( collectionPersister.HasWhere ) ! { ! whereSqlString.Append( " and " ).Append( collectionPersister.GetSQLWhereString( alias ) ); ! } ! ! JoinFragment ojf = MergeOuterJoins( associations ); ! ! SqlSelectBuilder selectBuilder = new SqlSelectBuilder( factory ) ! .SetSelectClause( ! collectionPersister.SelectFragment( alias, Suffixes[ joins ], true ).ToString() + ! SelectString( associations, factory ) ! ) ! .SetFromClause( ! persister.FromTableFragment( alias ).Append( ! persister.FromJoinFragment( alias, true, true ) ! ) ! ) ! .AddWhereClause( whereSqlString ) ! .SetOuterJoins( ! ojf.ToFromFragmentString, ! ojf.ToWhereFragmentString.Append( ! persister.WhereJoinFragment( alias, true, true ) ! ) ! ); ! ! if( collectionPersister.HasOrdering ) ! { ! selectBuilder.SetOrderByClause( collectionPersister.GetSQLOrderByString( alias ) ); ! } ! ! this.SqlString = selectBuilder.ToSqlString(); } } Index: CriteriaLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/CriteriaLoader.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CriteriaLoader.cs 31 Dec 2004 20:57:25 -0000 1.11 --- CriteriaLoader.cs 14 Mar 2005 18:53:03 -0000 1.12 *************** *** 2,8 **** --- 2,12 ---- using System.Data; using System.Text; + using Iesi.Collections; + using NHibernate.Dialect; using NHibernate.Engine; using NHibernate.Expression; + using NHibernate.Impl; using NHibernate.Persister; + using NHibernate.SqlCommand; using NHibernate.Type; using NHibernate.Util; *************** *** 17,24 **** /// queries are more like multi-object <c>Load()</c>s than like HQL queries. /// </remarks> ! public class CriteriaLoader : AbstractEntityLoader { ! private ICriteria criteria; ! //private static readonly IType[] noTypes = new IType[0]; /// <summary> --- 21,29 ---- /// queries are more like multi-object <c>Load()</c>s than like HQL queries. /// </remarks> ! internal class CriteriaLoader : AbstractEntityLoader { ! private CriteriaImpl criteria; ! private ISet querySpaces = new HashedSet(); ! private IType[] resultTypes; /// <summary> *************** *** 28,42 **** /// <param name="factory"></param> /// <param name="criteria"></param> ! public CriteriaLoader( ILoadable persister, ISessionFactoryImplementor factory, ICriteria criteria ) : base( persister, factory ) { this.criteria = criteria; ! IEnumerator iter = criteria.IterateExpressions(); StringBuilder orderByBuilder = new StringBuilder( 60 ); bool commaNeeded = false; - iter = criteria.IterateOrderings(); while( iter.MoveNext() ) { --- 33,50 ---- /// <param name="factory"></param> /// <param name="criteria"></param> ! public CriteriaLoader( IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl criteria ) : base( persister, factory ) { this.criteria = criteria; ! AddAllToPropertySpaces( persister.PropertySpaces ); ! ! resultTypes = new IType[ 1 ]; ! resultTypes[ 0 ] = NHibernateUtil.Entity( persister.MappedClass ); StringBuilder orderByBuilder = new StringBuilder( 60 ); bool commaNeeded = false; + IEnumerator iter = criteria.IterateOrderings(); while( iter.MoveNext() ) { *************** *** 52,59 **** } ! RenderStatement( criteria.Expression.ToSqlString( factory, criteria.PersistentClass, Alias ), orderByBuilder.ToString(), factory ); PostInstantiate(); - } --- 60,68 ---- } ! IList associations = WalkTree( persister, Alias, factory ); ! InitClassPersisters( associations ); ! InitStatementString( associations, criteria.Expression.ToSqlString( factory, criteria.PersistentClass, Alias ), orderByBuilder.ToString(), factory ); PostInstantiate(); } *************** *** 82,87 **** IType[ ] typeArray = ( IType[ ] ) types.ToArray( typeof( IType ) ); ! QueryParameters qp = new QueryParameters( typeArray, valueArray, null, criteria.Selection ); ! return Find( session, qp, true ); } --- 91,110 ---- IType[ ] typeArray = ( IType[ ] ) types.ToArray( typeof( IType ) ); ! // TODO: 2.1 Uncomment once CriteriaImpl up to standard ! /* ! RowSelection selection = new RowSelection(); ! selection.FirstRow = criteria.FirstResult; ! selection.MaxRows = criteria.MaxResults; ! selection.Timeout = criteria.Timeout; ! selection.FetchSize = criteria.FetchSize; ! ! QueryParameters qp = new QueryParameters( typeArray, valueArray, criteria.LockModes, selection ); ! qp.Cacheable = criteria.Cacheable; ! qp.CacheRegion = criteria.CacheRegion; ! */ ! ! QueryParameters qp = new QueryParameters( typeArray, valueArray, criteria.LockModes, criteria.Selection ); ! ! return List( session, qp, querySpaces, resultTypes ); } *************** *** 95,110 **** protected override object GetResultColumnOrRow( object[ ] row, IDataReader rs, ISessionImplementor session ) { return row[ row.Length - 1 ]; } /// <summary> ! /// Navigate associations, returning the aliased columns. Adds extra table joins ! /// to this loader. /// </summary> ! /// <param name="pathExpression"></param> /// <returns></returns> ! public string[ ] ToColumns( string pathExpression ) { ! return null; } --- 118,160 ---- protected override object GetResultColumnOrRow( object[ ] row, IDataReader rs, ISessionImplementor session ) { + //return criteria.ResultTransformer.TransformTuple( row, EntityAliases ); return row[ row.Length - 1 ]; } /// <summary> ! /// /// </summary> ! /// <param name="type"></param> ! /// <param name="config"></param> ! /// <param name="path"></param> ! /// <param name="table"></param> ! /// <param name="foreignKeyColumns"></param> ! /// <param name="factory"></param> /// <returns></returns> ! protected override JoinType GetJoinType( ! IAssociationType type, ! OuterJoinFetchStrategy config, ! string path, ! string table, ! string[] foreignKeyColumns, ! ISessionFactoryImplementor factory ) { ! if ( criteria.IsJoin( path ) ) ! { ! return JoinType.InnerJoin; ! } ! else ! { ! FetchMode fm = criteria.GetFetchMode( path ); ! //fm==null || - an Enum can't be null ! if( fm == FetchMode.Default ) ! { ! return base.GetJoinType( type, config, path, table, foreignKeyColumns, factory ); ! } ! else ! { ! return fm == FetchMode.Eager ? JoinType.LeftOuterJoin : JoinType.None; ! } ! } } *************** *** 112,140 **** /// /// </summary> ! /// <param name="mappingDefault"></param> /// <param name="path"></param> ! /// <param name="table"></param> ! /// <param name="foreignKeyColumns"></param> /// <returns></returns> ! protected override bool EnableJoinedFetch( bool mappingDefault, string path, string table, string[ ] foreignKeyColumns ) { ! FetchMode fm = criteria.GetFetchMode( path ); ! //fm==null || - an Enum can't be null ! if( fm == FetchMode.Default ) { ! return mappingDefault; } else { ! return fm == FetchMode.Eager; } } ! /// <summary></summary> ! protected override bool UseQueryWhereFragment { ! get { return true; } } } } \ No newline at end of file --- 162,268 ---- /// /// </summary> ! /// <returns></returns> ! /// <remarks>Uses the discriminator, to narrow the select to instances of the queried subclass.</remarks> ! protected override SqlString GetWhereFragment( ) ! { ! return ( (IQueryable) Persister).QueryWhereFragment( Alias, true, true ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="className"></param> ! /// <param name="n"></param> /// <param name="path"></param> ! /// <param name="isLinkTable"></param> /// <returns></returns> ! protected override string GenerateTableAlias( string className, int n, string path, bool isLinkTable ) { ! if ( !isLinkTable ) { ! string userDefinedAlias = criteria.GetAlias( path ); ! if ( userDefinedAlias != null ) ! { ! return userDefinedAlias; ! } ! } ! return base.GenerateTableAlias( className, n, path, isLinkTable ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="tableName"></param> ! /// <returns></returns> ! protected override string GenerateRootAlias( string tableName ) ! { ! return CriteriaImpl.RootAlias; ! } ! ! /// <summary> ! /// ! /// </summary> ! public ISet QuerySpaces ! { ! get { return querySpaces; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="space"></param> ! protected override void AddToPropertySpaces( object space ) ! { ! querySpaces.Add( space ); ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="sqlSelectString"></param> ! /// <param name="lockModes"></param> ! /// <param name="dialect"></param> ! /// <returns></returns> ! protected string ApplyLocks( string sqlSelectString, IDictionary lockModes, Dialect.Dialect dialect ) ! { ! if ( lockModes == null || lockModes.Count == 0 ) ! { ! return sqlSelectString; } else { ! return sqlSelectString + new ForUpdateFragment( ).ToSqlStringFragment( dialect ); } } ! /// <summary> ! /// ! /// </summary> ! /// <param name="lockModes"></param> ! /// <returns></returns> ! protected override LockMode[] GetLockModes( IDictionary lockModes ) { ! string[] aliases = EntityAliases; ! int size = aliases.Length; ! LockMode[] lockModesArray = new LockMode[ size ]; ! for( int i = 0; i < size; i++ ) ! { ! LockMode lockMode = (LockMode) lockModes[ aliases[ i ] ]; ! lockModesArray[ i ] = lockMode == null ? LockMode.None : lockMode; ! } ! return lockModesArray; } + /// <summary> + /// + /// </summary> + /// <param name="results"></param> + /// <returns></returns> + protected override IList ResultList( IList results ) + { + // TODO: 2.1 Transform the results + //return criteria.ResultTransformer.TransformList( results ); + return results; + } } } \ No newline at end of file Index: OuterJoinLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/OuterJoinLoader.cs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** OuterJoinLoader.cs 6 Mar 2005 12:44:44 -0000 1.19 --- OuterJoinLoader.cs 14 Mar 2005 18:53:03 -0000 1.20 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using System.Text; + using Iesi.Collections; using NHibernate.Collection; using NHibernate.Dialect; *************** *** 42,52 **** private LockMode[ ] lockModeArray; [...1298 lines suppressed...] ! } ! else ! { ! // a many-to-one association ! return aliasedPropertyColumns; ! } ! } ! ! private static string[] GetForeignKeyColumns( IOuterJoinLoadable persister, IAssociationType associationType, string[] propertyColumns ) ! { ! if ( associationType.UsePrimaryKeyAsForeignKey ) ! { ! return persister.IdentifierColumnNames; ! } ! else ! { ! return propertyColumns; ! } } Index: SimpleEntityLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/SimpleEntityLoader.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SimpleEntityLoader.cs 1 Mar 2005 16:24:48 -0000 1.11 --- SimpleEntityLoader.cs 14 Mar 2005 18:53:03 -0000 1.12 *************** *** 15,22 **** public class SimpleEntityLoader : Loader, IUniqueEntityLoader { ! private ILoadable[ ] persister; ! private IType[ ] idType; private SqlString sqlString; ! private LockMode[ ] lockMode; /// <summary> --- 15,22 ---- public class SimpleEntityLoader : Loader, IUniqueEntityLoader { ! private readonly ILoadable[ ] persister; ! private readonly IType idType; private SqlString sqlString; ! private readonly LockMode[ ] lockMode; /// <summary> *************** *** 30,34 **** { this.persister = new ILoadable[ ] {persister}; ! this.idType = new IType[ ] {persister.IdentifierType}; this.sqlString = sqlString; this.lockMode = new LockMode[ ] {lockMode}; --- 30,34 ---- { this.persister = new ILoadable[ ] {persister}; ! this.idType = persister.IdentifierType; this.sqlString = sqlString; this.lockMode = new LockMode[ ] {lockMode}; *************** *** 44,51 **** /// <summary></summary> protected override ILoadable[ ] Persisters { get { return persister; } ! set { persister = value; } } --- 44,63 ---- /// <summary></summary> + protected override int[] Owners + { + get { return null; } + } + + /// <summary></summary> + protected override bool IsSingleRowLoader + { + get { return true; } + } + + /// <summary></summary> protected override ILoadable[ ] Persisters { get { return persister; } ! set { throw new NotSupportedException( "cannot assign to the Persisters property" ); } } *************** *** 72,80 **** public object Load( ISessionImplementor session, object id, object obj ) { ! IList list = LoadEntity( session, new object[ ] {id}, idType, obj, id, false ); if( list.Count == 1 ) { return list[ 0 ]; - //return ( (object[]) list[0] )[0]; } else if( list.Count == 0 ) --- 84,91 ---- public object Load( ISessionImplementor session, object id, object obj ) { ! IList list = LoadEntity( session, id, idType, obj, id ); if( list.Count == 1 ) { return list[ 0 ]; } else if( list.Count == 0 ) *************** *** 112,116 **** return row[ 0 ]; } - } } \ No newline at end of file --- 123,126 ---- Index: Loader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/Loader.cs,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Loader.cs 6 Mar 2005 12:44:43 -0000 1.49 --- Loader.cs 14 Mar 2005 18:53:03 -0000 1.50 *************** *** 6,9 **** --- 6,10 ---- using NHibernate.Collection; using NHibernate.Engine; + using NHibernate.Impl; using NHibernate.Persister; using NHibernate.SqlCommand; *************** *** 19,32 **** /// This class implements useful common funtionality that concrete loaders would delegate to. /// It is not intended that this functionality would be directly accessed by client code (Hence, [...1116 lines suppressed...] { ! //return new Alias( 10, unique.ToString() + StringHelper.Underscore ) ! // .ToAliasString( StringHelper.Unqualify( description ).ToLower(), Dialect ); ! ! string alias = StringHelper.Unqualify( description ).ToLower().Replace( "$", "_" ); ! int len = Math.Min( 10, alias.Length ); ! ! return alias.Substring( 0, len ) + unique.ToString() + StringHelper.Underscore; } } --- 1187,1195 ---- /// <param name="unique"></param> /// <returns>an alias of the form <c>foo1_</c></returns> ! protected string GenerateAlias( string description, int unique ) { ! // NB Java has this as static but we need the Dialect to achieve correct quoting. ! return new Alias( 10, unique.ToString() + StringHelper.Underscore ) ! .ToAliasString( StringHelper.Unqualify( description ).ToLower().Replace( "$", "_" ), Dialect ); } } Index: SqlLoader.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Loader/SqlLoader.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlLoader.cs 1 Mar 2005 16:24:48 -0000 1.1 --- SqlLoader.cs 14 Mar 2005 18:53:03 -0000 1.2 *************** *** 236,240 **** public IList List( ISessionImplementor session, QueryParameters queryParameters ) { ! // TODO: Uncomment once //return List( session, queryParameters, querySpaces, resultTypes ) ; return null ; --- 236,240 ---- public IList List( ISessionImplementor session, QueryParameters queryParameters ) { ! // TODO: 2.1 Uncomment once SQL Loading implemented //return List( session, queryParameters, querySpaces, resultTypes ) ; return null ; |
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6723/nhibernate/src/NHibernate/Impl Modified Files: CollectionEntry.cs CriteriaImpl.cs IExecutable.cs ScheduledCollectionAction.cs ScheduledCollectionRecreate.cs ScheduledCollectionRemove.cs ScheduledCollectionUpdate.cs ScheduledDeletion.cs ScheduledEntityAction.cs ScheduledIdentityInsertion.cs ScheduledInsertion.cs ScheduledUpdate.cs SessionImpl.cs Log Message: Refactored as per 2.1 Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** SessionImpl.cs 10 Mar 2005 02:21:06 -0000 1.70 --- SessionImpl.cs 14 Mar 2005 18:52:52 -0000 1.71 *************** *** 44,63 **** /// <c>true</c> if the Session has had the methods <c>Close()</c> or /// <c>Dispose()</c> invoked.</value> ! private bool closed; private FlushMode flushMode = FlushMode.Auto; ! /// <summary> ! /// A boolean indicating if the method AfterTransactionCompletion() should ! /// be called from the method Disconnect(). ! /// </summary> ! /// <value> [...1094 lines suppressed...] // that references it ! ICollectionPersister persister = factory.GetCollectionPersister( role ); ! PersistentCollection collection = GetLoadingCollection( role, id ); if (collection != null) *************** *** 4937,4941 **** log.Debug( "creating collection wrapper:" + MessageHelper.InfoString(persister, id) ); } ! collection = persister.CollectionType.Instantiate(this, persister); //TODO: suck into CollectionPersister.instantiate() AddUninitializedCollection(collection, persister, id); if ( persister.IsArray ) --- 5024,5029 ---- log.Debug( "creating collection wrapper:" + MessageHelper.InfoString(persister, id) ); } ! //TODO: suck into CollectionPersister.instantiate() ! collection = persister.CollectionType.Instantiate(this, persister); AddUninitializedCollection(collection, persister, id); if ( persister.IsArray ) Index: CriteriaImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CriteriaImpl.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CriteriaImpl.cs 31 Dec 2004 19:51:05 -0000 1.8 --- CriteriaImpl.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 1,4 **** --- 1,8 ---- using System.Collections; using NHibernate.Engine; + using NHibernate.Persister; + using NHibernate.Transform; + using NHibernate.Type; + using NHibernate.Util; using NExpression = NHibernate.Expression; *************** *** 10,20 **** internal class CriteriaImpl : ICriteria { ! private IList expressions = new ArrayList(); private IList orderings = new ArrayList(); private IDictionary fetchModes = new Hashtable(); ! ! private RowSelection selection = new RowSelection(); private System.Type persistentClass; private SessionImpl session; private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); --- 14,36 ---- internal class CriteriaImpl : ICriteria { ! private IList criteria = new ArrayList(); private IList orderings = new ArrayList(); private IDictionary fetchModes = new Hashtable(); ! private IDictionary associationPathByAlias = new Hashtable(); ! private IDictionary aliasByAssociationPath = new Hashtable(); ! private IDictionary classByAlias = new Hashtable(); ! private IDictionary lockModes = new Hashtable(); ! private int maxResults; ! private int firstResult; ! private int timeout; ! private int fetchSize; private System.Type persistentClass; private SessionImpl session; + private IResultTransformer resultTransformer; //== new RootEntityResultTransformer(); + private bool cacheable; + private string cacheRegion; + private RowSelection selection = new RowSelection(); + + private int counter = 0; private NExpression.Junction conjunction = NExpression.Expression.Conjunction(); *************** *** 23,26 **** --- 39,90 ---- /// /// </summary> + public const string RootAlias = "this"; + + /// <summary> + /// + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="session"></param> + public CriteriaImpl( System.Type persistentClass, SessionImpl session ) + { + this.persistentClass = persistentClass; + this.session = session; + this.classByAlias[ CriteriaImpl.RootAlias ] = persistentClass ; + this.cacheable = false; + } + + /// <summary> + /// Copy all the internal attributes of the given CriteriaImpl + /// except alter the root persistent class type to be the given one. + /// </summary> + /// <param name="persistentClass"></param> + /// <param name="original"></param> + public CriteriaImpl( System.Type persistentClass, CriteriaImpl original ) + { + this.persistentClass = persistentClass; + + //this.classByAlias = original.ClassByAlias; + //this.classByAlias.put( CriteriaImpl.RootAlias, persistentClass); + + this.criteria = original.Criteria; + this.orderings = original.Orderings; + this.fetchModes = original.FetchModes; + this.associationPathByAlias = original.AssociationPathByAlias; + this.aliasByAssociationPath = original.AliasByAssociationPath; + this.lockModes = original.LockModes; + this.maxResults = original.MaxResults; + this.firstResult = original.FirstResult; + this.timeout = original.Timeout; + this.fetchSize = original.FetchSize; + this.session = original.Session; + this.resultTransformer = original.ResultTransformer; + this.counter = original.Counter; + this.cacheable = original.Cacheable; + this.cacheRegion = original.CacheRegion; + } + + /// <summary> + /// + /// </summary> /// <param name="maxResults"></param> /// <returns></returns> *************** *** 56,65 **** /// /// </summary> ! /// <param name="expression"></param> /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { ! expressions.Add( expression ); ! conjunction.Add( expression ); return this; } --- 120,128 ---- /// /// </summary> ! /// <param name="fetchSize"></param> /// <returns></returns> ! public ICriteria SetFetchSize( int fetchSize ) { ! this.fetchSize = fetchSize; return this; } *************** *** 78,90 **** } /// <summary> /// /// </summary> ! /// <param name="persistentClass"></param> ! /// <param name="session"></param> ! public CriteriaImpl( System.Type persistentClass, SessionImpl session ) { ! this.persistentClass = persistentClass; ! this.session = session; } --- 141,239 ---- } + internal IList Criteria + { + get { return criteria; } + } + + internal IList Orderings + { + get { return orderings; } + } + + internal IDictionary LockModes + { + get { return lockModes; } + } + + internal IDictionary FetchModes + { + get { return fetchModes; } + } + + internal IDictionary AssociationPathByAlias + { + get { return associationPathByAlias; } + } + + internal IDictionary AliasByAssociationPath + { + get { return aliasByAssociationPath; } + } + + internal SessionImpl Session + { + get { return session; } + } + + internal IResultTransformer ResultTransformer + { + get { return resultTransformer; } + } + + internal int Counter + { + get { return counter; } + } + + internal bool Cacheable + { + get { return cacheable; } + } + + internal string CacheRegion + { + get { return cacheRegion; } + } + + /// <summary></summary> + public int MaxResults + { + get { return maxResults; } + } + + /// <summary></summary> + public int FirstResult + { + get { return firstResult; } + } + + /// <summary></summary> + public int Timeout + { + get { return timeout; } + } + + /// <summary></summary> + public int FetchSize + { + get { return fetchSize; } + } + + /// <summary></summary> + public bool IsJoin( string path ) + { + return aliasByAssociationPath.Contains( path ); + } + /// <summary> /// /// </summary> ! /// <param name="expression"></param> ! /// <returns></returns> ! public ICriteria Add( NExpression.Expression expression ) { ! criteria.Add( expression ); ! conjunction.Add( expression ); ! return this; } *************** *** 98,102 **** public IEnumerator IterateExpressions() { ! return expressions.GetEnumerator(); } --- 247,251 ---- public IEnumerator IterateExpressions() { ! return criteria.GetEnumerator(); } *************** *** 116,120 **** public override string ToString() { ! return expressions.ToString(); } --- 265,269 ---- public override string ToString() { ! return criteria.ToString(); } *************** *** 158,161 **** --- 307,409 ---- return this; } + + /// <summary> + /// + /// </summary> + /// <param name="lockMode"></param> + /// <returns></returns> + public ICriteria SetLockMode( LockMode lockMode ) + { + return SetLockMode( CriteriaImpl.RootAlias, lockMode ); + } + + /// <summary> + /// + /// </summary> + /// <param name="alias"></param> + /// <param name="lockMode"></param> + /// <returns></returns> + public ICriteria SetLockMode( string alias, LockMode lockMode ) + { + lockModes[ alias ] = lockMode; + return this; + } + + /// <summary> + /// + /// </summary> + /// <param name="associationPath"></param> + /// <param name="alias"></param> + /// <returns></returns> + public ICriteria CreateAlias( string associationPath, string alias ) + { + CreateAlias( CriteriaImpl.RootAlias, associationPath, alias ); + return this; + } + + private void CreateAlias( string rootAlias, string associationPath, string alias ) + { + string testAlias = StringHelper.Root( associationPath ); + if ( classByAlias.Contains( testAlias ) ) + { + rootAlias = testAlias; + associationPath = associationPath.Substring( rootAlias.Length + 1 ); + } + + string rootPath = (string) associationPathByAlias[ rootAlias ]; + string wholeAssociationPath; + if ( rootPath == null ) + { + if ( !CriteriaImpl.RootAlias.Equals( rootAlias ) ) + { + throw new HibernateException( string.Format( "unknown alias: {0}", rootAlias ) ); + } + wholeAssociationPath = associationPath; + } + else + { + wholeAssociationPath = StringHelper.Qualify( rootPath, associationPath ); + } + + object oldPath = associationPathByAlias[ alias ] = wholeAssociationPath; + if ( oldPath != null ) + { + } + object oldAlias = aliasByAssociationPath[ wholeAssociationPath ] = alias; + if ( oldAlias != null ) + { + } + classByAlias[ alias ] = GetClassForPath( rootAlias, associationPath ); + } + + + /// <summary> + /// + /// </summary> + /// <param name="associationPath"></param> + /// <returns></returns> + public string GetAlias( string associationPath ) + { + return (string) aliasByAssociationPath[ associationPath ]; + } + + /// <summary> + /// + /// </summary> + /// <param name="rootAlias"></param> + /// <param name="associationPath"></param> + /// <returns></returns> + public System.Type GetClassForPath( string rootAlias, string associationPath ) + { + ISessionFactoryImplementor factory = session.Factory; + System.Type clazz = (System.Type) classByAlias[ rootAlias ]; + IType type = ( (IPropertyMapping) factory.GetPersister( clazz ) ).ToType( associationPath ); + if ( !type.IsAssociationType ) + { + throw new QueryException( string.Format( "not an association path: {0}", associationPath ) ); + } + + return ( (IAssociationType) type).GetAssociatedClass( factory ); + } } } \ No newline at end of file Index: ScheduledDeletion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledDeletion.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ScheduledDeletion.cs 6 Mar 2005 12:44:42 -0000 1.7 --- ScheduledDeletion.cs 14 Mar 2005 18:52:52 -0000 1.8 *************** *** 39,43 **** /// <summary></summary> ! public override void AfterTransactionCompletion() { if( Persister.HasCache ) --- 39,43 ---- /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { if( Persister.HasCache ) Index: IExecutable.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/IExecutable.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IExecutable.cs 6 Mar 2005 12:44:42 -0000 1.3 --- IExecutable.cs 14 Mar 2005 18:52:52 -0000 1.4 *************** *** 25,33 **** /// Called after the Transaction has been completed. /// </summary> /// <remarks> /// Actions should make sure that the Cache is notified about /// what just happened. /// </remarks> ! void AfterTransactionCompletion(); /// <summary> --- 25,34 ---- /// Called after the Transaction has been completed. /// </summary> + /// <param name="success"></param> /// <remarks> /// Actions should make sure that the Cache is notified about /// what just happened. /// </remarks> ! void AfterTransactionCompletion( bool success ); /// <summary> Index: ScheduledIdentityInsertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledIdentityInsertion.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ScheduledIdentityInsertion.cs 6 Mar 2005 12:44:43 -0000 1.1 --- ScheduledIdentityInsertion.cs 14 Mar 2005 18:52:52 -0000 1.2 *************** *** 10,14 **** { private readonly object[] state; ! private CacheEntry cacheEntry; private object generatedId; --- 10,14 ---- { private readonly object[] state; ! //private CacheEntry cacheEntry; private object generatedId; *************** *** 46,50 **** } ! public override void AfterTransactionCompletion( ) { // TODO: renable --- 46,54 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="sucess"></param> ! public override void AfterTransactionCompletion( bool sucess ) { // TODO: renable Index: ScheduledCollectionRecreate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRecreate.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScheduledCollectionRecreate.cs 1 Mar 2005 16:24:46 -0000 1.6 --- ScheduledCollectionRecreate.cs 14 Mar 2005 18:52:52 -0000 1.7 *************** *** 28,33 **** { Persister.Recreate( _collection, Id, Session ); ! // TODO: Commented out as isn't in the 2.1 implementation - test ! //Persister.Softlock( Id ); } } --- 28,32 ---- { Persister.Recreate( _collection, Id, Session ); ! Evict(); } } Index: ScheduledInsertion.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledInsertion.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScheduledInsertion.cs 6 Mar 2005 12:44:42 -0000 1.6 --- ScheduledInsertion.cs 14 Mar 2005 18:52:52 -0000 1.7 *************** *** 10,14 **** { private readonly object[ ] state; ! private CacheEntry entry; private readonly object version; --- 10,14 ---- { private readonly object[ ] state; ! private CacheEntry cacheEntry; private readonly object version; *************** *** 32,58 **** public override void Execute() { Persister.Insert( Id, state, Instance, Session ); Session.PostInsert( Instance ); ! /* ! if ( Persister.HasCache && Persister.IsCacheInvalidationRequired ) { cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Put( Id, cacheEntry ); } - */ } /// <summary></summary> ! public override void AfterTransactionCompletion() { // Make 100% certain that this is called before any subsequent ScheduledUpdate.AfterTransactionCompletion()!! ! /* ! if ( Persister.HasCache && Persister.IsCacheInvalidationRequired ) { - cacheEntry = new CacheEntry( Instance, Persister, Session ); Persister.Cache.AfterInsert( Id, cacheEntry, version ); } - */ } } --- 32,55 ---- public override void Execute() { + // Don't need to lock the cache here, since if someone + // else inserted the same pk first, the insert would fail Persister.Insert( Id, state, Instance, Session ); Session.PostInsert( Instance ); ! if ( Persister.HasCache && !Persister.IsCacheInvalidationRequired ) { cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Insert( Id, cacheEntry ); } } /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { // Make 100% certain that this is called before any subsequent ScheduledUpdate.AfterTransactionCompletion()!! ! if ( success && Persister.HasCache && !Persister.IsCacheInvalidationRequired ) { Persister.Cache.AfterInsert( Id, cacheEntry, version ); } } } Index: CollectionEntry.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/CollectionEntry.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CollectionEntry.cs 1 Mar 2005 16:24:46 -0000 1.7 --- CollectionEntry.cs 14 Mar 2005 18:52:52 -0000 1.8 *************** *** 93,96 **** --- 93,100 ---- internal ICollectionPersister currentPersister; + /// <summary></summary> + [NonSerialized] + internal object currentKey; + /// <summary> /// The <see cref="ICollectionPersister"/> when the Collection was loaded. *************** *** 103,110 **** internal ICollectionPersister loadedPersister; - /// <summary></summary> - [NonSerialized] - internal object currentKey; - /// <summary> /// The identifier of the Entity that is the owner of this Collection --- 107,110 ---- *************** *** 113,120 **** internal object loadedKey; ! /// <summary></summary> ! internal object snapshot; //session-start/post-flush persistent state ! /// <summary></summary> internal string role; --- 113,120 ---- internal object loadedKey; ! /// <summary>session-start/post-flush persistent state</summary> ! internal object snapshot; ! /// <summary>allow the snapshot to be serialized</summary> internal string role; *************** *** 128,131 **** --- 128,133 ---- public CollectionEntry() { + //a newly wrapped collection is NOT dirty (or we get unnecessary version updates) + this.dirty = false; // A newly wrapped collection is NOT dirty (or we get unnecessary version updates) //this.dirty = false; *************** *** 133,137 **** // New collections that get found and wrapped during flush shouldn't be ignored ! //this.ignore = false; } --- 135,139 ---- // New collections that get found and wrapped during flush shouldn't be ignored ! this.ignore = false; } *************** *** 151,157 **** public CollectionEntry( ICollectionPersister loadedPersister, object loadedID, bool ignore ) { ! // dirty & initialized are set to false by the runtime ! //this.dirty = false; ! //this.initialized = false; this.loadedKey = loadedID; SetLoadedPersister( loadedPersister ); --- 153,158 ---- public CollectionEntry( ICollectionPersister loadedPersister, object loadedID, bool ignore ) { ! this.dirty = false; ! this.initialized = false; this.loadedKey = loadedID; SetLoadedPersister( loadedPersister ); *************** *** 177,181 **** // Detached collections that get found and reattached during flush // shouldn't be ignored ! //this.ignore = false; SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); } --- 178,182 ---- // Detached collections that get found and reattached during flush // shouldn't be ignored ! this.ignore = false; SetLoadedPersister( factory.GetCollectionPersister( cs.Role ) ); } *************** *** 277,284 **** // 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 ) ) { ! InitSnapshot(collection, loadedPersister); } } --- 278,285 ---- // if it was initialized or any of the scheduled actions were performed then ! // need to resnapshot the contents of the collection. if( initialized && ( doremove || dorecreate || doupdate ) ) { ! InitSnapshot( collection, loadedPersister ); } } *************** *** 374,381 **** public bool IsNew { ! // TODO: is this correct implementation - h2.0.3 get { return initialized && ( snapshot == null ); } } } - } \ No newline at end of file --- 375,381 ---- public bool IsNew { ! // TODO: is this correct implementation get { return initialized && ( snapshot == null ); } } } } \ No newline at end of file Index: ScheduledCollectionAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionAction.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ScheduledCollectionAction.cs 6 Mar 2005 12:44:42 -0000 1.11 --- ScheduledCollectionAction.cs 14 Mar 2005 18:52:52 -0000 1.12 *************** *** 58,62 **** /// <summary></summary> ! public void AfterTransactionCompletion() { if ( persister.HasCache ) --- 58,63 ---- /// <summary></summary> ! /// <param name="success"></param> ! public void AfterTransactionCompletion( bool success ) { if ( persister.HasCache ) *************** *** 90,93 **** --- 91,105 ---- } + /// <summary> + /// + /// </summary> + protected void Evict( ) + { + if ( persister.HasCache ) + { + persister.Cache.Evict( id ); + } + } + /// <summary></summary> public object[ ] PropertySpaces Index: ScheduledEntityAction.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledEntityAction.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ScheduledEntityAction.cs 6 Mar 2005 12:44:42 -0000 1.9 --- ScheduledEntityAction.cs 14 Mar 2005 18:52:52 -0000 1.10 *************** *** 86,90 **** /// Called when the Transaction this action occurred in has completed. /// </summary> ! public abstract void AfterTransactionCompletion(); /// <summary> --- 86,91 ---- /// Called when the Transaction this action occurred in has completed. /// </summary> ! /// <param name="success"></param> ! public abstract void AfterTransactionCompletion( bool success ); /// <summary> Index: ScheduledUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledUpdate.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ScheduledUpdate.cs 6 Mar 2005 12:44:42 -0000 1.10 --- ScheduledUpdate.cs 14 Mar 2005 18:52:52 -0000 1.11 *************** *** 10,18 **** internal class ScheduledUpdate : ScheduledEntityAction { ! private object[ ] _fields; ! private object _lastVersion; ! private object _nextVersion; ! private int[ ] _dirtyFields; ! private object[ ] _updatedState; private ISoftLock _lock; --- 10,20 ---- internal class ScheduledUpdate : ScheduledEntityAction { ! private readonly object[] fields; ! private readonly object[] oldFields; ! private readonly object lastVersion; ! private readonly object nextVersion; ! private readonly int[ ] dirtyFields; ! private readonly object[ ] updatedState; ! private CacheEntry cacheEntry; private ISoftLock _lock; *************** *** 23,26 **** --- 25,29 ---- /// <param name="fields">An array of objects that contains the value of each Property.</param> /// <param name="dirtyProperties">An array that contains the indexes of the dirty Properties.</param> + /// <param name="oldFields"></param> /// <param name="lastVersion">The current version of the object.</param> /// <param name="nextVersion">The version the object should be after update.</param> *************** *** 29,40 **** /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledUpdate( object id, object[ ] fields, int[ ] dirtyProperties, object lastVersion, object nextVersion, object instance, object[ ] updatedState, IClassPersister persister, ISessionImplementor session ) : base( session, id, instance, persister ) { ! _fields = fields; ! _lastVersion = lastVersion; ! _nextVersion = nextVersion; ! _dirtyFields = dirtyProperties; ! _updatedState = updatedState; } --- 32,44 ---- /// <param name="persister">The <see cref="IClassPersister"/> that is responsible for the persisting the object.</param> /// <param name="session">The <see cref="ISessionImplementor"/> that the Action is occuring in.</param> ! public ScheduledUpdate( object id, object[ ] fields, int[ ] dirtyProperties, object[ ] oldFields, object lastVersion, object nextVersion, object instance, object[ ] updatedState, IClassPersister persister, ISessionImplementor session ) : base( session, id, instance, persister ) { ! this.fields = fields; ! this.oldFields = oldFields; ! this.lastVersion = lastVersion; ! this.nextVersion = nextVersion; ! this.dirtyFields = dirtyProperties; ! this.updatedState = updatedState; } *************** *** 44,59 **** if( Persister.HasCache ) { ! _lock = Persister.Cache.Lock( Id, _lastVersion ); } - Persister.Update( Id, _fields, _dirtyFields, _lastVersion, Instance, Session ); - Session.PostUpdate( Instance, _updatedState, _nextVersion ); } /// <summary></summary> ! public override void AfterTransactionCompletion() { if( Persister.HasCache ) { ! Persister.Cache.Release( Id, _lock ); } } --- 48,84 ---- if( Persister.HasCache ) { ! _lock = Persister.Cache.Lock( Id, lastVersion ); ! } ! Persister.Update( Id, fields, dirtyFields, oldFields, lastVersion, Instance, Session ); ! Session.PostUpdate( Instance, updatedState, nextVersion ); ! ! if ( Persister.HasCache ) ! { ! if ( Persister.IsCacheInvalidationRequired ) ! { ! Persister.Cache.Evict( Id ); ! } ! else ! { ! // TODO: Inefficient if that cache is just going to ignore the updated state! ! cacheEntry = new CacheEntry( Instance, Persister, Session ); ! Persister.Cache.Update( Id, cacheEntry ); ! } } } /// <summary></summary> ! public override void AfterTransactionCompletion( bool success ) { if( Persister.HasCache ) { ! if ( success && !Persister.IsCacheInvalidationRequired ) ! { ! Persister.Cache.AfterUpdate( Id, cacheEntry, nextVersion, _lock ); ! } ! else ! { ! Persister.Cache.Release( Id, _lock ); ! } } } Index: ScheduledCollectionUpdate.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionUpdate.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScheduledCollectionUpdate.cs 1 Mar 2005 16:24:46 -0000 1.8 --- ScheduledCollectionUpdate.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 34,41 **** public override void Execute() { - if ( Persister.HasCache ) - { - Persister.Cache.Remove( Id ); - } if( !_collection.WasInitialized ) { --- 34,37 ---- *************** *** 78,82 **** Persister.InsertRows( _collection, Id, Session ); } ! } } --- 74,78 ---- Persister.InsertRows( _collection, Id, Session ); } ! Evict(); } } Index: ScheduledCollectionRemove.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/ScheduledCollectionRemove.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ScheduledCollectionRemove.cs 6 Mar 2005 12:44:42 -0000 1.8 --- ScheduledCollectionRemove.cs 14 Mar 2005 18:52:52 -0000 1.9 *************** *** 30,39 **** public override void Execute() { - // TODO: 2.1 Remove this clause - if ( Persister.HasCache ) - { - Persister.Cache.Lock( Id, null ); - } - // 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. --- 30,33 ---- *************** *** 42,45 **** --- 36,40 ---- Persister.Remove( Id, Session ); } + Evict(); } } |
From: Paul H. <pha...@us...> - 2005-03-14 18:52:46
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6677/nhibernate/src/NHibernate/Hql Modified Files: QueryTranslator.cs WhereParser.cs Log Message: Refactored as per 2.1 Index: WhereParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/WhereParser.cs,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** WhereParser.cs 1 Mar 2005 16:24:46 -0000 1.29 --- WhereParser.cs 14 Mar 2005 18:52:35 -0000 1.30 *************** *** 462,465 **** --- 462,466 ---- if( persister != null ) // the name of a class { + // TODO: 2.1 - Use DiscriminatorSQLValue and compare to null/not null rather than DiscriminatorSQLString AppendToken( q, persister.DiscriminatorSQLString ); } Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** QueryTranslator.cs 1 Mar 2005 16:24:46 -0000 1.55 --- QueryTranslator.cs 14 Mar 2005 18:52:35 -0000 1.56 *************** *** 204,207 **** --- 204,213 ---- /// <summary></summary> + protected override int[] Owners + { + get { return owners; } + } + + /// <summary></summary> protected bool HasScalarValues { *************** *** 813,818 **** if( CollectionPersister != null ) { ! sql.AddSelectFragmentString( ((CollectionPersister) collectionPersister).MultiselectClauseFragment( fetchName ) ); ! //sql.AddSelectFragmentString( collectionPersister.SelectFragment( fetchName ) ); } if( hasScalars || shallowQuery ) --- 819,823 ---- if( CollectionPersister != null ) { ! sql.AddSelectFragmentString( collectionPersister.SelectFragment( fetchName ) ); } if( hasScalars || shallowQuery ) *************** *** 954,957 **** --- 959,963 ---- int c = 0; bool nolast = false; //real hacky... + int parenCount = 0; // used to count the nesting of parentheses foreach( object next in scalarSelectTokens ) { *************** *** 960,964 **** string token = ( string ) next; string lc = token.ToLower(); ! if( lc.Equals( StringHelper.CommaSpace ) ) { if( nolast ) --- 966,979 ---- string token = ( string ) next; string lc = token.ToLower(); ! ! if( StringHelper.OpenParen.Equals( token ) ) ! { ! parenCount++; ! } ! else if( StringHelper.ClosedParen.Equals( token ) ) ! { ! parenCount--; ! } ! else if( lc.Equals( StringHelper.CommaSpace ) ) { if( nolast ) *************** *** 968,972 **** else { ! if( !isSubselect ) { buf.Append( " as " ).Append( ScalarName( c++, 0 ) ); --- 983,987 ---- else { ! if( !isSubselect && parenCount == 0 ) { buf.Append( " as " ).Append( ScalarName( c++, 0 ) ); *************** *** 974,977 **** --- 989,993 ---- } } + buf.Append( token ); if( lc.Equals( "distinct" ) || lc.Equals( "all" ) ) *************** *** 1254,1257 **** --- 1270,1285 ---- /// /// </summary> + /// <param name="session"></param> + /// <param name="queryParameters"></param> + /// <returns></returns> + public IList List( ISessionImplementor session, QueryParameters queryParameters ) + { + LogQuery( queryString, sqlString.ToString() ); + return List( session, queryParameters, QuerySpaces, actualReturnTypes ); + } + + /// <summary> + /// + /// </summary> /// <param name="parameters"></param> /// <param name="session"></param> *************** *** 1261,1265 **** SqlString sqlWithLock = ApplyLocks( SqlString, parameters.LockModes, session.Factory.Dialect ); ! IDbCommand st = PrepareCommand( sqlWithLock, parameters, false, session ); --- 1289,1293 ---- SqlString sqlWithLock = ApplyLocks( SqlString, parameters.LockModes, session.Factory.Dialect ); ! IDbCommand st = PrepareQueryCommand( sqlWithLock, parameters, false, session ); *************** *** 1411,1414 **** --- 1439,1443 ---- + /* /// <summary> /// *************** *** 1422,1425 **** --- 1451,1455 ---- return base.Find( session, parameters, returnProxies ); } + */ /// <summary> *************** *** 1581,1585 **** } ! return sql.Append( updateClause.ToSqlStringFragment() ); } else --- 1611,1615 ---- } ! return sql.Append( updateClause.ToSqlStringFragment( dialect ) ); } else *************** *** 1647,1651 **** /// namedParams parameters. /// </remarks> ! protected override IDbCommand PrepareCommand( SqlString sqlString, QueryParameters parameters, bool scroll, ISessionImplementor session ) { lock( prepareCommandLock ) --- 1677,1681 ---- /// namedParams parameters. /// </remarks> ! protected override IDbCommand PrepareQueryCommand( SqlString sqlString, QueryParameters parameters, bool scroll, ISessionImplementor session ) { lock( prepareCommandLock ) *************** *** 1760,1764 **** } ! return base.PrepareCommand( this.sqlString, parameters, scroll, session ); } } --- 1790,1794 ---- } ! return base.PrepareQueryCommand( this.sqlString, parameters, scroll, session ); } } |
From: Paul H. <pha...@us...> - 2005-03-14 18:52:40
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6586/nhibernate/src/NHibernate/Engine Modified Files: Cascades.cs ISessionImplementor.cs Log Message: Refactored as per 2.1 Index: ISessionImplementor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ISessionImplementor.cs 6 Mar 2005 12:44:39 -0000 1.31 --- ISessionImplementor.cs 14 Mar 2005 18:52:11 -0000 1.32 *************** *** 38,48 **** /// <summary> - /// Set the "shallow dirty" status of the collection. Called when the collection detects - /// that the client is modifying it - /// </summary> - /// TODO: (2.1) This method no longer required. - void Dirty( PersistentCollection collection ); - - /// <summary> /// Initialize the collection (if not already initialized) /// </summary> --- 38,41 ---- *************** *** 59,81 **** /// <summary> ! /// new in h2.0.3 and no javadoc /// </summary> /// <param name="persister"></param> /// <param name="id"></param> /// <returns></returns> ! PersistentCollection GetLoadingCollection( ICollectionPersister persister, object id ); ! ! /// <summary> ! /// new in h2.0.3 and no javadoc ! /// </summary> ! /// <param name="role"></param> ! /// <param name="id"></param> ! /// <returns></returns> ! PersistentCollection GetLoadingCollection( String role, object id ); /// <summary> ! /// new in h2.0.3 and no javadoc /// </summary> ! void EndLoadingCollections(); /// <summary> --- 52,67 ---- /// <summary> ! /// new in h2.1 and no javadoc /// </summary> /// <param name="persister"></param> /// <param name="id"></param> + /// <param name="resultSetId"></param> /// <returns></returns> ! PersistentCollection GetLoadingCollection( ICollectionPersister persister, object id, object resultSetId ); /// <summary> ! /// new in h2.1 and no javadoc /// </summary> ! void EndLoadingCollections( ICollectionPersister persister, object resultSetId ); /// <summary> *************** *** 274,280 **** /// <summary> /// Notify the session that the transaction completed, so we no longer own the old locks. ! /// (Also we shold release cache softlocks). /// </summary> ! void AfterTransactionCompletion(); /// <summary> --- 260,267 ---- /// <summary> /// Notify the session that the transaction completed, so we no longer own the old locks. ! /// (Also we shold release cache softlocks). May be called multiple times during the transaction ! /// completion process. /// </summary> ! void AfterTransactionCompletion( bool successful ); /// <summary> Index: Cascades.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Engine/Cascades.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Cascades.cs 6 Mar 2005 12:44:38 -0000 1.17 --- Cascades.cs 14 Mar 2005 18:52:11 -0000 1.18 *************** *** 17,20 **** --- 17,21 ---- /// </summary> CascadeAfterInsertBeforeDelete = 1, + /// <summary> /// A cascade point that occurs just before the insertion of the parent entity *************** *** 22,25 **** --- 23,27 ---- /// </summary> CascadeBeforeInsertAfterDelete = 2, + /// <summary> /// A cascade point that occurs just after the insertion of the parent entity *************** *** 27,34 **** --- 29,38 ---- /// </summary> CascadeAfterInsertBeforeDeleteViaCollection = 3, + /// <summary> /// A cascade point that occurs just after the update of the parent entity /// </summary> CascadeOnUpdate = 0, + /// <summary> /// A cascade point that occurs just after eviction of the parent entity from the *************** *** 38,44 **** /// <summary> ! /// A cascade point that occurs just after locking the parent entity /// </summary> ! CascadeOnLock = 0 } --- 42,53 ---- /// <summary> ! /// A cascade point that occurs just after locking a transient parent entity into the session cache /// </summary> ! CascadeOnLock = 0, ! ! /// <summary> ! /// A cascade point that occurs just after copying from a transient parent entity into the object in the session cache ! /// </summary> ! CascadeOnCopy = 0 } *************** *** 71,79 **** /// <summary> ! /// Should this action be cascaded to the given (possibly unitilized) collection? /// </summary> ! public abstract bool ShouldCascadeCollection( object collection ); ! /// <summary></summary> public abstract bool DeleteOrphans(); --- 80,90 ---- /// <summary> ! /// The children to whom we should cascade. /// </summary> ! public abstract ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ); ! /// <summary> ! /// Do we need to handle orphan delete for this action? ! /// </summary> public abstract bool DeleteOrphans(); *************** *** 92,98 **** } ! public override bool ShouldCascadeCollection( object collection ) { ! return true; } --- 103,109 ---- } ! public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) { ! return Cascades.GetAllElementsCollection( collectionType, collection ); } *************** *** 104,120 **** /// <summary></summary> ! public static CascadingAction ActionEvict = new ActionEvictClass(); ! private class ActionEvictClass : CascadingAction { public override void Cascade( ISessionImplementor session, object child, object anything ) { ! log.Debug( "cascading to evict()" ); ! session.Evict( child ); } ! public override bool ShouldCascadeCollection( object collection ) { ! return CollectionIsInitialized( collection ); } --- 115,131 ---- /// <summary></summary> ! public static CascadingAction ActionLock = new ActionLockClass(); ! private class ActionLockClass : CascadingAction { public override void Cascade( ISessionImplementor session, object child, object anything ) { ! log.Debug( "cascading to lock()" ); ! session.Lock( child, (LockMode) anything ); } ! public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) { ! return Cascades.GetLoadedElementsCollection( collectionType, collection ); } *************** *** 126,142 **** /// <summary></summary> ! public static CascadingAction ActionLock = new ActionLockClass(); ! private class ActionLockClass : CascadingAction { public override void Cascade( ISessionImplementor session, object child, object anything ) { ! log.Debug( "cascading to lock()" ); ! session.Lock( child, (LockMode) anything ); } ! public override bool ShouldCascadeCollection( object collection ) { ! return CollectionIsInitialized( collection ); } --- 137,153 ---- /// <summary></summary> ! public static CascadingAction ActionEvict = new ActionEvictClass(); ! private class ActionEvictClass : CascadingAction { public override void Cascade( ISessionImplementor session, object child, object anything ) { ! log.Debug( "cascading to evict()" ); ! session.Evict( child ); } ! public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) { ! return Cascades.GetLoadedElementsCollection( collectionType, collection ); } *************** *** 158,165 **** } ! public override bool ShouldCascadeCollection( object collection ) { ! // saves/updates don't cascade to uninitialized collections ! return CollectionIsInitialized( collection ); } --- 169,175 ---- } ! public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) { ! return Cascades.GetLoadedElementsCollection( collectionType, collection ); } *************** *** 171,174 **** --- 181,208 ---- /// <summary></summary> + public static CascadingAction ActionCopy = new ActionCopyClass(); + + private class ActionCopyClass : CascadingAction + { + public override void Cascade( ISessionImplementor session, object child, object anything ) + { + log.Debug( "cascading to Replicate()" ); + // TODO: 2.1 implement copy + //session.Copy( child, (ReplicationMode) anything ); + } + + public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) + { + return Cascades.GetLoadedElementsCollection( collectionType, collection ); + } + + public override bool DeleteOrphans() + { + // orphans should not be deleted during copy??? + return false; + } + } + + /// <summary></summary> public static CascadingAction ActionReplicate = new ActionReplicateClass(); *************** *** 182,189 **** } ! public override bool ShouldCascadeCollection( object collection ) { ! // replicate does cascade to uninitialized collections ! return true; } --- 216,222 ---- } ! public override ICollection CascadableChildrenCollection( PersistentCollectionType collectionType, object collection ) { ! return Cascades.GetLoadedElementsCollection( collectionType, collection ); } *************** *** 193,201 **** } } ! private static bool CollectionIsInitialized( object collection ) ! { ! return !( collection is PersistentCollection ) || ( ( PersistentCollection ) collection ).WasInitialized; ! } } --- 226,234 ---- } } + } ! private static bool CollectionIsInitialized( object collection ) ! { ! return !( collection is PersistentCollection ) || ( ( PersistentCollection ) collection ).WasInitialized; } *************** *** 215,227 **** public abstract bool DoCascade( CascadingAction action ); ! //TODO: H2.0.3 - it looks like the CascadeStyle subclasses are defined outside of the CascadeStyle ! // class /// <summary> ! /// Save/Delete/Update/Evict + delete orphans /// </summary> ! public static CascadeStyle StyleAllGC = new StyleAllGCClass(); ! private class StyleAllGCClass : CascadeStyle { public override bool DoCascade( CascadingAction action ) --- 248,265 ---- public abstract bool DoCascade( CascadingAction action ); ! /// <summary> ! /// Do we delete orphans automatically? ! /// </summary> ! public virtual bool HasOrphanDelete ! { ! get { return false; } ! } /// <summary> ! /// Save / Delete / Update / Evict / Lock / Replicate + delete orphans /// </summary> ! public static CascadeStyle StyleAllDeleteOrphan = new StyleAllDeleteOrphanClass(); ! private class StyleAllDeleteOrphanClass : CascadeStyle { public override bool DoCascade( CascadingAction action ) *************** *** 229,236 **** return true; } } /// <summary> ! /// Save / Delete / Update / Evict /// </summary> public static CascadeStyle StyleAll = new StyleAllClass(); --- 267,279 ---- return true; } + + public override bool HasOrphanDelete + { + get { return true; } + } } /// <summary> ! /// Save / Delete / Update / Evict / Lock / Replicate /// </summary> public static CascadeStyle StyleAll = new StyleAllClass(); *************** *** 246,250 **** /// <summary> ! /// Save / Update /// </summary> public static CascadeStyle StyleSaveUpdate = new StyleSaveUpdateClass(); --- 289,293 ---- /// <summary> ! /// Save / Update / Lock / Replicate /// </summary> public static CascadeStyle StyleSaveUpdate = new StyleSaveUpdateClass(); *************** *** 254,260 **** public override bool DoCascade( CascadingAction action ) { ! return action == CascadingAction.ActionSaveUpdate ! || action == CascadingAction.ActionLock; ! // TODO: H2.1 also includes Copy and Replicate actions here } } --- 297,304 ---- public override bool DoCascade( CascadingAction action ) { ! return action == CascadingAction.ActionSaveUpdate || ! action == CascadingAction.ActionLock || ! action == CascadingAction.ActionReplicate || ! action == CascadingAction.ActionCopy; } } *************** *** 275,278 **** --- 319,340 ---- /// <summary> + /// Delete + delete orphans + /// </summary> + public static CascadeStyle StyleDeleteOrphan = new StyleDeleteOrphanClass(); + + private class StyleDeleteOrphanClass : CascadeStyle + { + public override bool DoCascade( CascadingAction action ) + { + return action == CascadingAction.ActionDelete; + } + + public override bool HasOrphanDelete + { + get { return true; } + } + } + + /// <summary> /// No Cascades /// </summary> *************** *** 283,287 **** public override bool DoCascade( CascadingAction action ) { ! return false; } } --- 345,349 ---- public override bool DoCascade( CascadingAction action ) { ! return action == CascadingAction.ActionReplicate; } } *************** *** 295,299 **** public class IdentifierValue { ! private object value; /// <summary></summary> --- 357,361 ---- public class IdentifierValue { ! private readonly object value; /// <summary></summary> *************** *** 369,374 **** } /// <summary> ! /// Cascade an action to the Child. /// </summary> /// <param name="session"></param> --- 431,529 ---- } + /// <summary> ! /// A strategy for determining if a version value is an version of ! /// a new transient instance or a previously persistent transient instance. ! /// The strategy is determined by the <c>Unsaved-Value</c> attribute in the mapping file. ! /// </summary> ! public class VersionValue ! { ! private readonly object value; ! ! /// <summary></summary> ! protected VersionValue() ! { ! this.value = null; ! } ! ! /// <summary> ! /// Assume the transient instance is newly instantiated if its version is null or ! /// equal to <c>Value</c> ! /// </summary> ! /// <param name="value"></param> ! public VersionValue( object value ) ! { ! this.value = value; ! } ! ! /// <summary> ! /// Does the given identifier belong to a new instance ! /// </summary> ! public virtual bool IsUnsaved( object version ) ! { ! if( log.IsDebugEnabled ) ! { ! log.Debug( "unsaved-value: " + value ); ! } ! return version == null || value.Equals( version ); ! } ! ! /// <summary> ! /// Assume the transient instance is newly instantiated if the version ! /// is null, otherwise assume it is a detached instance. ! /// </summary> ! public static VersionValue VersionNull = new VersionNullClass(); ! ! private class VersionNullClass : VersionValue ! { ! public override bool IsUnsaved( object version ) ! { ! log.Debug( "version unsaved-value strategy NULL" ); ! return version == null; ! } ! } ! ! /* ! /// <summary> ! /// Assume the transient instance is newly instantiated if the version ! /// is null, otherwise defer to the identifier unsaved-value. ! /// </summary> ! public static VersionValue VersionUndefined = new VersionUndefinedClass(); ! ! private class SaveNoneClass : IdentifierValue ! { ! public override bool IsUnsaved( object id ) ! { ! log.Debug( "version unsaved-value strategy UNDEFINED" ); ! return false; ! } ! } ! */ ! ! /// <summary> ! /// Assume the transient instance is newly instantiated if the identifier ! /// is null. ! /// </summary> ! public static VersionValue VersionNegative = new VersionNegativeClass(); ! ! private class VersionNegativeClass : VersionValue ! { ! public override bool IsUnsaved( object version ) ! { ! log.Debug( "version unsaved-value strategy NEGATIVE" ); ! if ( version is short || version is int || version is long ) ! { ! return (long) version < 1; ! } ! else ! { ! throw new MappingException( "unsaved-value strategy NEGATIVE may only be used with short, int and long types" ); ! } ! } ! } ! } ! ! /// <summary> ! /// Cascade an action to the child or children /// </summary> /// <param name="session"></param> *************** *** 376,383 **** /// <param name="type"></param> /// <param name="action"></param> /// <param name="cascadeTo"></param> - /// <param name="deleteOrphans"></param> /// <param name="anything"></param> ! private static void Cascade( ISessionImplementor session, object child, IType type, CascadingAction action, CascadePoint cascadeTo, bool deleteOrphans, object anything ) { if( child != null ) --- 531,545 ---- /// <param name="type"></param> /// <param name="action"></param> + /// <param name="style"></param> /// <param name="cascadeTo"></param> /// <param name="anything"></param> ! private static void Cascade( ! ISessionImplementor session, ! object child, ! IType type, ! CascadingAction action, ! CascadeStyle style, ! CascadePoint cascadeTo, ! object anything ) { if( child != null ) *************** *** 402,406 **** cascadeVia = cascadeTo; } - PersistentCollectionType pctype = ( PersistentCollectionType ) type; ICollectionPersister persister = session.Factory.GetCollectionPersister( pctype.Role ); --- 564,567 ---- *************** *** 408,463 **** // cascade to current collection elements ! ICollection iter; ! if( action.ShouldCascadeCollection( child ) ) ! { ! if( log.IsDebugEnabled ) ! { ! log.Debug( "cascading to collection: " + pctype.Role ); ! } ! iter = pctype.GetElementsCollection( child ); ! } ! else ! { ! //TODO: this hack assumes that shouldCascadeCollection() always ! // returns true for an initialized collection, which is corruption ! // of the semantics - what we need is to change ! // shouldCascadeCollection() to getCollectionCascadeIterator() ! if( child is PersistentCollection ) ! { ! PersistentCollection pc = ( PersistentCollection ) child; ! if( pc.HasQueuedAdds ) ! { ! iter = pc.QueuedAddsCollection; ! } ! else ! { ! iter = null; ! } ! } ! else ! { ! iter = null; ! } ! } ! if( iter != null ) ! { ! foreach( object obj in iter ) ! { ! Cascade( session, obj, elemType, action, cascadeVia, false, anything ); ! } ! } ! ! // handle oprhaned entities!! ! if( deleteOrphans && action.DeleteOrphans() && child is PersistentCollection ) { ! PersistentCollection pc = ( PersistentCollection ) child; ! if( pc.WasInitialized ) ! { ! ICollection orphanColl = session.GetOrphans( pc ); ! foreach( object obj in orphanColl ) ! { ! session.Delete( obj ); ! } ! } } } --- 569,575 ---- // cascade to current collection elements ! if ( elemType.IsEntityType || elemType.IsObjectType || elemType.IsComponentType ) { ! CascadeCollection( action, style, pctype, elemType, child, cascadeVia, session, anything ); } } *************** *** 471,477 **** for( int i = 0; i < types.Length; i++ ) { ! if( ctype.Cascade( i ).DoCascade( action ) ) { ! Cascade( session, children[ i ], types[ i ], action, cascadeTo, deleteOrphans, anything ); } } --- 583,590 ---- for( int i = 0; i < types.Length; i++ ) { ! CascadeStyle componentPropertyStyle = ctype.Cascade( i ); ! if( componentPropertyStyle.DoCascade( action ) ) { ! Cascade( session, children[ i ], types[ i ], action, componentPropertyStyle, cascadeTo, anything ); } } *************** *** 481,484 **** --- 594,610 ---- /// <summary> + /// + /// </summary> + /// <param name="session"></param> + /// <param name="persister"></param> + /// <param name="parent"></param> + /// <param name="action"></param> + /// <param name="cascadeTo"></param> + public static void Cascade( ISessionImplementor session, IClassPersister persister, object parent, CascadingAction action, CascadePoint cascadeTo ) + { + Cascade( session, persister, parent, action, cascadeTo, null ); + } + + /// <summary> /// Cascade an action from the parent object to all its children. /// </summary> *************** *** 501,507 **** for( int i = 0; i < types.Length; i++ ) { ! if( cascadeStyles[ i ].DoCascade( action ) ) { ! Cascade( session, persister.GetPropertyValue( parent, i ), types[ i ], action, cascadeTo, cascadeStyles[ i ] == CascadeStyle.StyleAllGC, anything ); } } --- 627,634 ---- for( int i = 0; i < types.Length; i++ ) { ! CascadeStyle style = cascadeStyles[ i ]; ! if( style.DoCascade( action ) ) { ! Cascade( session, persister.GetPropertyValue( parent, i ), types[ i ], action, style, cascadeTo, anything ); } } *************** *** 512,515 **** --- 639,716 ---- } } + + /// <summary> + /// Cascade to the collection elements + /// </summary> + /// <param name="action"></param> + /// <param name="style"></param> + /// <param name="collectionType"></param> + /// <param name="elemType"></param> + /// <param name="child"></param> + /// <param name="cascadeVia"></param> + /// <param name="session"></param> + /// <param name="anything"></param> + private static void CascadeCollection( + CascadingAction action, + CascadeStyle style, + PersistentCollectionType collectionType, + IType elemType, + object child, + CascadePoint cascadeVia, + ISessionImplementor session, + object anything ) + { + // cascade to current collection elements + if( log.IsDebugEnabled ) + { + log.Debug( "cascading to collection: " + collectionType.Role ); + } + ICollection iter = action.CascadableChildrenCollection( collectionType, child ); + foreach( object obj in iter ) + { + Cascade( session, obj, elemType, action, style, cascadeVia, anything ); + } + + // handle oprhaned entities!! + if( style.HasOrphanDelete && action.DeleteOrphans() && child is PersistentCollection ) + { + // We can do the cast since orphan-delete does not apply to: + // 1. newly instatiated collections + // 2. arrays ( we can't track orphans for detached arrays) + DeleteOrphans( child as PersistentCollection, session ); + } + } + + private static void DeleteOrphans( PersistentCollection pc, ISessionImplementor session ) + { + if( pc.WasInitialized ) // can't be any orphans if it was not initialized + { + ICollection orphanColl = session.GetOrphans( pc ); + foreach( object obj in orphanColl ) + { + session.Delete( obj ); + } + } + } + + internal static ICollection GetLoadedElementsCollection( PersistentCollectionType collectionType, object collection ) + { + if ( CollectionIsInitialized( collection ) ) + { + // handles arrays and newly instantiated collections + return collectionType.GetElementsCollection( collection ); + } + else + { + // does not handle arrays (that's ok, cos they can't be lazy) + // or newly instantiated collections so we can do the cast + return ( (PersistentCollection) collection).QueuedAddsCollection; + } + } + + internal static ICollection GetAllElementsCollection( PersistentCollectionType collectionType, object collection ) + { + return collectionType.GetElementsCollection( collection ); + } } } \ No newline at end of file |
From: Paul H. <pha...@us...> - 2005-03-14 18:52:10
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6406/nhibernate/src/NHibernate/Collection Modified Files: AbstractCollectionPersister.cs ArrayHolder.cs Bag.cs BasicCollectionPersister.cs IdentifierBag.cs List.cs Map.cs OneToManyPersister.cs PersistentCollection.cs Set.cs Log Message: Refactored as per 2.1 Index: OneToManyPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/OneToManyPersister.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OneToManyPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 --- OneToManyPersister.cs 14 Mar 2005 18:51:48 -0000 1.3 *************** *** 142,146 **** /// <param name="session"></param> /// <returns></returns> ! protected int DoUpdateRows( object id, PersistentCollection collection, ISessionImplementor session ) { // we finish all the "removes" first to take care of possible unique --- 142,146 ---- /// <param name="session"></param> /// <returns></returns> ! protected override int DoUpdateRows( object id, PersistentCollection collection, ISessionImplementor session ) { // we finish all the "removes" first to take care of possible unique *************** *** 236,241 **** { // Super impl will ignore suffix for collection columns! ! //return SelectFragment( alias ).Append( StringHelper.CommaSpace ); ! return SelectFragment( alias ); } else --- 236,240 ---- { // Super impl will ignore suffix for collection columns! ! return SelectFragment( alias ).Append( StringHelper.CommaSpace ).Append( ojl.SelectFragment( alias, suffix ) ); } else Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Map.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Map.cs 1 Mar 2005 16:24:44 -0000 1.21 --- Map.cs 14 Mar 2005 18:51:48 -0000 1.22 *************** *** 43,47 **** ArrayList result = new ArrayList( sn.Values.Count ); result.AddRange( sn.Values ); ! PersistentCollection.IdentityRemoveAll( result, map.Values, session ); return result; } --- 43,47 ---- ArrayList result = new ArrayList( sn.Values.Count ); result.AddRange( sn.Values ); ! PersistentCollection.IdentityRemoveAll( result, map.Values, Session ); return result; } *************** *** 61,65 **** foreach( DictionaryEntry entry in map ) { ! if( elementType.IsDirty( entry.Value, xmap[ entry.Key ], session ) ) { return false; --- 61,65 ---- foreach( DictionaryEntry entry in map ) { ! if( elementType.IsDirty( entry.Value, xmap[ entry.Key ], Session ) ) { return false; *************** *** 96,100 **** this.map = map; SetInitialized(); ! directlyAccessible = true; } --- 96,100 ---- this.map = map; SetInitialized(); ! DirectlyAccessible = true; } *************** *** 291,296 **** { DictionaryEntry e = ( DictionaryEntry ) entry; ! persister.WriteElement( st, e.Value, writeOrder, session ); ! persister.WriteIndex( st, e.Key, writeOrder, session ); } --- 291,296 ---- { DictionaryEntry e = ( DictionaryEntry ) entry; ! persister.WriteElement( st, e.Value, writeOrder, Session ); ! persister.WriteIndex( st, e.Key, writeOrder, Session ); } *************** *** 304,309 **** public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, session); ! object index = persister.ReadIndex( rs, session ); map[ index ] = element; --- 304,309 ---- public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, Session); ! object index = persister.ReadIndex( rs, Session ); map[ index ] = element; *************** *** 334,339 **** for( int i = 0; i < array.Length; i += 2 ) { ! map[ persister.IndexType.Assemble( array[ i ], session, owner ) ] = ! persister.ElementType.Assemble( array[ i + 1 ], session, owner ); } SetInitialized(); --- 334,339 ---- for( int i = 0; i < array.Length; i += 2 ) { ! map[ persister.IndexType.Assemble( array[ i ], Session, owner ) ] = ! persister.ElementType.Assemble( array[ i + 1 ], Session, owner ); } SetInitialized(); *************** *** 351,356 **** foreach( DictionaryEntry e in map ) { ! result[ i++ ] = persister.IndexType.Disassemble( e.Key, session ); ! result[ i++ ] = persister.ElementType.Disassemble( e.Value, session ); } return result; --- 351,356 ---- foreach( DictionaryEntry e in map ) { ! result[ i++ ] = persister.IndexType.Disassemble( e.Key, Session ); ! result[ i++ ] = persister.ElementType.Disassemble( e.Value, Session ); } return result; *************** *** 402,406 **** DictionaryEntry e = ( DictionaryEntry ) entry; object snValue = sn[ e.Key ]; ! return ( e.Value != null && snValue != null && elemType.IsDirty( snValue, e.Value, session ) ); } --- 402,406 ---- DictionaryEntry e = ( DictionaryEntry ) entry; object snValue = sn[ e.Key ]; ! return ( e.Value != null && snValue != null && elemType.IsDirty( snValue, e.Value, Session ) ); } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Set.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Set.cs 1 Mar 2005 16:24:44 -0000 1.26 --- Set.cs 14 Mar 2005 18:51:49 -0000 1.27 *************** *** 61,69 **** public override ICollection GetOrphans( object snapshot ) { IDictionary sn = ( IDictionary ) snapshot; ArrayList result = new ArrayList( sn.Keys.Count ); result.AddRange( sn.Keys ); ! PersistentCollection.IdentityRemoveAll( result, internalSet, session ); return result; } --- 61,73 ---- public override ICollection GetOrphans( object snapshot ) { + /* IDictionary sn = ( IDictionary ) snapshot; ArrayList result = new ArrayList( sn.Keys.Count ); result.AddRange( sn.Keys ); ! PersistentCollection.IdentityRemoveAll( result, internalSet, Session ); return result; + */ + IDictionary sn = ( IDictionary ) snapshot; + return PersistentCollection.GetOrphans( sn.Keys, internalSet, Session ); } *************** *** 84,88 **** { object oldValue = snapshot[ obj ]; ! if( oldValue == null || elementType.IsDirty( oldValue, obj, session ) ) { return false; --- 88,92 ---- { object oldValue = snapshot[ obj ]; ! if( oldValue == null || elementType.IsDirty( oldValue, obj, Session ) ) { return false; *************** *** 124,128 **** internalSet = collection; SetInitialized(); ! directlyAccessible = true; } --- 128,132 ---- internalSet = collection; SetInitialized(); ! DirectlyAccessible = true; } *************** *** 139,143 **** for( int i = 0; i < array.Length; i += 2 ) { ! internalSet.Add( persister.ElementType.Assemble( array[ i ], session, owner ) ); } SetInitialized(); --- 143,147 ---- for( int i = 0; i < array.Length; i += 2 ) { ! internalSet.Add( persister.ElementType.Assemble( array[ i ], Session, owner ) ); } SetInitialized(); *************** *** 391,395 **** public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); } --- 395,399 ---- public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, Session ); } *************** *** 403,407 **** public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, session); tempList.Add( element ); return element; --- 407,411 ---- public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, Session); tempList.Add( element ); return element; *************** *** 423,434 **** /// Set. /// </summary> ! public override void EndRead() { internalSet.AddAll( tempList ); tempList = null; SetInitialized(); ! // TODO: h2.1 synch to return bool instead of IsCacheable (NH specific code) ! IsCacheable = true; ! // return true; } --- 427,436 ---- /// Set. /// </summary> ! public override bool EndRead() { internalSet.AddAll( tempList ); tempList = null; SetInitialized(); ! return true; } *************** *** 453,457 **** foreach( object obj in internalSet ) { ! result[ i++ ] = persister.ElementType.Disassemble( obj, session ); } return result; --- 455,459 ---- foreach( object obj in internalSet ) { ! result[ i++ ] = persister.ElementType.Disassemble( obj, Session ); } return result; *************** *** 483,487 **** object oldKey = snapshot[ obj ]; ! if( oldKey != null && elemType.IsDirty( obj, oldKey, session ) ) { deletes.Add( obj ); --- 485,489 ---- object oldKey = snapshot[ obj ]; ! if( oldKey != null && elemType.IsDirty( obj, oldKey, Session ) ) { deletes.Add( obj ); *************** *** 507,511 **** // assuming the user implements equals() properly, as required by the Set // contract! ! return oldKey == null || elemType.IsDirty( oldKey, entry, session ); } --- 509,513 ---- // assuming the user implements equals() properly, as required by the Set // contract! ! return oldKey == null || elemType.IsDirty( oldKey, entry, Session ); } *************** *** 544,549 **** return true; } - - } } \ No newline at end of file --- 546,549 ---- Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/List.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** List.cs 1 Mar 2005 16:24:44 -0000 1.20 --- List.cs 14 Mar 2005 18:51:48 -0000 1.21 *************** *** 40,44 **** ArrayList result = new ArrayList( sn.Count ); result.AddRange( sn ); ! PersistentCollection.IdentityRemoveAll( result, list, session ); return result; } --- 40,44 ---- ArrayList result = new ArrayList( sn.Count ); result.AddRange( sn ); ! PersistentCollection.IdentityRemoveAll( result, list, Session ); return result; } *************** *** 58,62 **** for( int i = 0; i < list.Count; i++ ) { ! if( elementType.IsDirty( list[ i ], sn[ i ], session ) ) { return false; --- 58,62 ---- for( int i = 0; i < list.Count; i++ ) { ! if( elementType.IsDirty( list[ i ], sn[ i ], Session ) ) { return false; *************** *** 93,97 **** this.list = list; SetInitialized(); ! directlyAccessible = true; } --- 93,97 ---- this.list = list; SetInitialized(); ! DirectlyAccessible = true; } *************** *** 301,306 **** public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); ! persister.WriteIndex( st, i, writeOrder, session ); } --- 301,306 ---- public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, Session ); ! persister.WriteIndex( st, i, writeOrder, Session ); } *************** *** 314,319 **** public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, session); ! int index = (int)persister.ReadIndex( rs, session ); for( int i=list.Count; i<=index; i++ ) --- 314,319 ---- public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, Session); ! int index = (int)persister.ReadIndex( rs, Session ); for( int i=list.Count; i<=index; i++ ) *************** *** 344,348 **** for( int i = 0; i < array.Length; i++ ) { ! list.Add( persister.ElementType.Assemble( array[ i ], session, owner ) ); } SetInitialized(); --- 344,348 ---- for( int i = 0; i < array.Length; i++ ) { ! list.Add( persister.ElementType.Assemble( array[ i ], Session, owner ) ); } SetInitialized(); *************** *** 360,364 **** for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( list[ i ], session ); } return result; --- 360,364 ---- for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( list[ i ], Session ); } return result; *************** *** 420,424 **** { IList sn = ( IList ) GetSnapshot(); ! return i < sn.Count && sn[ i ] != null && list[ i ] != null && elemType.IsDirty( list[ i ], sn[ i ], session ); } --- 420,424 ---- { IList sn = ( IList ) GetSnapshot(); ! return i < sn.Count && sn[ i ] != null && list[ i ] != null && elemType.IsDirty( list[ i ], sn[ i ], Session ); } Index: ArrayHolder.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/ArrayHolder.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ArrayHolder.cs 1 Mar 2005 16:24:44 -0000 1.18 --- ArrayHolder.cs 14 Mar 2005 18:51:48 -0000 1.19 *************** *** 84,88 **** for( int i = 0; i < sn.Length; i++ ) { ! PersistentCollection.IdentityRemove( result, arr[ i ], session ); } return result; --- 84,88 ---- for( int i = 0; i < sn.Length; i++ ) { ! PersistentCollection.IdentityRemove( result, arr[ i ], Session ); } return result; *************** *** 135,139 **** for( int i = 0; i < xlen; i++ ) { ! if( elementType.IsDirty( snapshot.GetValue( i ), array.GetValue( i ), session ) ) { return false; --- 135,139 ---- for( int i = 0; i < xlen; i++ ) { ! if( elementType.IsDirty( snapshot.GetValue( i ), array.GetValue( i ), Session ) ) { return false; *************** *** 177,182 **** public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); ! persister.WriteIndex( st, i, writeOrder, session ); } --- 177,182 ---- public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, Session ); ! persister.WriteIndex( st, i, writeOrder, Session ); } *************** *** 190,195 **** public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, session); ! int index = ( int ) persister.ReadIndex( rs, session ); for( int i = tempList.Count; i <= index; i++ ) { --- 190,195 ---- public override object ReadFrom( IDataReader rs, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement(rs, owner, Session); ! int index = ( int ) persister.ReadIndex( rs, Session ); for( int i = tempList.Count; i <= index; i++ ) { *************** *** 224,228 **** /// array. /// </summary> ! public override void EndRead() { SetInitialized(); --- 224,228 ---- /// array. /// </summary> ! public override bool EndRead() { SetInitialized(); *************** *** 236,242 **** tempList = null; ! // TODO: h2.1 synch to return bool instead of IsCacheable (NH specific code) ! IsCacheable = true; ! //return true; } --- 236,240 ---- tempList = null; ! return true; } *************** *** 279,283 **** for( int i = 0; i < cached.Length; i++ ) { ! array.SetValue( persister.ElementType.Assemble( cached[ i ], session, owner ), i ); } SetInitialized(); --- 277,281 ---- for( int i = 0; i < cached.Length; i++ ) { ! array.SetValue( persister.ElementType.Assemble( cached[ i ], Session, owner ), i ); } SetInitialized(); *************** *** 295,299 **** for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( array.GetValue( i ), session ); } return result; --- 293,297 ---- for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( array.GetValue( i ), Session ); } return result; *************** *** 371,375 **** sn.GetValue( i ) != null && array.GetValue( i ) != null && ! elemType.IsDirty( array.GetValue( i ), sn.GetValue( i ), session ); } --- 369,373 ---- sn.GetValue( i ) != null && array.GetValue( i ) != null && ! elemType.IsDirty( array.GetValue( i ), sn.GetValue( i ), Session ); } Index: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/Bag.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Bag.cs 1 Mar 2005 16:24:44 -0000 1.15 --- Bag.cs 14 Mar 2005 18:51:48 -0000 1.16 *************** *** 42,46 **** SetInitialized(); ! directlyAccessible = true; } --- 42,46 ---- SetInitialized(); ! DirectlyAccessible = true; } *************** *** 91,95 **** public override object ReadFrom( IDataReader reader, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement( reader, owner, session ); bag.Add( element ); return element; --- 91,95 ---- public override object ReadFrom( IDataReader reader, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement( reader, owner, Session ); bag.Add( element ); return element; *************** *** 106,110 **** public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); } --- 106,110 ---- public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, Session ); } *************** *** 188,192 **** ArrayList result = new ArrayList(); result.AddRange( sn ); ! PersistentCollection.IdentityRemoveAll( result, bag, session ); return result; } --- 188,192 ---- ArrayList result = new ArrayList(); result.AddRange( sn ); ! PersistentCollection.IdentityRemoveAll( result, bag, Session ); return result; } *************** *** 204,208 **** for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( bag[ i ], session ); } --- 204,208 ---- for( int i = 0; i < length; i++ ) { ! result[ i ] = persister.ElementType.Disassemble( bag[ i ], Session ); } *************** *** 222,226 **** for( int i = 0; i < array.Length; i++ ) { ! bag.Add( persister.ElementType.Assemble( array[ i ], session, owner ) ); } SetInitialized(); --- 222,226 ---- for( int i = 0; i < array.Length; i++ ) { ! bag.Add( persister.ElementType.Assemble( array[ i ], Session, owner ) ); } SetInitialized(); *************** *** 545,550 **** return entry != null; } - - } } \ No newline at end of file --- 545,548 ---- Index: BasicCollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/BasicCollectionPersister.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BasicCollectionPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 --- BasicCollectionPersister.cs 14 Mar 2005 18:51:48 -0000 1.3 *************** *** 146,150 **** /// <param name="session"></param> /// <returns></returns> ! protected int DoUpdateRows( object id, PersistentCollection collection, ISessionImplementor session ) { try --- 146,150 ---- /// <param name="session"></param> /// <returns></returns> ! protected override int DoUpdateRows( object id, PersistentCollection collection, ISessionImplementor session ) { try *************** *** 164,173 **** st = session.Batcher.PrepareBatchCommand( SqlUpdateRowString ); } - WriteKey( st, id, false, session ); if ( !HasIdentifier ) { WriteKey( st, id, true, session ); } ! collection.WriteTo( st, this, entry, i, false ); session.Batcher.AddToBatch( 1 ); count++; --- 164,172 ---- st = session.Batcher.PrepareBatchCommand( SqlUpdateRowString ); } if ( !HasIdentifier ) { WriteKey( st, id, true, session ); } ! collection.WriteTo( st, this, entry, i, true ); session.Batcher.AddToBatch( 1 ); count++; *************** *** 235,240 **** public override SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) { ! // TODO: Changed from Null to SqlString( string.Empty ) as per Java ! return includeCollectionColumns ? SelectFragment( alias ) : new SqlString( string.Empty ) ; } } --- 234,238 ---- public override SqlString SelectFragment( string alias, string suffix, bool includeCollectionColumns ) { ! return includeCollectionColumns ? SelectFragment( alias ) : null ; } } Index: AbstractCollectionPersister.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/AbstractCollectionPersister.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractCollectionPersister.cs 8 Mar 2005 16:26:12 -0000 1.2 --- AbstractCollectionPersister.cs 14 Mar 2005 18:51:45 -0000 1.3 *************** *** 382,386 **** public string GetSQLWhereString( string alias ) { ! if( sqlWhereStringTemplate != null ) { return StringHelper.Replace( sqlWhereStringTemplate, Template.Placeholder, alias ); --- 382,386 ---- public string GetSQLWhereString( string alias ) { ! if( hasWhere ) { return StringHelper.Replace( sqlWhereStringTemplate, Template.Placeholder, alias ); *************** *** 929,1036 **** /// /// </summary> - /// <param name="id"></param> - /// <param name="collection"></param> - /// <param name="session"></param> - public void Update( object id, PersistentCollection collection, ISessionImplementor session ) - { - IDbCommand st = null; - ICollection entries = collection.Entries(); - int i = 0; - try - { - foreach( object entry in entries ) - { - if( collection.NeedsUpdating( entry, i, elementType ) ) - { - if( st == null ) - { - st = session.Batcher.PrepareBatchCommand( SqlUpdateRowString ); - } - if( !hasIdentifier ) - { - WriteKey( st, id, true, session ); - } - collection.WriteTo( st, this, entry, i, true ); - session.Batcher.AddToBatch( 1 ); - } - i++; - } - } - // TODO: change to SqlException - catch( Exception e ) - { - session.Batcher.AbortBatch( e ); - throw; - } - } - - /// <summary> - /// - /// </summary> - /// <param name="id"></param> - /// <param name="collection"></param> - /// <param name="session"></param> - public void UpdateOneToMany( object id, PersistentCollection collection, ISessionImplementor session ) - { - IDbCommand rmvst = null; - int i = 0; - ICollection entries = collection.Entries(); - try - { - foreach( object entry in entries ) - { - if( collection.NeedsUpdating( entry, i, elementType ) ) - { - if( rmvst == null ) - { - rmvst = session.Batcher.PrepareBatchCommand( SqlDeleteRowString ); - } - WriteKey( rmvst, id, false, session ); - WriteIndex( rmvst, collection.GetIndex( entry, i ), false, session ); - session.Batcher.AddToBatch( -1 ); - } - i++; - } - } - // TODO: change to SqlException - catch( Exception e ) - { - session.Batcher.AbortBatch( e ); - throw; - } - - // finish all the removes first to take care of possible unique constraints - // and so that we can take advantage of batching - IDbCommand insst = null; - i = 0; - entries = collection.Entries(); - try - { - foreach( object entry in entries ) - { - if( collection.NeedsUpdating( entry, i, elementType ) ) - { - if( insst == null ) - { - insst = session.Batcher.PrepareBatchCommand( SqlInsertRowString ); - } - WriteKey( insst, id, false, session ); - collection.WriteTo( insst, this, entry, i, false ); - session.Batcher.AddToBatch( 1 ); - } - i++; - } - } - //TODO: change to SqlException - catch( Exception e ) - { - session.Batcher.AbortBatch( e ); - throw; - } - } - - /// <summary> - /// - /// </summary> /// <param name="collection"></param> /// <param name="id"></param> --- 929,932 ---- *************** *** 1042,1061 **** if( log.IsDebugEnabled ) { ! log.Debug( "Updating rows of collection: " + role + "#" + id ); } // update all the modified entries ! if( IsOneToMany ) ! { ! UpdateOneToMany( id, collection, session ); ! } ! else ! { ! Update( id, collection, session ); ! } if( log.IsDebugEnabled ) { ! log.Debug( "done updating rows" ); } } --- 938,950 ---- if( log.IsDebugEnabled ) { ! log.Debug( string.Format( "Updating rows of collection: {0}#{1}", role, id ) ); } // update all the modified entries ! int count = DoUpdateRows( id, collection, session ); if( log.IsDebugEnabled ) { ! log.Debug( string.Format( "done updating rows: {0} updated", count ) ); } } *************** *** 1065,1068 **** --- 954,966 ---- /// /// </summary> + /// <param name="key"></param> + /// <param name="collection"></param> + /// <param name="session"></param> + /// <returns></returns> + protected abstract int DoUpdateRows( object key, PersistentCollection collection, ISessionImplementor session ); + + /// <summary> + /// + /// </summary> /// <param name="collection"></param> /// <param name="id"></param> *************** *** 1085,1095 **** try { foreach( object entry in entries ) { - // This is as per the java, don't get the logic of this, it will be reinitialised each time round the loop anyway - IDbCommand st = null; if( collection.NeedsInserting( entry, i, elementType ) ) { - // This is as per the java, don't get the logic of this, it will be reinitialised each time round the loop anyway if( st == null ) { --- 983,992 ---- try { + // Moved the IDbCommand outside the loop otherwise, don't get the logic of this, it will be reinitialised each time round + IDbCommand st = null; foreach( object entry in entries ) { if( collection.NeedsInserting( entry, i, elementType ) ) { if( st == null ) { *************** *** 1258,1262 **** { SelectFragment frag = new SelectFragment( factory.Dialect ) ! .SetSuffix( String.Empty ) .AddColumns( alias, keyColumnNames, keyColumnAliases ) .AddColumns( alias, elementColumnNames, elementColumnAliases ); --- 1155,1159 ---- { SelectFragment frag = new SelectFragment( factory.Dialect ) ! .SetSuffix( String.Empty ) //always ignore suffix for collection columns .AddColumns( alias, keyColumnNames, keyColumnAliases ) .AddColumns( alias, elementColumnNames, elementColumnAliases ); Index: PersistentCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/PersistentCollection.cs,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PersistentCollection.cs 1 Mar 2005 16:24:44 -0000 1.22 --- PersistentCollection.cs 14 Mar 2005 18:51:49 -0000 1.23 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using System.Data; + using Iesi.Collections; using log4net; using NHibernate.Engine; *************** *** 10,14 **** /// <summary> /// Persistent collections are treated as value objects by Hibernate. ! /// ie. they have no independent existence beyond the object holding /// a reference to them. Unlike instances of entity classes, they are /// automatically deleted when unreferenced and automatically become --- 11,15 ---- /// <summary> /// Persistent collections are treated as value objects by Hibernate. ! /// i.e. they have no independent existence beyond the object holding /// a reference to them. Unlike instances of entity classes, they are /// automatically deleted when unreferenced and automatically become *************** *** 41,49 **** /// <summary></summary> [NonSerialized] ! protected ISessionImplementor session; ! /// <summary></summary> ! protected bool initialized; ! private bool initializing; [NonSerialized] --- 42,48 ---- /// <summary></summary> [NonSerialized] ! private ISessionImplementor session; ! private bool initialized; [NonSerialized] *************** *** 54,58 **** /// <summary></summary> [NonSerialized] ! protected bool directlyAccessible; //careful: these methods do not initialize the collection --- 53,60 ---- /// <summary></summary> [NonSerialized] ! private bool directlyAccessible; ! ! [NonSerialized] ! private bool initializing; //careful: these methods do not initialize the collection *************** *** 64,68 **** public abstract bool Empty { get; } ! /// <summary></summary> public void Read() { --- 66,72 ---- public abstract bool Empty { get; } ! /// <summary> ! /// Called by any read-only method of the collection interface ! /// </summary> public void Read() { *************** *** 70,73 **** --- 74,86 ---- } + /// <summary></summary> + protected ISessionImplementor Session + { + get { return session; } + } + + /// <summary> + /// Is the collection currently connected to an open session? + /// </summary> private bool IsConnectedToSession { *************** *** 76,107 **** /// <summary></summary> protected void Write() { Initialize( true ); ! if( IsConnectedToSession ) ! { ! session.Dirty( this ); ! } ! else ! { ! collectionSnapshot.SetDirty(); ! } } ! private bool MayQueueAdd { ! get { ! return ! !initialized && ! IsConnectedToSession && ! session.IsInverseCollection( this ); } } ! /// <summary></summary> protected bool QueueAdd( object element ) { ! if( MayQueueAdd ) { if( additions == null ) --- 89,125 ---- /// <summary></summary> + protected bool DirectlyAccessible + { + set { directlyAccessible = value; } + } + + /// <summary> + /// Called by any writer method of the collection interface + /// </summary> protected void Write() { Initialize( true ); ! collectionSnapshot.SetDirty(); } ! /// <summary> ! /// Is this collection in a state that would allow us to "queue" additions? ! /// </summary> ! private bool IsQueueAdditionEnabled { ! get { ! return !initialized && ! IsConnectedToSession && ! session.IsInverseCollection( this ); } } ! /// <summary> ! /// Queue an addition ! /// </summary> protected bool QueueAdd( object element ) { ! if( IsQueueAdditionEnabled ) { if( additions == null ) *************** *** 110,114 **** } additions.Add( element ); ! session.Dirty( this ); //needed so that we remove this collection from the JCS cache return true; } --- 128,132 ---- } additions.Add( element ); ! collectionSnapshot.SetDirty(); //needed so that we remove this collection from the JCS cache return true; } *************** *** 119,126 **** } ! /// <summary></summary> protected bool QueueAddAll( ICollection coll ) { ! if( MayQueueAdd ) { if( additions == null ) --- 137,146 ---- } ! /// <summary> ! /// Queue additions ! /// </summary> protected bool QueueAddAll( ICollection coll ) { ! if( IsQueueAdditionEnabled ) { if( additions == null ) *************** *** 137,143 **** } - //TODO: H2.0.3 new method /// <summary> ! /// /// </summary> /// <param name="coll"></param> --- 157,163 ---- } /// <summary> ! /// After reading all existing elements from the database, ! /// add the queued elements to the underlying collection. /// </summary> /// <param name="coll"></param> *************** *** 148,151 **** --- 168,172 ---- // TODO: h2.0.3 synhc - I don't see AddAll in the H code... + // NB This is needed by Set/SortedSet to fulfil ISet contract /// <summary> /// *************** *** 166,170 **** { get { return additions; } - set { additions = value; } } --- 187,190 ---- *************** *** 186,190 **** /// <summary> ! /// /// </summary> /// <param name="session"></param> --- 206,217 ---- /// <summary> ! /// Not called by Hibernate, but used by non-NET serialization, eg. SOAP libraries. ! /// </summary> ! public PersistentCollection() ! { ! } ! ! /// <summary> ! /// Not called by Hibernate, but used by non-NET serialization, eg. SOAP libraries. /// </summary> /// <param name="session"></param> *************** *** 208,220 **** } - /* - /// <summary></summary> - public virtual object GetCachedValue() - { - initialized = true; //TODO: only needed for query FETCH so should move out of here - return this; - } - */ - /// <summary> /// Override on some subclasses --- 235,238 ---- *************** *** 233,288 **** /// to store values read from the db. /// </p> - /// <p> - /// This is also responsible for determining if the collection is cacheable by - /// setting the property <see cref="IsCacheable"/>. When NH is synched with h2.1 - /// this method will be changed to return that bool instead of setting the property, - /// but this accomplishes the same thing until then. - /// </p> /// </remarks> ! public virtual void EndRead() { - // TODO:SYNCH:hib2.1 has this return a bool SetInitialized(); //do this bit after setting initialized to true or it will recurse ! if (additions!=null) { ! DelayedAddAll(additions); ! additions=null; ! // can't cache the collection because it contains additions that are ! // not in the database - those additions can't be put in the cache ! // because they might throw TransientObjectExceptions when attempting ! // to get their database identifier. ! IsCacheable = false; ! //return false; } else { ! // nothing happened that would prevent this collection from being safe ! // to cache. ! IsCacheable = true; ! //return true; } } - private bool _isCacheable; - - /// <summary> - /// Gets or sets a boolean indicating if this collection can be put into the - /// cache. - /// </summary> - /// <remarks> - /// This is a method new to NHibernate and is in here until the Loader design - /// can get synched up with h2.1's loader design. In h2.1 the <c>EndRead()</c> - /// method returns a bool that is used by the ISession to determine wether or - /// not the Collection can go in cache. Right now, the only thing that can keep - /// a collection from being cached is if Delayed Adds are supported - ie, adding - /// items to the collection without fully initializing it. - /// </remarks> - internal bool IsCacheable - { - get { return _isCacheable; } - set { _isCacheable = value; } - } - /// <summary> /// Initialize the collection, if possible, wrapping any exceptions in a runtime exception --- 251,271 ---- /// to store values read from the db. /// </p> /// </remarks> ! public virtual bool EndRead() { SetInitialized(); //do this bit after setting initialized to true or it will recurse ! if ( additions != null ) { ! DelayedAddAll( additions ); ! additions = null; ! return false; } else { ! return true; } } /// <summary> /// Initialize the collection, if possible, wrapping any exceptions in a runtime exception *************** *** 321,324 **** --- 304,316 ---- /// <summary> + /// Mark the collection as initialized. + /// </summary> + protected void SetInitialized() + { + initializing = false; + initialized = true; + } + + /// <summary> /// /// </summary> *************** *** 414,418 **** public abstract object ReadFrom( IDataReader reader, ICollectionPersister role, object owner ); - /* /// <summary> /// --- 406,409 ---- *************** *** 424,441 **** /// <param name="writeOrder"></param> public abstract void WriteTo( IDbCommand st, ICollectionPersister role, object entry, int i, bool writeOrder ); - */ - - /// <summary> - /// - /// </summary> - /// <param name="st"></param> - /// <param name="role"></param> - /// <param name="entry"></param> - /// <param name="i"></param> - /// <param name="writeOrder"></param> - /// <remarks>This is the 2.1 version, should be abstract, but trying to avoid lots of cascading changes</remarks> - public virtual void WriteTo( IDbCommand st, ICollectionPersister role, object entry, int i, bool writeOrder ) - { - } /// <summary> --- 415,418 ---- *************** *** 518,522 **** if( session == null ) throw new HibernateException("collection is not associated with any session"); if( !session.IsConnected ) throw new HibernateException("disconnected session"); ! if( !initialized ) session.InitializeCollection(this, false); } --- 495,499 ---- if( session == null ) throw new HibernateException("collection is not associated with any session"); if( !session.IsConnected ) throw new HibernateException("disconnected session"); ! if( !initialized ) session.InitializeCollection( this, false ); } *************** *** 576,580 **** public ICollection QueuedAddsCollection { ! get { return additions; } } --- 553,567 ---- public ICollection QueuedAddsCollection { ! get ! { ! if ( HasQueuedAdds ) ! { ! return additions; ! } ! else ! { ! return new ArrayList(); ! } ! } } *************** *** 586,604 **** } - // looks like it is used by IdentifierBag - /// <summary> - /// By default, no operation is performed. This provides a hook to get an identifer of the - /// collection row for <see cref="IdentifierBag"/>. - /// </summary> - /// <param name="persister">The <see cref="ICollectionPersister"/> for this Collection.</param> - /// <param name="entry"> - /// The entry to preInsert. If this is a Map this will be a DictionaryEntry. If this is - /// a List then it will be the object at that index. - /// </param> - /// <param name="i">The index of the Entry while enumerating through the Collection.</param> - public virtual void PreInsert( ICollectionPersister persister, object entry, int i ) - { - } - /// <summary> /// Called before inserting rows, to ensure that any surrogate keys are fully generated --- 573,576 ---- *************** *** 620,624 **** /// <summary> ! /// /// </summary> /// <param name="snapshot"></param> --- 592,596 ---- /// <summary> ! /// Get all "orphaned" elements /// </summary> /// <param name="snapshot"></param> *************** *** 644,647 **** --- 616,666 ---- /// /// </summary> + /// <param name="oldElements"></param> + /// <param name="currentElements"></param> + /// <param name="session"></param> + /// <returns></returns> + protected static ICollection GetOrphans( ICollection oldElements, ICollection currentElements, ISessionImplementor session ) + { + // short-circuit(s) + if ( currentElements.Count == 0 ) + { + // no new elements, the old list contains only Orphans + return oldElements; + } + if ( oldElements.Count == 0 ) + { + // no old elements, so no Orphans neither + return oldElements; + } + + // create the collection holding the orphans + IList res = new ArrayList(); + + // collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access + ISet currentIds = new HashedSet(); + foreach ( object current in currentElements ) + { + if ( session.IsSaved( current ) ) + { + currentIds.Add( session.GetEntityIdentifierIfNotUnsaved( current ) ); + } + } + + // iterate over the *old* list + foreach ( object old in oldElements ) + { + object id = session.GetEntityIdentifierIfNotUnsaved( old ); + if ( !currentIds.Contains( id ) ) + { + res.Add( old ); + } + } + + return res; + } + + /// <summary> + /// + /// </summary> /// <param name="list"></param> /// <param name="obj"></param> *************** *** 673,685 **** } - /// <summary> - /// Mark the collection as initialized. - /// </summary> - protected void SetInitialized() - { - initializing = false; - initialized = true; - } - #region - Hibernate Collection Proxy Classes --- 692,695 ---- Index: IdentifierBag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Collection/IdentifierBag.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IdentifierBag.cs 1 Mar 2005 16:24:44 -0000 1.10 --- IdentifierBag.cs 14 Mar 2005 18:51:48 -0000 1.11 *************** *** 26,33 **** public class IdentifierBag : PersistentCollection, IList { ! private IList values; ! ! // TODO: h2.1 changed this to index->id, haven't made that change in nh yet. ! private IDictionary identifiers; //element -> id /// <summary> --- 26,31 ---- public class IdentifierBag : PersistentCollection, IList { ! private IList values; //element ! private IDictionary identifiers; //index -> id /// <summary> *************** *** 48,52 **** IList list = coll as IList; ! if( list!=null ) { values = list; --- 46,50 ---- IList list = coll as IList; ! if( list != null ) { values = list; *************** *** 62,66 **** SetInitialized(); ! directlyAccessible = true; identifiers = new Hashtable(); } --- 60,64 ---- SetInitialized(); ! DirectlyAccessible = true; identifiers = new Hashtable(); } *************** *** 74,78 **** public override void InitializeFromCache( ICollectionPersister persister, object disassembled, object owner ) { - BeforeInitialize( persister ); object[ ] array = ( object[ ] ) disassembled; --- 72,75 ---- *************** *** 80,86 **** for( int i = 0; i < array.Length; i += 2 ) { ! object obj = persister.ElementType.Assemble( array[ i + 1 ], session, owner ); ! identifiers[ obj ] = persister.IdentifierType.Assemble( array[ i ], session, owner ); ! values.Add( obj ); } --- 77,84 ---- for( int i = 0; i < array.Length; i += 2 ) { ! //object obj = persister.ElementType.Assemble( array[ i + 1 ], session, owner ); ! //identifiers[ obj ] = persister.IdentifierType.Assemble( array[ i ], session, owner ); ! identifiers[ i / 2 ] = persister.IdentifierType.Assemble( array[ i ], Session, owner ); ! values.Add( persister.ElementType.Assemble( array[ i + 1 ], Session, owner ) ); } *************** *** 266,276 **** public override object Disassemble( ICollectionPersister persister ) { ! object[ ] result = new object[values.Count*2]; int i = 0; ! foreach( object obj in values ) { ! result[ i++ ] = persister.IdentifierType.Disassemble( identifiers[ obj ], session ); ! result[ i++ ] = persister.ElementType.Disassemble( obj, session ); } --- 264,275 ---- public override object Disassemble( ICollectionPersister persister ) { ! object[ ] result = new object[ values.Count * 2 ]; int i = 0; ! for( int j = 0; j < values.Count; j++ ) { ! object val = values[ j ]; ! result[ i++ ] = persister.IdentifierType.Disassemble( identifiers[ j ], Session ); ! result[ i++ ] = persister.ElementType.Disassemble( val, Session ); } *************** *** 320,327 **** } ! int i = 0; ! foreach( object obj in values ) { ! object id = identifiers[ i++ ]; if( id == null ) { --- 319,326 ---- } ! for( int i = 0; i < values.Count; i++ ) { ! object val = values[ i ]; ! object id = identifiers[ i ]; if( id == null ) { *************** *** 330,334 **** object old = snap[ id ]; ! if( elementType.IsDirty( old, obj, session ) ) { return false; --- 329,333 ---- object old = snap[ id ]; ! if( elementType.IsDirty( old, val, Session ) ) { return false; *************** *** 337,341 **** return true; - } --- 336,339 ---- *************** *** 350,359 **** IList deletes = new ArrayList( snap.Keys ); ! int i = 0; ! foreach( object obj in values ) { ! if( obj != null ) { ! deletes.Remove( identifiers[ i++ ] ); } } --- 348,356 ---- IList deletes = new ArrayList( snap.Keys ); ! for( int i = 0; i < values.Count; i++ ) { ! if( values[ i ] != null ) { ! deletes.Remove( identifiers[ i ] ); } } *************** *** 410,414 **** object old = snap[ id ]; ! return entry != null && old != null && elemType.IsDirty( old, entry, session ); } --- 407,411 ---- object old = snap[ id ]; ! return old != null && elemType.IsDirty( old, entry, Session ); } *************** *** 422,428 **** public override object ReadFrom( IDataReader reader, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement( reader, owner, session ); values.Add( element ); ! identifiers[ values.Count - 1 ] = persister.ReadIdentifier( reader, session ); return element; } --- 419,425 ---- public override object ReadFrom( IDataReader reader, ICollectionPersister persister, object owner ) { ! object element = persister.ReadElement( reader, owner, Session ); values.Add( element ); ! identifiers[ values.Count - 1 ] = persister.ReadIdentifier( reader, Session ); return element; } *************** *** 454,457 **** --- 451,455 ---- public override ICollection GetOrphans( object snapshot ) { + /* IDictionary sn = ( IDictionary ) GetSnapshot(); ArrayList result = new ArrayList(); *************** *** 459,462 **** --- 457,463 ---- PersistentCollection.IdentityRemoveAll( result, values, session ); return result; + */ + + return PersistentCollection.GetOrphans( ( ( IDictionary ) snapshot).Values, values, Session ); } *************** *** 465,481 **** /// </summary> /// <param name="persister"></param> ! /// <param name="entry"></param> ! /// <param name="i"></param> ! public override void PreInsert( ICollectionPersister persister, object entry, int i ) { try { ! object id = persister.IdentifierGenerator.Generate( session, entry ); ! // TODO: native ids ! identifiers[ i ] = id; } catch( Exception sqle ) { ! throw new ADOException( "Could not generate collection row id.", sqle ); } } --- 466,487 ---- /// </summary> /// <param name="persister"></param> ! public override void PreInsert( ICollectionPersister persister ) { try { ! int i = 0; ! foreach( object entry in values ) ! { ! int loc = i++; ! if( !identifiers.Contains( loc ) ) // TODO: native ids ! { ! object id = persister.IdentifierGenerator.Generate( Session, entry ); ! identifiers[ loc ] = id; ! } ! } } catch( Exception sqle ) { ! throw new ADOException( "Could not generate idbag row id.", sqle ); } } *************** *** 491,499 **** public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, session ); ! persister.WriteIdentifier( st, identifiers[ i ], writeOrder, session ); } - - } } \ No newline at end of file --- 497,504 ---- public override void WriteTo( IDbCommand st, ICollectionPersister persister, object entry, int i, bool writeOrder ) { ! persister.WriteElement( st, entry, writeOrder, Session ); ! // TODO: if not using identity columns: ! persister.WriteIdentifier( st, identifiers[ i ], writeOrder, Session ); } } } \ No newline at end of file |
From: Paul H. <pha...@us...> - 2005-03-14 16:53:27
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5013/nhibernate/src/NHibernate/Impl Modified Files: FlushVisitor.cs WrapVisitor.cs Log Message: Update visitors to 2.1 standards Index: FlushVisitor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/FlushVisitor.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FlushVisitor.cs 7 Feb 2005 01:34:40 -0000 1.2 --- FlushVisitor.cs 14 Mar 2005 16:53:17 -0000 1.3 *************** *** 1,3 **** --- 1,4 ---- using System; + using log4net; using NHibernate.Collection; using NHibernate.Type; *************** *** 8,11 **** --- 9,13 ---- { private object _owner; + private static readonly ILog log = LogManager.GetLogger( typeof( AbstractVisitor ) ); public FlushVisitor(SessionImpl session, object owner) *************** *** 17,20 **** --- 19,27 ---- protected override object ProcessCollection(object collection, PersistentCollectionType type) { + if( log.IsDebugEnabled ) + { + log.Debug( string.Format( "Processing collection for role {0}", type.Role ) ); + } + if( collection != null ) { Index: WrapVisitor.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/WrapVisitor.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WrapVisitor.cs 1 Mar 2005 16:24:47 -0000 1.4 --- WrapVisitor.cs 14 Mar 2005 16:53:17 -0000 1.5 *************** *** 28,34 **** protected override object ProcessCollection(object collection, PersistentCollectionType collectionType) { ! PersistentCollection coll = collection as PersistentCollection; ! if( coll!=null ) { if( coll.SetCurrentSession( Session ) ) { --- 28,34 ---- protected override object ProcessCollection(object collection, PersistentCollectionType collectionType) { ! if( collection != null && (collection is PersistentCollection) ) { + PersistentCollection coll = collection as PersistentCollection; if( coll.SetCurrentSession( Session ) ) { *************** *** 36,40 **** } return null; - } else --- 36,39 ---- |