Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5548/nhibernate/src/NHibernate/Mapping Modified Files: Any.cs Array.cs Association.cs Bag.cs Collection.cs Component.cs IdentifierBag.cs IdentifierCollection.cs IndexedCollection.cs IntegerValue.cs List.cs ManyToOne.cs Map.cs OneToMany.cs OneToOne.cs PersistentClass.cs Property.cs RootClass.cs Set.cs Subclass.cs Table.cs Value.cs Added Files: IFetchable.cs IValue.cs MetaAttribute.cs NamedSQLQuery.cs SimpleValue.cs ToOne.cs Log Message: Various refactorings on the way to 2.1 querying capability Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PersistentClass.cs 6 Jan 2005 14:19:59 -0000 1.18 --- PersistentClass.cs 1 Mar 2005 16:24:49 -0000 1.19 *************** *** 2,6 **** --- 2,8 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; using NHibernate.SqlCommand; + using NHibernate.Util; namespace NHibernate.Mapping *************** *** 15,21 **** private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! private System.Type persistentClass; private string discriminatorValue; ! private ArrayList properties = new ArrayList(); private Table table; private System.Type proxyInterface; --- 17,32 ---- private static readonly Alias PKAlias = new Alias( 15, "PK" ); ! /// <summary> ! /// ! /// </summary> ! public static readonly string NullDiscriminatorMapping = "null"; ! /// <summary> ! /// ! /// </summary> ! public static readonly string NotNullDiscriminatorMapping = "not null"; ! ! private System.Type mappedClass; private string discriminatorValue; ! private Hashtable properties = new Hashtable(); private Table table; private System.Type proxyInterface; *************** *** 25,28 **** --- 36,43 ---- private bool dynamicInsert; private bool dynamicUpdate; + private int batchSize = 1; + //private bool selectBeforeUpdate; + //private int optimisticLockMode; + //private IDictionary metaAttributes; /// <summary> *************** *** 75,78 **** --- 90,103 ---- public virtual void AddSubclass( Subclass subclass ) { + // Inheritable cycle detection (paranoid check) + PersistentClass superclass = Superclass; + while ( superclass != null ) + { + if ( subclass.Name == superclass.Name ) + { + throw new MappingException( string.Format( "Circular inheritance mapping detected {0} will have itself as superclass when extending {1}", subclass.Name, Name ) ); + } + superclass = superclass.Superclass; + } subclasses.Add( subclass ); } *************** *** 146,149 **** --- 171,190 ---- /// <summary> + /// + /// </summary> + /// <param name="p"></param> + public void AddNewProperty( Property p ) + { + if ( properties.Contains( p.Name ) ) + { + throw new MappingException( string.Format( "Duplication mapping for property: {0}", StringHelper.Qualify( Name, p.Name ) ) ); + } + else + { + AddProperty( p ); + } + } + + /// <summary> /// Add the <see cref="Property"/> to this PersistentClass. /// </summary> *************** *** 151,155 **** public virtual void AddProperty( Property p ) { ! properties.Add( p ); } --- 192,196 ---- public virtual void AddProperty( Property p ) { ! properties.Add( p.Name, p ); } *************** *** 175,179 **** public virtual ICollection PropertyCollection { ! get { return properties; } } --- 216,220 ---- public virtual ICollection PropertyCollection { ! get { return properties.Values; } } *************** *** 186,193 **** /// element. /// </remarks> ! public virtual System.Type PersistentClazz { ! get { return persistentClass; } ! set { persistentClass = value; } } --- 227,234 ---- /// element. /// </remarks> ! public virtual System.Type MappedClass { ! get { return mappedClass; } ! set { mappedClass = value; } } *************** *** 198,202 **** public virtual string Name { ! get { return persistentClass.FullName; } } --- 239,243 ---- public virtual string Name { ! get { return mappedClass.FullName; } } *************** *** 228,236 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the identifier.</value> ! public abstract Value Identifier { get; set; } /// <summary> --- 269,277 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the identifier.</value> ! public abstract SimpleValue Identifier { get; set; } /// <summary> *************** *** 242,250 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the discriminator.</value> ! public abstract Value Discriminator { get; set; } /// <summary> --- 283,291 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the discriminator.</value> ! public abstract SimpleValue Discriminator { get; set; } /// <summary> *************** *** 413,416 **** --- 454,473 ---- /// <summary> + /// + /// </summary> + public bool IsDiscriminatorValueNotNull + { + get { return NotNullDiscriminatorMapping.Equals( DiscriminatorValue ); } + } + + /// <summary> + /// + /// </summary> + public bool IsDiscriminatorValueNull + { + get { return NullDiscriminatorMapping.Equals( DiscriminatorValue ); } + } + + /// <summary> /// When implemented by a class, gets or sets a boolean indicating if the identifier is /// embedded in the class. *************** *** 425,434 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="System.Type"/> of ! /// the Persister. /// </summary> ! /// <value>The <see cref="System.Type"/> of the Persister.</value> ! /// <remarks>The value of this is set by the <c>persister</c> attribute.</remarks> ! public abstract System.Type Persister { get; set; } /// <summary> --- 482,488 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="System.Type"/> of the Persister. /// </summary> ! public abstract System.Type ClassPersisterClass { get; set; } /// <summary> *************** *** 451,459 **** /// <summary> ! /// When implemented by a class, gets or sets the <see cref="Value"/> /// that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public abstract Value Key { get; set; } /// <summary> --- 505,513 ---- /// <summary> ! /// When implemented by a class, gets or sets the <see cref="SimpleValue"/> /// that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public abstract SimpleValue Key { get; set; } /// <summary> *************** *** 476,479 **** --- 530,542 ---- /// <summary> + /// + /// </summary> + public int BatchSize + { + get { return batchSize; } + set { batchSize = value; } + } + + /// <summary> /// When implemented by a class, gets or sets the sql string that should /// be a part of the where clause. *************** *** 487,490 **** --- 550,577 ---- public abstract string Where { get; set; } + /// <summary> + /// + /// </summary> + public abstract bool IsJoinedSubclass { get; } + + /// <summary> + /// + /// </summary> + public abstract bool IsDiscriminatorInsertable { get; set; } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public virtual void Validate( IMapping mapping ) + { + foreach( Mapping.Property prop in PropertyCollection ) + { + if ( !prop.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "property mapping has wrong number of columns: {0} type: {1}", StringHelper.Qualify( MappedClass.Name, Name ), prop.Type.Name ) ) ; + } + } + } } } \ No newline at end of file Index: ManyToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ManyToOne.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ManyToOne.cs 31 Dec 2004 21:27:30 -0000 1.4 --- ManyToOne.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 5,9 **** { /// <summary></summary> ! public class ManyToOne : Association { /// <summary> --- 5,9 ---- { /// <summary></summary> ! public class ManyToOne : ToOne { /// <summary> *************** *** 38,42 **** public override void CreateForeignKey() { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).PersistentClass ); } } --- 38,46 ---- public override void CreateForeignKey() { ! // TODO: Handle the case of a foreign key to something other than the pk ! if ( ReferencedPropertyName == null ) ! { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).AssociatedClass ); ! } } } Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Map.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Map.cs 14 Feb 2005 03:37:27 -0000 1.7 --- Map.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 15,19 **** /// <summary></summary> ! public override PersistentCollectionType Type { get --- 15,19 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get --- NEW FILE: IFetchable.cs --- using NHibernate.Loader; namespace NHibernate.Mapping { /// <summary> /// Any mapping with an outer-join attribute /// </summary> public interface IFetchable { /// <summary> /// /// </summary> OuterJoinFetchStrategy OuterJoinFetchSetting { get; set; } } } Index: Property.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Property.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Property.cs 31 Dec 2004 21:27:54 -0000 1.10 --- Property.cs 1 Mar 2005 16:24:49 -0000 1.11 *************** *** 10,18 **** { private string name; ! private Value propertyValue; private string cascade; ! private bool updateable; ! private bool insertable; private string propertyAccessorName; /// <summary> --- 10,26 ---- { private string name; ! private IValue propertyValue; private string cascade; ! private bool updateable = true; ! private bool insertable = true; private string propertyAccessorName; + private IDictionary metaAttributes; + + /// <summary> + /// + /// </summary> + public Property( ) + { + } /// <summary> *************** *** 20,24 **** /// </summary> /// <param name="propertyValue"></param> ! public Property( Value propertyValue ) { this.propertyValue = propertyValue; --- 28,32 ---- /// </summary> /// <param name="propertyValue"></param> ! public Property( IValue propertyValue ) { this.propertyValue = propertyValue; *************** *** 70,74 **** /// <summary></summary> ! public Value Value { get { return propertyValue; } --- 78,82 ---- /// <summary></summary> ! public IValue Value { get { return propertyValue; } *************** *** 153,156 **** --- 161,171 ---- /// <summary></summary> + public bool IsNullable + { + // Approximate + get { return propertyValue != null && propertyValue.IsNullable; } + } + + /// <summary></summary> public string PropertyAccessorName { *************** *** 190,193 **** --- 205,234 ---- get { return propertyAccessorName == null || propertyAccessorName.Equals( "property" ); } } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + /// <returns></returns> + public bool IsValid( IMapping mapping ) + { + return IsFormula ? ColumnSpan == 0 : Value.IsValid( mapping ); + } + + /// <summary> + /// + /// </summary> + public string NullValue + { + get + { + if ( propertyValue is SimpleValue ) + { + return ( (SimpleValue) propertyValue).NullValue; + } + else + return null; + } + } } } \ No newline at end of file Index: Value.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Value.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Value.cs 31 Dec 2004 21:28:13 -0000 1.10 --- Value.cs 1 Mar 2005 16:24:49 -0000 1.11 *************** *** 145,151 **** /// <summary></summary> ! public virtual OuterJoinLoaderType OuterJoinFetchSetting { ! get { return OuterJoinLoaderType.Lazy; } set { throw new NotSupportedException(); } } --- 145,151 ---- /// <summary></summary> ! public virtual OuterJoinFetchStrategy OuterJoinFetchSetting { ! get { return OuterJoinFetchStrategy.Lazy; } set { throw new NotSupportedException(); } } Index: OneToMany.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToMany.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneToMany.cs 31 Dec 2004 21:27:30 -0000 1.4 --- OneToMany.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 1,2 **** --- 1,5 ---- + using System.Collections; + using NHibernate.Engine; + using NHibernate.Loader; using NHibernate.Type; *************** *** 4,14 **** { /// <summary></summary> ! public class OneToMany { private EntityType type; private Table referencingTable; /// <summary></summary> ! public EntityType Type { get { return type; } --- 7,18 ---- { /// <summary></summary> ! public class OneToMany : IValue { private EntityType type; private Table referencingTable; + private PersistentClass associatedClass; /// <summary></summary> ! public EntityType EntityType { get { return type; } *************** *** 26,33 **** --- 30,113 ---- /// <summary></summary> + public ICollection ColumnCollection + { + get { return associatedClass.Key.ColumnCollection; } + } + + /// <summary></summary> + public int ColumnSpan + { + get { return associatedClass.Key.ColumnSpan; } + } + + /// <summary></summary> public Table ReferencingTable { get { return referencingTable; } } + + /// <summary></summary> + public IType Type + { + get { return type; } + set { type = (EntityType) value; } + } + + /// <summary></summary> + public PersistentClass AssociatedClass + { + get { return associatedClass; } + set { associatedClass = value; } + } + + /// <summary></summary> + public Formula Formula + { + get { return null; } + } + + /// <summary></summary> + public Table Table + { + get { return referencingTable; } + } + + /// <summary></summary> + public bool IsNullable + { + get { return false; } + } + + /// <summary></summary> + public bool IsSimpleValue + { + get { return false; } + } + + /// <summary></summary> + public bool IsUnique + { + get { return false; } + } + + /// <summary></summary> + public bool IsValid( IMapping mapping ) + { + return true; + } + + /// <summary></summary> + public OuterJoinFetchStrategy OuterJoinFetchSetting + { + get { return OuterJoinFetchStrategy.Eager; } + } + + /// <summary> + /// + /// </summary> + /// <remarks>No foreign key element for a one-to-many</remarks> + public void CreateForeignKey( ) + { + } } } \ No newline at end of file --- NEW FILE: MetaAttribute.cs --- using System; using System.Collections; namespace NHibernate.Mapping { /// <summary> /// A meta attribute is a named value or values. /// </summary> public class MetaAttribute { private string name; private IList values; /// <summary> /// /// </summary> public MetaAttribute() { values = new ArrayList(); } /// <summary> /// /// </summary> public string Name { get { return name; } set { name = value; } } /// <summary> /// /// </summary> public IList Values { get { return values; } } /// <summary> /// /// </summary> public string Value { get { if ( values.Count != 1 ) { throw new ArgumentException( "No unique value" ); } return (string) values[0]; } } /// <summary> /// /// </summary> public bool IsMultiValued { get { return values.Count > 1; } } /// <summary> /// /// </summary> /// <param name="value"></param> public void AddValue( string value ) { values.Add( value ); } } } Index: RootClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/RootClass.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RootClass.cs 3 Jan 2005 03:46:48 -0000 1.12 --- RootClass.cs 1 Mar 2005 16:24:49 -0000 1.13 *************** *** 27,41 **** private Property identifierProperty; ! private Value identifier; private Property version; private bool polymorphic; private ICacheConcurrencyStrategy cache; ! private Value discriminator; private bool mutable; private bool embeddedIdentifier = false; private bool explicitPolymorphism; ! private System.Type persister; private bool forceDiscriminator; private string where; /// <summary> --- 27,42 ---- private Property identifierProperty; ! private SimpleValue identifier; private Property version; private bool polymorphic; private ICacheConcurrencyStrategy cache; ! private SimpleValue discriminator; private bool mutable; private bool embeddedIdentifier = false; private bool explicitPolymorphism; ! private System.Type classPersisterClass; private bool forceDiscriminator; private string where; + private bool discriminatorInsertable; /// <summary> *************** *** 52,59 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the identifier.</value> ! public override Value Identifier { get { return identifier; } --- 53,60 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the identifier.</value> ! public override SimpleValue Identifier { get { return identifier; } *************** *** 71,78 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the discriminator.</value> ! public override Value Discriminator { get { return discriminator; } --- 72,79 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the discriminator.</value> ! public override SimpleValue Discriminator { get { return discriminator; } *************** *** 235,242 **** /// </summary> /// <value>The <see cref="System.Type"/> of the Persister.</value> ! public override System.Type Persister { ! get { return persister; } ! set { persister = value; } } --- 236,243 ---- /// </summary> /// <value>The <see cref="System.Type"/> of the Persister.</value> ! public override System.Type ClassPersisterClass { ! get { return classPersisterClass; } ! set { classPersisterClass = value; } } *************** *** 270,277 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public override Value Key { get { return Identifier; } --- 271,278 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public override SimpleValue Key { get { return Identifier; } *************** *** 302,305 **** --- 303,322 ---- } + /// <summary> + /// + /// </summary> + public override bool IsJoinedSubclass + { + get { return false; } + } + + /// <summary> + /// + /// </summary> + public override bool IsDiscriminatorInsertable + { + get { return discriminatorInsertable; } + set { discriminatorInsertable = value; } + } } } \ No newline at end of file --- NEW FILE: NamedSQLQuery.cs --- using System; using System.Collections; namespace NHibernate.Mapping { /// <summary> /// Simple holder for named sql queries /// </summary> public class NamedSQLQuery { private string query; private ArrayList aliasedClasses; private ArrayList synchronizedTables; private ArrayList aliases; /// <summary> /// /// </summary> /// <param name="query"></param> public NamedSQLQuery( string query ) { this.aliases = new ArrayList(); this.aliasedClasses = new ArrayList(); this.query = query; this.synchronizedTables = new ArrayList(); } /// <summary> /// /// </summary> public string[] ReturnAliases { get { return (string[]) aliases.ToArray( typeof( string[ ] ) ); } } /// <summary> /// /// </summary> public string[] ReturnClasses { get { return (string[]) aliasedClasses.ToArray( typeof( string[ ] ) ); } } /// <summary> /// /// </summary> public IList SynchronizedTables { get { return synchronizedTables; } } /// <summary> /// /// </summary> public string QueryString { get { return query; } } /// <summary> /// /// </summary> /// <param name="table"></param> public void AddSynchronizedTable( string table ) { synchronizedTables.Add( table ); } /// <summary> /// /// </summary> /// <param name="alias"></param> /// <param name="clazz"></param> public void AddAliasedClass( string alias, object clazz) { aliases.Add( alias ); aliasedClasses.Add( clazz ); } } } --- NEW FILE: ToOne.cs --- using System; using NHibernate.Loader; namespace NHibernate.Mapping { /// <summary> /// A simple-point association (ie. a reference to another entity). /// </summary> public abstract class ToOne : SimpleValue, IFetchable { private OuterJoinFetchStrategy joinedFetch; private string referencedPropertyName; /// <summary> /// /// </summary> public ToOne( Table table ) : base( table ) { } /// <summary></summary> public override OuterJoinFetchStrategy OuterJoinFetchSetting { get { return joinedFetch; } set { joinedFetch = value; } } /// <summary></summary> public string ReferencedPropertyName { get { return referencedPropertyName; } set { referencedPropertyName = value; } } /// <summary> /// /// </summary> public abstract override void CreateForeignKey( ); /// <summary> /// /// </summary> /// <param name="propertyClass"></param> /// <param name="propertyName"></param> public abstract override void SetTypeByReflection( System.Type propertyClass, string propertyName ); } } Index: IdentifierBag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IdentifierBag.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IdentifierBag.cs 14 Feb 2005 03:37:27 -0000 1.4 --- IdentifierBag.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 18,22 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.IdBag( Role ); } --- 18,22 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.IdBag( Role ); } Index: IntegerValue.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IntegerValue.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IntegerValue.cs 17 Jan 2005 03:40:58 -0000 1.6 --- IntegerValue.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 4,8 **** { /// <summary></summary> ! public class IntegerValue : Value { /// <summary> --- 4,8 ---- { /// <summary></summary> ! public class IntegerValue : SimpleValue { /// <summary> Index: IdentifierCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IdentifierCollection.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IdentifierCollection.cs 31 Dec 2004 21:26:49 -0000 1.3 --- IdentifierCollection.cs 1 Mar 2005 16:24:49 -0000 1.4 *************** *** 8,12 **** /// <summary></summary> public static readonly string DefaultIdentifierColumnName = "id"; ! private Value identifier; /// <summary> --- 8,12 ---- /// <summary></summary> public static readonly string DefaultIdentifierColumnName = "id"; ! private SimpleValue identifier; /// <summary> *************** *** 19,23 **** /// <summary></summary> ! public Value Identifier { get { return identifier; } --- 19,23 ---- /// <summary></summary> ! public SimpleValue Identifier { get { return identifier; } *************** *** 32,44 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Identifier.ColumnCollection ) { ! pk.AddColumn( col ); } - Table.PrimaryKey = pk; } --- 32,48 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Identifier.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! CollectionTable.PrimaryKey = pk; } + //else // Create an index on the key columns? } Index: Collection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Collection.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Collection.cs 31 Dec 2004 21:26:38 -0000 1.7 --- Collection.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 1,4 **** --- 1,6 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; + using NHibernate.Loader; using NHibernate.Type; *************** *** 6,11 **** { /// <summary></summary> ! public abstract class Collection { /// <summary></summary> public const string DefaultElementColumnName = "elt"; --- 8,15 ---- { /// <summary></summary> ! public abstract class Collection : IFetchable, IValue { + private static readonly ICollection EmptyColumns = new ArrayList(); + /// <summary></summary> public const string DefaultElementColumnName = "elt"; *************** *** 14,25 **** public const string DefaultKeyColumnName = "id"; ! private Value key; ! private Value element; ! private Table table; private string role; private bool lazy; ! private bool isOneToMany; private bool inverse; ! private OneToMany oneToMany; private ICacheConcurrencyStrategy cache; private string orderBy; --- 18,29 ---- public const string DefaultKeyColumnName = "id"; ! private SimpleValue key; ! private IValue element; ! private Table collectionTable; private string role; private bool lazy; ! //private bool isOneToMany; private bool inverse; ! //private OneToMany oneToMany; private ICacheConcurrencyStrategy cache; private string orderBy; *************** *** 29,32 **** --- 33,39 ---- private IComparer comparer; private bool orphanDelete; + private int batchSize = 1; + private OuterJoinFetchStrategy joinedFetch; + private System.Type collectionPersisterClass; /// <summary> *************** *** 40,43 **** --- 47,56 ---- /// <summary></summary> + public int ColumnSpan + { + get { return 0; } + } + + /// <summary></summary> public virtual bool IsSet { *************** *** 46,50 **** /// <summary></summary> ! public Value Key { get { return key; } --- 59,63 ---- /// <summary></summary> ! public SimpleValue Key { get { return key; } *************** *** 53,57 **** /// <summary></summary> ! public Value Element { get { return element; } --- 66,70 ---- /// <summary></summary> ! public IValue Element { get { return element; } *************** *** 66,73 **** /// <summary></summary> public Table Table { ! get { return table; } ! set { table = value; } } --- 79,92 ---- /// <summary></summary> + public Table CollectionTable + { + get { return collectionTable; } + set { collectionTable = value; } + } + + /// <summary></summary> public Table Table { ! get { return Owner.Table; } } *************** *** 80,83 **** --- 99,116 ---- /// <summary></summary> + public PersistentClass Owner + { + get { return owner; } + set { owner = value; } + } + + /// <summary></summary> + public System.Type CollectionPersisterClass + { + get { return collectionPersisterClass; } + set { collectionPersisterClass = value; } + } + + /// <summary></summary> public IComparer Comparer { *************** *** 101,107 **** /// <summary></summary> ! public abstract PersistentCollectionType Type { get; } /// <summary></summary> public abstract System.Type WrapperClass { get; } --- 134,170 ---- /// <summary></summary> ! public ICollection ColumnCollection ! { ! get { return EmptyColumns; } ! } ! ! /// <summary></summary> ! public Formula Formula ! { ! get { return null; } ! } ! ! /// <summary></summary> ! public bool IsNullable ! { ! get { return true; } ! } ! ! /// <summary></summary> ! public bool IsUnique ! { ! get { return false; } ! } ! ! /// <summary></summary> ! public abstract PersistentCollectionType CollectionType { get; } /// <summary></summary> + public IType Type + { + get { return CollectionType; } + } + + /// <summary></summary> public abstract System.Type WrapperClass { get; } *************** *** 127,134 **** public bool IsOneToMany { ! get { return isOneToMany; } ! set { isOneToMany = value; } } /// <summary></summary> public OneToMany OneToMany --- 190,198 ---- public bool IsOneToMany { ! get { return element is OneToMany; } ! //set { isOneToMany = value; } } + /* /// <summary></summary> public OneToMany OneToMany *************** *** 137,140 **** --- 201,205 ---- set { oneToMany = value; } } + */ /// <summary></summary> *************** *** 155,166 **** public System.Type OwnerClass { ! get { return owner.PersistentClazz; } ! } ! ! /// <summary></summary> ! public PersistentClass Owner ! { ! get { return owner; } ! set { owner = value; } } --- 220,224 ---- public System.Type OwnerClass { ! get { return owner.MappedClass; } } *************** *** 186,189 **** --- 244,326 ---- } + /// <summary></summary> + public int BatchSize + { + get { return batchSize; } + set { batchSize = value; } + } + + /// <summary></summary> + public OuterJoinFetchStrategy OuterJoinFetchSetting + { + get { return joinedFetch; } + set { joinedFetch = value; } + } + + /// <summary> + /// + /// </summary> + public void CreateForeignKey( ) + { + } + + private void CreateForeignKeys( ) + { + if ( !IsInverse ) + { + Element.CreateForeignKey(); + Key.CreateForeignKeyOfClass( Owner.MappedClass ); + } + } + + /// <summary> + /// + /// </summary> + public abstract void CreatePrimaryKey( ); + + /// <summary> + /// + /// </summary> + public void CreateAllKeys() + { + CreateForeignKeys(); + if ( !IsInverse ) + { + CreatePrimaryKey( ); + } + } + + /// <summary></summary> + public bool IsSimpleValue + { + get { return false; } + } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + /// <returns></returns> + public bool IsValid( IMapping mapping ) + { + return true; + } + + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public virtual void Validate( IMapping mapping ) + { + if ( !Key.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "collection foreign key mapping has wrong number of columns: {0} type: {1}", Role, Key.Type.Name ) ); + } + + if ( !Element.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "collection element key mapping has wrong number of columns: {0} type: {1}", Role, Element.Type.Name ) ); + } + } } } \ No newline at end of file Index: Any.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Any.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Any.cs 31 Dec 2004 21:26:25 -0000 1.5 --- Any.cs 1 Mar 2005 16:24:48 -0000 1.6 *************** *** 5,9 **** { /// <summary></summary> ! public class Any : Value { private IType identifierType; --- 5,9 ---- { /// <summary></summary> ! public class Any : SimpleValue { private IType identifierType; Index: Association.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Association.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Association.cs 31 Dec 2004 21:26:26 -0000 1.4 --- Association.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 6,10 **** public abstract class Association : Value { ! private OuterJoinLoaderType joinedFetch; /// <summary> --- 6,10 ---- public abstract class Association : Value { ! private OuterJoinFetchStrategy joinedFetch; /// <summary> *************** *** 17,21 **** /// <summary></summary> ! public override OuterJoinLoaderType OuterJoinFetchSetting { get { return joinedFetch; } --- 17,21 ---- /// <summary></summary> ! public override OuterJoinFetchStrategy OuterJoinFetchSetting { get { return joinedFetch; } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Set.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Set.cs 14 Feb 2005 03:37:27 -0000 1.7 --- Set.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 29,33 **** /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type { get --- 29,33 ---- /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType CollectionType { get *************** *** 53,79 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Key.ColumnCollection ) { ! pk.AddColumn( col ); ! } ! bool nullable = false; ! foreach( Column col in Element.ColumnCollection ) ! { ! if( col.IsNullable ) { ! nullable = true; } - pk.AddColumn( col ); - } ! // some databases (Postgres) will tolerate nullable ! // column in a primary key - others (DB2) won't ! if( !nullable ) { ! Table.PrimaryKey = pk; } } --- 53,86 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! foreach( Column col in Key.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! bool nullable = false; ! foreach( Column col in Element.ColumnCollection ) { ! if( col.IsNullable ) ! { ! nullable = true; ! } ! pk.AddColumn( col ); } ! // some databases (Postgres) will tolerate nullable ! // column in a primary key - others (DB2) won't ! if( !nullable ) ! { ! CollectionTable.PrimaryKey = pk; ! } ! } ! else { ! // Create an index on the key columns? } } Index: OneToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToOne.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OneToOne.cs 31 Dec 2004 21:27:42 -0000 1.4 --- OneToOne.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 6,14 **** { /// <summary></summary> ! public class OneToOne : Association { private bool constrained; private ForeignKeyType foreignKeyType; ! private Value identifier; /// <summary> --- 6,14 ---- { /// <summary></summary> ! public class OneToOne : ToOne { private bool constrained; private ForeignKeyType foreignKeyType; ! private SimpleValue identifier; /// <summary> *************** *** 17,21 **** /// <param name="table"></param> /// <param name="identifier"></param> ! public OneToOne( Table table, Value identifier ) : base( table ) { this.identifier = identifier; --- 17,21 ---- /// <param name="table"></param> /// <param name="identifier"></param> ! public OneToOne( Table table, SimpleValue identifier ) : base( table ) { this.identifier = identifier; *************** *** 45,51 **** public override void CreateForeignKey() { if( constrained ) { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).PersistentClass ); } } --- 45,52 ---- public override void CreateForeignKey() { + //if( constrained && ReferencedPropertyName == null ) if( constrained ) { ! CreateForeignKeyOfClass( ( ( EntityType ) Type ).AssociatedClass ); } } *************** *** 80,90 **** /// <summary></summary> ! public Value Identifier { get { return identifier; } ! set { identifier = value; } } ! } } \ No newline at end of file --- 81,95 ---- /// <summary></summary> ! public IValue Identifier { get { return identifier; } ! set { identifier = (SimpleValue) value; } } ! /// <summary></summary> ! public override bool IsNullable ! { ! get { return !IsConstrained; } ! } } } \ No newline at end of file --- NEW FILE: SimpleValue.cs --- using System; using System.Collections; using NHibernate.Engine; using NHibernate.Id; using NHibernate.Loader; using NHibernate.Type; using NHibernate.Util; namespace NHibernate.Mapping { /// <summary> /// Any value that maps to columns. /// </summary> public class SimpleValue : IValue { private ArrayList columns = new ArrayList(); private IType type; private IDictionary identifierGeneratorProperties; private string identifierGeneratorStrategy = "assigned"; private string nullValue; private Table table; private Formula formula; private string foreignKeyName; private bool unique; private IIdentifierGenerator uniqueIdentifierGenerator; /// <summary> /// /// </summary> public SimpleValue( ) { } /// <summary> /// /// </summary> /// <param name="table"></param> public SimpleValue( Table table ) { this.table = table; } /// <summary> /// /// </summary> /// <param name="column"></param> public virtual void AddColumn( Column column ) { if( !columns.Contains( column ) ) { columns.Add( column ); } } /// <summary></summary> public virtual int ColumnSpan { get { return columns.Count; } } /// <summary></summary> public virtual ICollection ColumnCollection { get { return columns; } } /// <summary></summary> public virtual IList ConstraintColumns { get { return columns; } } /// <summary></summary> public virtual IType Type { get { return type; } set { this.type = value; int count = 0; foreach( Column col in ColumnCollection ) { col.Type = type; col.TypeIndex = count++; } } } /// <summary></summary> public string ForeignKeyName { get { return foreignKeyName; } set { foreignKeyName = value; } } /// <summary></summary> public Table Table { get { return table; } set { table = value; } } /// <summary></summary> public virtual void CreateForeignKey() { } /// <summary> /// /// </summary> /// <param name="persistentClass"></param> public void CreateForeignKeyOfClass( System.Type persistentClass ) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } /// <summary> /// /// </summary> /// <param name="dialect"></param> /// <returns></returns> public IIdentifierGenerator CreateIdentifierGenerator( Dialect.Dialect dialect ) { if( uniqueIdentifierGenerator == null ) { uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create( identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect ); } return uniqueIdentifierGenerator; } /// <summary> /// /// </summary> /// <param name="propertyClass"></param> /// <param name="propertyName"></param> public virtual void SetTypeByReflection( System.Type propertyClass, string propertyName ) { try { if( type == null ) { type = ReflectHelper.ReflectedPropertyType( propertyClass, propertyName ); int count = 0; foreach( Column col in ColumnCollection ) { col.Type = type; col.TypeIndex = count++; } } } catch( HibernateException he ) { throw new MappingException( "Problem trying to set property type by reflection", he ); } } /// <summary></summary> public virtual OuterJoinFetchStrategy OuterJoinFetchSetting { get { return OuterJoinFetchStrategy.Lazy; } set { throw new NotSupportedException(); } } /// <summary></summary> public IDictionary IdentifierGeneratorProperties { get { return identifierGeneratorProperties; } set { identifierGeneratorProperties = value; } } /// <summary></summary> public string IdentifierGeneratorStrategy { get { return identifierGeneratorStrategy; } set { identifierGeneratorStrategy = value; } } /// <summary></summary> public virtual bool IsComposite { get { return false; } } /// <summary></summary> public bool IsSimpleValue { get { return true; } } /// <summary></summary> public bool IsUnique { get { return unique; } set { unique = value; } } /// <summary></summary> public virtual bool IsNullable { get { bool nullable = true; foreach( Column col in ColumnCollection ) { if ( !col.IsNullable ) { nullable = false; } } return nullable; } } /// <summary></summary> public string NullValue { get { return nullValue; } set { nullValue = value; } } /// <summary></summary> public virtual bool IsAny { get { return false; } } /// <summary></summary> public Formula Formula { get { return formula; } set { formula = value; } } /// <summary></summary> public bool IsValid( IMapping mapping ) { return ColumnSpan == Type.GetColumnSpan( mapping ); } } } Index: Bag.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Bag.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Bag.cs 14 Feb 2005 03:37:27 -0000 1.6 --- Bag.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 17,21 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.Bag( Role ); } --- 17,21 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.Bag( Role ); } *************** *** 28,31 **** --- 28,38 ---- } + /// <summary> + /// + /// </summary> + /// <remarks>Should we create an index on the key columns?</remarks> + public override void CreatePrimaryKey( ) + { + } } } \ No newline at end of file Index: IndexedCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IndexedCollection.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IndexedCollection.cs 31 Dec 2004 21:27:02 -0000 1.5 --- IndexedCollection.cs 1 Mar 2005 16:24:49 -0000 1.6 *************** *** 1,2 **** --- 1,4 ---- + using NHibernate.Engine; + namespace NHibernate.Mapping { *************** *** 10,14 **** public const string DefaultIndexColumnName = "idx"; ! private Value index; /// <summary> --- 12,16 ---- public const string DefaultIndexColumnName = "idx"; ! private SimpleValue index; /// <summary> *************** *** 21,25 **** /// <summary></summary> ! public Value Index { get { return index; } --- 23,27 ---- /// <summary></summary> ! public SimpleValue Index { get { return index; } *************** *** 34,51 **** /// <summary></summary> ! public void CreatePrimaryKey() { ! PrimaryKey pk = new PrimaryKey(); ! ! foreach( Column col in Key.ColumnCollection ) { ! pk.AddColumn( col ); } ! foreach( Column col in Index.ColumnCollection ) { ! pk.AddColumn( col ); } - - Table.PrimaryKey = pk; } } --- 36,71 ---- /// <summary></summary> ! public override void CreatePrimaryKey() { ! if ( !IsOneToMany ) { ! PrimaryKey pk = new PrimaryKey(); ! ! foreach( Column col in Key.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! ! // Index should be last column listed ! foreach( Column col in Index.ColumnCollection ) ! { ! pk.AddColumn( col ); ! } ! ! CollectionTable.PrimaryKey = pk; } ! } ! ! /// <summary> ! /// ! /// </summary> ! /// <param name="mapping"></param> ! public override void Validate( IMapping mapping ) ! { ! base.Validate( mapping ); ! if ( !Index.IsValid( mapping ) ) { ! throw new MappingException( string.Format( "collection index mapping has wrong number of columns: {0} type: {1}", Role, Index.Type.Name ) ); } } } Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/List.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** List.cs 14 Feb 2005 03:37:27 -0000 1.8 --- List.cs 1 Mar 2005 16:24:49 -0000 1.9 *************** *** 17,21 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.List( Role ); } --- 17,21 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.List( Role ); } --- NEW FILE: IValue.cs --- using System.Collections; using NHibernate.Engine; using NHibernate.Loader; using NHibernate.Type; namespace NHibernate.Mapping { /// <summary> /// A value is anything that is persisted by value, instead of /// by reference. It is essentially a Hibernate IType, together /// with zero or more columns. Values are wrapped by things with /// higher level semantics, for example properties, collections, /// classes. /// </summary> public interface IValue { /// <summary> /// /// </summary> int ColumnSpan { get; } /// <summary> /// /// </summary> ICollection ColumnCollection { get; } /// <summary> /// /// </summary> IType Type { get; } /// <summary> /// /// </summary> Table Table { get; } /// <summary> /// /// </summary> Formula Formula { get; } /// <summary> /// /// </summary> bool IsUnique { get; } /// <summary> /// /// </summary> bool IsNullable { get; } /// <summary> /// /// </summary> bool IsSimpleValue { get; } /// <summary> /// /// </summary> void CreateForeignKey( ); /// <summary> /// /// </summary> /// <param name="mapping"></param> /// <returns></returns> bool IsValid( IMapping mapping ); /// <summary> /// /// </summary> OuterJoinFetchStrategy OuterJoinFetchSetting { get; } } } Index: Component.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Component.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Component.cs 31 Dec 2004 21:26:38 -0000 1.6 --- Component.cs 1 Mar 2005 16:24:49 -0000 1.7 *************** *** 5,9 **** { /// <summary></summary> ! public class Component : Value { private ArrayList properties = new ArrayList(); --- 5,9 ---- { /// <summary></summary> ! public class Component : SimpleValue { private ArrayList properties = new ArrayList(); *************** *** 11,14 **** --- 11,15 ---- // TODO: H2.0.3 - make sure this is gone from the mapping file... //private BasicDynaClass dynaClass + private bool dynamic; private bool embedded; private string parentProperty; *************** *** 108,111 **** --- 109,119 ---- /// <summary></summary> + public bool IsDynamic + { + get { return dynamic; } + set { dynamic = value; } + } + + /// <summary></summary> public override bool IsComposite { Index: Table.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Table.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Table.cs 2 Jan 2005 22:03:39 -0000 1.15 --- Table.cs 1 Mar 2005 16:24:49 -0000 1.16 *************** *** 17,21 **** private string schema; private SequencedHashMap columns = new SequencedHashMap(); ! private Value idValue; private PrimaryKey primaryKey; private IDictionary indexes = new Hashtable(); --- 17,21 ---- private string schema; private SequencedHashMap columns = new SequencedHashMap(); ! private SimpleValue idValue; private PrimaryKey primaryKey; private IDictionary indexes = new Hashtable(); *************** *** 25,28 **** --- 25,29 ---- private bool quoted; private static int tableCounter = 0; + private IList checkConstraints = new ArrayList(); /// <summary> *************** *** 496,501 **** /// Sets the Identifier of the Table. /// </summary> ! /// <param name="idValue">The <see cref="Value"/> that represents the Identifier.</param> ! public void SetIdentifierValue( Value idValue ) { this.idValue = idValue; --- 497,502 ---- /// Sets the Identifier of the Table. /// </summary> ! /// <param name="idValue">The <see cref="SimpleValue"/> that represents the Identifier.</param> ! public void SetIdentifierValue( SimpleValue idValue ) { this.idValue = idValue; *************** *** 512,516 **** } ! } } \ No newline at end of file --- 513,524 ---- } ! /// <summary> ! /// ! /// </summary> ! /// <param name="constraint"></param> ! public void AddCheckConstraint( string constraint ) ! { ! checkConstraints.Add( constraint ); ! } } } \ No newline at end of file Index: Subclass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Subclass.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Subclass.cs 3 Jan 2005 03:46:48 -0000 1.7 --- Subclass.cs 1 Mar 2005 16:24:49 -0000 1.8 *************** *** 2,5 **** --- 2,6 ---- using System.Collections; using NHibernate.Cache; + using NHibernate.Engine; namespace NHibernate.Mapping *************** *** 12,16 **** { private PersistentClass superclass; ! private Value key; /// <summary> --- 13,18 ---- { private PersistentClass superclass; ! private SimpleValue key; ! private System.Type classPersisterClass; /// <summary> *************** *** 58,61 **** --- 60,85 ---- /// <summary> + /// + /// </summary> + public override System.Type ClassPersisterClass + { + get + { + if ( classPersisterClass == null ) + { + return Superclass.ClassPersisterClass; + } + else + { + return classPersisterClass; + } + } + set + { + classPersisterClass = value; + } + } + + /// <summary> /// Gets or sets the <see cref="Property"/> that is used as the <c>id</c>. /// </summary> *************** *** 70,77 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="Value"/> from the Superclass that contains information about the identifier.</value> ! public override Value Identifier { get { return Superclass.Identifier; } --- 94,101 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the identifier. /// </summary> ! /// <value>The <see cref="SimpleValue"/> from the Superclass that contains information about the identifier.</value> ! public override SimpleValue Identifier { get { return Superclass.Identifier; } *************** *** 89,96 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="Value"/> from the Superclass that contains information about the discriminator.</value> ! public override Value Discriminator { get { return Superclass.Discriminator; } --- 113,120 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the discriminator. /// </summary> ! /// <value>The <see cref="SimpleValue"/> from the Superclass that contains information about the discriminator.</value> ! public override SimpleValue Discriminator { get { return Superclass.Discriminator; } *************** *** 281,294 **** /// <summary> - /// Gets or sets the <see cref="System.Type"/> of the Persister. - /// </summary> - /// <value>The <see cref="System.Type"/> of the Persister for the Superclass.</value> - public override System.Type Persister - { - get { return Superclass.Persister; } - set { Superclass.Persister = value; } - } - - /// <summary> /// Gets the <see cref="Table"/> of the class /// that is mapped in the <c>class</c> element. --- 305,308 ---- *************** *** 303,310 **** /// <summary> ! /// Gets or sets the <see cref="Value"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="Value"/> that contains information about the Key.</value> ! public override Value Key { get --- 317,324 ---- /// <summary> ! /// Gets or sets the <see cref="SimpleValue"/> that contains information about the Key. /// </summary> ! /// <value>The <see cref="SimpleValue"/> that contains information about the Key.</value> ! public override SimpleValue Key { get *************** *** 350,354 **** --- 364,409 ---- } + /// <summary> + /// + /// </summary> + public override bool IsJoinedSubclass + { + get { return Table != RootTable; } + } + + /// <summary> + /// + /// </summary> + public override bool IsDiscriminatorInsertable + { + get { return Superclass.IsDiscriminatorInsertable ; } + set { throw new InvalidOperationException( "The DiscriminatorInsertable property can not be set on the Subclass - use the Superclass instead." ); } + } + /// <summary> + /// + /// </summary> + /// <param name="mapping"></param> + public override void Validate( IMapping mapping ) + { + base.Validate( mapping ); + if ( Key != null && !Key.IsValid( mapping ) ) + { + throw new MappingException( string.Format( "subclass key has wrong number of columns: {0} type: {1}", MappedClass.Name, Key.Type.Name ) ); + } + } + + /// <summary> + /// + /// </summary> + public void CreateForeignKey( ) + { + if ( !IsJoinedSubclass ) + { + throw new AssertionFailure( "Not a joined-subclass" ); + } + + Key.CreateForeignKeyOfClass( Superclass.MappedClass ); + } } } \ No newline at end of file Index: Array.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Array.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Array.cs 31 Dec 2004 21:26:26 -0000 1.4 --- Array.cs 1 Mar 2005 16:24:49 -0000 1.5 *************** *** 27,31 **** /// <summary></summary> ! public override PersistentCollectionType Type { get { return TypeFactory.Array( Role, ElementClass ); } --- 27,31 ---- /// <summary></summary> ! public override PersistentCollectionType CollectionType { get { return TypeFactory.Array( Role, ElementClass ); } |