Skip to content

Commit 964680f

Browse files
author
Sergey Koshcheyev
committed
Added SynchronizedTables property
SVN: trunk@2192
1 parent 74f2127 commit 964680f

File tree

3 files changed

+56
-30
lines changed

3 files changed

+56
-30
lines changed

src/NHibernate/Mapping/PersistentClass.cs

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using NHibernate.Engine;
66
using NHibernate.SqlCommand;
77
using NHibernate.Util;
8+
using Iesi.Collections;
89

910
namespace NHibernate.Mapping
1011
{
@@ -52,6 +53,8 @@ public abstract class PersistentClass
5253

5354
private string loaderName;
5455

56+
protected readonly ISet synchronizedTablesField = new HashedSet();
57+
5558
/// <summary>
5659
/// Gets or Sets if the Insert Sql is built dynamically.
5760
/// </summary>
@@ -750,5 +753,12 @@ public void SetCustomSQLUpdate(string sql, bool callable, ExecuteUpdateResultChe
750753
customUpdateCallable = callable;
751754
updateCheckStyle = checkStyle;
752755
}
756+
757+
public abstract ISet SynchronizedTables { get; }
758+
759+
public void AddSynchronizedTable(string table)
760+
{
761+
synchronizedTablesField.Add(table);
762+
}
753763
}
754764
}

src/NHibernate/Mapping/RootClass.cs

+5
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,10 @@ public override void Validate( IMapping mapping )
340340
throw new MappingException( string.Format( "identifier mapping has wrong number of columns: {0} type: {1}", MappedClass.Name, Identifier.Type.Name ) );
341341
}
342342
}
343+
344+
public override Iesi.Collections.ISet SynchronizedTables
345+
{
346+
get { return synchronizedTablesField; }
347+
}
343348
}
344349
}

src/NHibernate/Mapping/Subclass.cs

+41-30
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using NHibernate.Cache;
44
using NHibernate.Engine;
5+
using Iesi.Collections;
56

67
namespace NHibernate.Mapping
78
{
@@ -19,7 +20,7 @@ public class Subclass : PersistentClass
1920
/// Initializes a new instance of the <see cref="Subclass"/> class.
2021
/// </summary>
2122
/// <param name="superclass">The <see cref="PersistentClass"/> that is the superclass.</param>
22-
public Subclass( PersistentClass superclass )
23+
public Subclass(PersistentClass superclass)
2324
{
2425
this.superclass = superclass;
2526
}
@@ -65,7 +66,7 @@ public override System.Type ClassPersisterClass
6566
{
6667
get
6768
{
68-
if ( classPersisterClass == null )
69+
if (classPersisterClass == null)
6970
{
7071
return Superclass.ClassPersisterClass;
7172
}
@@ -156,9 +157,9 @@ public override bool IsPolymorphic
156157
get { return true; }
157158
set
158159
{
159-
if( value!=true )
160+
if (value != true)
160161
{
161-
throw new AssertionFailure( "IsPolymorphic has to be true for subclasses. There is a bug in NHibernate somewhere." );
162+
throw new AssertionFailure("IsPolymorphic has to be true for subclasses. There is a bug in NHibernate somewhere.");
162163
}
163164
}
164165
}
@@ -171,10 +172,10 @@ public override bool IsPolymorphic
171172
/// This also adds the <see cref="Property"/> to the Superclass' collection
172173
/// of Subclass Properties.
173174
/// </remarks>
174-
public override void AddProperty( Property p )
175+
public override void AddProperty(Property p)
175176
{
176-
base.AddProperty( p );
177-
Superclass.AddSubclassProperty( p );
177+
base.AddProperty(p);
178+
Superclass.AddSubclassProperty(p);
178179
}
179180

180181
/// <summary>
@@ -191,7 +192,7 @@ public override Table Table
191192
set
192193
{
193194
base.Table = value;
194-
Superclass.AddSubclassTable( value );
195+
Superclass.AddSubclassTable(value);
195196
}
196197
}
197198

@@ -211,8 +212,8 @@ public override ICollection PropertyClosureCollection
211212
get
212213
{
213214
ArrayList retVal = new ArrayList();
214-
retVal.AddRange( PropertyCollection );
215-
retVal.AddRange( Superclass.PropertyClosureCollection );
215+
retVal.AddRange(PropertyCollection);
216+
retVal.AddRange(Superclass.PropertyClosureCollection);
216217
return retVal;
217218
}
218219
}
@@ -234,8 +235,8 @@ public override ICollection TableClosureCollection
234235
get
235236
{
236237
ArrayList retVal = new ArrayList();
237-
retVal.AddRange( Superclass.TableClosureCollection );
238-
retVal.Add( Table );
238+
retVal.AddRange(Superclass.TableClosureCollection);
239+
retVal.Add(Table);
239240
return retVal;
240241
}
241242
}
@@ -248,10 +249,10 @@ public override ICollection TableClosureCollection
248249
/// This also adds the <see cref="Property"/> to the Superclass' collection
249250
/// of Subclass Properties.
250251
/// </remarks>
251-
public override void AddSubclassProperty( Property p )
252+
public override void AddSubclassProperty(Property p)
252253
{
253-
base.AddSubclassProperty( p );
254-
Superclass.AddSubclassProperty( p );
254+
base.AddSubclassProperty(p);
255+
Superclass.AddSubclassProperty(p);
255256
}
256257

257258
/// <summary>
@@ -262,10 +263,10 @@ public override void AddSubclassProperty( Property p )
262263
/// This also adds the <see cref="Table"/> to the Superclass' collection
263264
/// of Subclass Tables.
264265
/// </remarks>
265-
public override void AddSubclassTable( Table table )
266+
public override void AddSubclassTable(Table table)
266267
{
267-
base.AddSubclassTable( table );
268-
Superclass.AddSubclassTable( table );
268+
base.AddSubclassTable(table);
269+
Superclass.AddSubclassTable(table);
269270
}
270271

271272
/// <summary>
@@ -323,7 +324,7 @@ public override SimpleValue Key
323324
{
324325
get
325326
{
326-
if( key == null )
327+
if (key == null)
327328
{
328329
return Identifier;
329330
}
@@ -360,7 +361,7 @@ public override bool IsExplicitPolymorphism
360361
public override string Where
361362
{
362363
get { return Superclass.Where; }
363-
set { throw new InvalidOperationException( "The Where string can not be set on the Subclass - use the RootClass instead." ); }
364+
set { throw new InvalidOperationException("The Where string can not be set on the Subclass - use the RootClass instead."); }
364365
}
365366

366367
/// <summary>
@@ -376,40 +377,50 @@ public override bool IsJoinedSubclass
376377
/// </summary>
377378
public override bool IsDiscriminatorInsertable
378379
{
379-
get { return Superclass.IsDiscriminatorInsertable ; }
380-
set { throw new InvalidOperationException( "The DiscriminatorInsertable property can not be set on the Subclass - use the Superclass instead." ); }
380+
get { return Superclass.IsDiscriminatorInsertable; }
381+
set { throw new InvalidOperationException("The DiscriminatorInsertable property can not be set on the Subclass - use the Superclass instead."); }
381382
}
382383

383384
/// <summary>
384385
///
385386
/// </summary>
386387
/// <param name="mapping"></param>
387-
public override void Validate( IMapping mapping )
388+
public override void Validate(IMapping mapping)
388389
{
389-
base.Validate( mapping );
390-
if ( Key != null && !Key.IsValid( mapping ) )
390+
base.Validate(mapping);
391+
if (Key != null && !Key.IsValid(mapping))
391392
{
392-
throw new MappingException( string.Format( "subclass key has wrong number of columns: {0} type: {1}", MappedClass.Name, Key.Type.Name ) );
393+
throw new MappingException(string.Format("subclass key has wrong number of columns: {0} type: {1}", MappedClass.Name, Key.Type.Name));
393394
}
394395
}
395396

396397
/// <summary>
397398
///
398399
/// </summary>
399-
public void CreateForeignKey( )
400+
public void CreateForeignKey()
400401
{
401-
if ( !IsJoinedSubclass )
402+
if (!IsJoinedSubclass)
402403
{
403-
throw new AssertionFailure( "Not a joined-subclass" );
404+
throw new AssertionFailure("Not a joined-subclass");
404405
}
405406

406-
Key.CreateForeignKeyOfClass( Superclass.MappedClass );
407+
Key.CreateForeignKeyOfClass(Superclass.MappedClass);
407408
}
408409

409410
public override int PropertyClosureSpan
410411
{
411412
get { return Superclass.PropertyClosureSpan + base.PropertyClosureSpan; }
412413
}
413414

415+
public override ISet SynchronizedTables
416+
{
417+
get
418+
{
419+
HashedSet result = new HashedSet();
420+
result.AddAll(synchronizedTablesField);
421+
result.AddAll(Superclass.SynchronizedTables);
422+
return result;
423+
}
424+
}
414425
}
415426
}

0 commit comments

Comments
 (0)