Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11566/Mapping Modified Files: Any.cs Array.cs Association.cs Bag.cs Collection.cs Column.cs Component.cs Constraint.cs ForeignKey.cs Index.cs IndexedCollection.cs IntegerValue.cs IRelationalModel.cs List.cs ManyToOne.cs Map.cs OneToMany.cs OneToOne.cs PersistentClass.cs PrimaryKey.cs PrimitiveArray.cs Property.cs Set.cs Table.cs UniqueKey.cs Value.cs Log Message: Synching Mapping namespace with H2.0.3 - still need to finish Table, PersistentClass, Rootclass, and subclass. Index: PersistentClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PersistentClass.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PersistentClass.cs 12 Apr 2004 05:42:36 -0000 1.8 --- PersistentClass.cs 13 Apr 2004 02:06:54 -0000 1.9 *************** *** 1,11 **** using System; using System.Collections; using NHibernate.Cache; - using NHibernate.Util; using NHibernate.Sql; - namespace NHibernate.Mapping { - - public abstract class PersistentClass { private System.Type persistentClass; private string discriminatorValue; --- 1,17 ---- using System; using System.Collections; + using NHibernate.Cache; using NHibernate.Sql; + using NHibernate.Util; + + namespace NHibernate.Mapping + { + //TODO: H2.0.3 - there are some "set" declared on properties that I am not sure about - need + // to double check those. + public abstract class PersistentClass + { + private static readonly Alias PKAlias = new Alias(15, "PK"); private System.Type persistentClass; private string discriminatorValue; *************** *** 13,43 **** private Table table; private System.Type proxyInterface; - private bool dynamicUpdate; private readonly ArrayList subclasses = new ArrayList(); private readonly ArrayList subclassProperties = new ArrayList(); private readonly ArrayList subclassTables = new ArrayList(); ! public virtual bool DynamicUpdate { get { return dynamicUpdate; } set { dynamicUpdate = value ; } } ! public virtual string DiscriminatorValue { get { return discriminatorValue; } set { discriminatorValue = value; } } ! public virtual void AddSubclass(Subclass subclass) { subclasses.Add(subclass); } ! public virtual bool HasSubclasses { get { return subclasses.Count > 0; } } ! public virtual int SubclassSpan { ! get { int n = subclasses.Count; ! foreach(Subclass sc in subclasses) { n += sc.SubclassSpan; } --- 19,63 ---- private Table table; private System.Type proxyInterface; private readonly ArrayList subclasses = new ArrayList(); private readonly ArrayList subclassProperties = new ArrayList(); private readonly ArrayList subclassTables = new ArrayList(); + private bool dynamicInsert; + private bool dynamicUpdate; + + public virtual bool DynamicInsert + { + get { return dynamicInsert; } + set { dynamicInsert = value ; } + } ! public virtual bool DynamicUpdate ! { get { return dynamicUpdate; } set { dynamicUpdate = value ; } } ! public virtual string DiscriminatorValue ! { get { return discriminatorValue; } set { discriminatorValue = value; } } ! public virtual void AddSubclass(Subclass subclass) ! { subclasses.Add(subclass); } ! public virtual bool HasSubclasses ! { get { return subclasses.Count > 0; } } ! public virtual int SubclassSpan ! { ! get ! { int n = subclasses.Count; ! foreach(Subclass sc in subclasses) ! { n += sc.SubclassSpan; } *************** *** 51,55 **** /// it will pick those up also. /// </summary> ! public virtual ICollection SubclassCollection { get { ArrayList retVal = new ArrayList(); --- 71,76 ---- /// it will pick those up also. /// </summary> ! public virtual ICollection SubclassCollection ! { get { ArrayList retVal = new ArrayList(); *************** *** 69,123 **** } ! public virtual ICollection DirectSubclasses { get { return subclasses; } } ! public virtual void AddProperty(Property p) { properties.Add(p); } ! public virtual Table Table { get { return table; } set { table = value; } } ! public virtual ICollection PropertyCollection { get { return properties; } } ! public virtual System.Type PersistentClazz { get { return persistentClass; } set { persistentClass = value; } } ! public virtual string Name { get { return persistentClass.FullName; } } ! public abstract bool IsMutable { get; set;} public abstract bool HasIdentifierProperty { get; } ! public abstract Property IdentifierProperty { get; set; } ! public abstract Value Identifier { get; set; } ! public abstract Property Version { get; set; } ! public abstract Value Discriminator { get; set; } ! public abstract bool IsInherited { get; } // see the comment in RootClass about why the polymorphic setter is commented out public abstract bool IsPolymorphic { get; } //set; } public abstract bool IsVersioned { get;} ! public abstract ICacheConcurrencyStrategy Cache { get; set;} ! public abstract PersistentClass Superclass { get; set; } ! public abstract bool IsExplicitPolymorphism { get; set;} public abstract ICollection PropertyClosureCollection { get; } public abstract ICollection TableClosureCollection { get; } ! public virtual void AddSubclassProperty(Property p) { subclassProperties.Add(p); } ! public virtual void AddSubclassTable(Table table) { subclassTables.Add(table); } ! public virtual ICollection SubclassPropertyClosureCollection { ! get { ArrayList retVal = new ArrayList(); retVal.AddRange( PropertyClosureCollection ); --- 90,156 ---- } ! public virtual ICollection DirectSubclasses ! { get { return subclasses; } } ! public virtual void AddProperty(Property p) ! { properties.Add(p); } ! public virtual Table Table ! { get { return table; } set { table = value; } } ! public virtual ICollection PropertyCollection ! { get { return properties; } } ! public virtual System.Type PersistentClazz ! { get { return persistentClass; } set { persistentClass = value; } } ! public virtual string Name ! { get { return persistentClass.FullName; } } ! public abstract bool IsMutable { get; set;} // set?? public abstract bool HasIdentifierProperty { get; } ! public abstract Property IdentifierProperty { get; set; } //set?? ! public abstract Value Identifier { get; set; } //set?? ! public abstract Property Version { get; set; } //set?? ! public abstract Value Discriminator { get; set; } //set?? ! public abstract bool IsInherited { get; } // see the comment in RootClass about why the polymorphic setter is commented out public abstract bool IsPolymorphic { get; } //set; } public abstract bool IsVersioned { get;} ! public abstract ICacheConcurrencyStrategy Cache { get; set;} //set?? ! public abstract PersistentClass Superclass { get; set; } //set?? ! public abstract bool IsExplicitPolymorphism { get; set;}//set?? public abstract ICollection PropertyClosureCollection { get; } public abstract ICollection TableClosureCollection { get; } ! public virtual void AddSubclassProperty(Property p) ! { subclassProperties.Add(p); } ! ! public virtual void AddSubclassTable(Table table) ! { subclassTables.Add(table); } ! ! public virtual ICollection SubclassPropertyClosureCollection ! { ! get ! { ArrayList retVal = new ArrayList(); retVal.AddRange( PropertyClosureCollection ); *************** *** 132,137 **** /// </summary> /// <remarks>It adds the TableClosureCollection and the subclassTables into the ICollection.</remarks> ! public virtual ICollection SubclassTableClosureCollection { ! get { ArrayList retVal = new ArrayList(); retVal.AddRange( TableClosureCollection ); --- 165,172 ---- /// </summary> /// <remarks>It adds the TableClosureCollection and the subclassTables into the ICollection.</remarks> ! public virtual ICollection SubclassTableClosureCollection ! { ! get ! { ArrayList retVal = new ArrayList(); retVal.AddRange( TableClosureCollection ); *************** *** 140,144 **** } } ! public virtual System.Type ProxyInterface { get { return proxyInterface; } set { proxyInterface = value ; } --- 175,180 ---- } } ! public virtual System.Type ProxyInterface ! { get { return proxyInterface; } set { proxyInterface = value ; } *************** *** 146,174 **** public virtual bool IsForceDiscriminator { ! get { ! return false; ! } ! set { } } ! public abstract bool HasEmbeddedIdentifier { get; set;} ! public abstract System.Type Persister { get; set;} public abstract Table RootTable { get; } public abstract RootClass RootClazz { get; } ! public abstract Value Key { get; set; } ! public virtual void CreatePrimaryKey() { PrimaryKey pk = new PrimaryKey(); pk.Table = table; ! pk.Name = StringHelper.Suffix( table.Name, "PK" ); table.PrimaryKey = pk; ! foreach(Column col in Key.ColumnCollection) { pk.AddColumn(col); } } ! private static readonly Alias PKAlias = new Alias(15, "PK"); } } --- 182,216 ---- public virtual bool IsForceDiscriminator { ! get { return false; } ! set { //??? } } ! public abstract bool HasEmbeddedIdentifier { get; set;} //set?? ! public abstract System.Type Persister { get; set;} //set?? public abstract Table RootTable { get; } public abstract RootClass RootClazz { get; } ! public abstract Value Key { get; set; } //set?? ! public virtual void CreatePrimaryKey() ! { PrimaryKey pk = new PrimaryKey(); pk.Table = table; ! pk.Name = PKAlias.ToAliasString(table.Name); // StringHelper.Suffix( table.Name, "PK" ); table.PrimaryKey = pk; ! foreach(Column col in Key.ColumnCollection) ! { pk.AddColumn(col); } } ! //TODO: H2.0.3 - make abstract... ! public virtual string Where ! { ! get { return ""; } ! } ! ! } } Index: ManyToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ManyToOne.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ManyToOne.cs 4 Mar 2003 03:59:28 -0000 1.2 --- ManyToOne.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 3,23 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class ManyToOne : Association { public ManyToOne(Table table) : base(table) { } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { ! try { if (Type==null) Type = TypeFactory.ManyToOne( ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType); ! } catch (HibernateException he) { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() { ! CreateForeignKeyOfClass( ( (EntityType)Type).PersistentClass); } } --- 3,29 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class ManyToOne : Association ! { public ManyToOne(Table table) : base(table) { } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { ! try ! { if (Type==null) Type = TypeFactory.ManyToOne( ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType); ! } ! catch (HibernateException he) ! { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() ! { ! CreateForeignKeyOfClass( ( (EntityType)Type).PersistentClass ); } } Index: Map.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Map.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Map.cs 10 Feb 2004 18:35:30 -0000 1.3 --- Map.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 1,22 **** using System; using NHibernate.Type; ! using SortedMap = NHibernate.Collection.SortedMap; ! using Map = NHibernate.Collection.Map; ! namespace NHibernate.Mapping { ! public class Map : IndexedCollection { public Map(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type { ! //TODO: fix up when SortedMap is implemented. //get { return IsSorted ? TypeFactory.SortedMap( Role, Comparator ) : TypeFactory.Map( Role ); get { return TypeFactory.Map( Role ); } //TODO: get sorted } ! public override System.Type WrapperClass { ! get { return IsSorted ? typeof(SortedMap) : typeof(Map); } } --- 1,26 ---- using System; + using NHibernate.Type; ! using NHCollection = NHibernate.Collection; ! namespace NHibernate.Mapping ! { public class Map : IndexedCollection { public Map(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type ! { ! //TODO: H2.0.3 - fix up when SortedMap is implemented. //get { return IsSorted ? TypeFactory.SortedMap( Role, Comparator ) : TypeFactory.Map( Role ); get { return TypeFactory.Map( Role ); } //TODO: get sorted } ! public override System.Type WrapperClass ! { ! //TODO: H2.0.3 - fix up when SortedMap is implemented. ! //get { return IsSorted ? typeof(NHCollection.SortedMap) : typeof(NHCollection.Map); } ! get { return typeof(NHCollection.Map); } } Index: Property.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Property.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Property.cs 22 Apr 2003 19:46:37 -0000 1.5 --- Property.cs 13 Apr 2004 02:06:54 -0000 1.6 *************** *** 4,71 **** using NHibernate.Engine; ! namespace NHibernate.Mapping { ! ! public class Property { private string name; ! private Value value; private string cascade; private bool updateable; private bool insertable; ! public Property(Value value) { ! this.value = value; } ! public IType Type { ! get { return value.Type; } } ! public int ColumnSpan { ! get { return value.ColumnSpan; } } ! public ICollection ColumnCollection { ! get { return value.ColumnCollection; } } ! public string Name { get { return name; } set { name = value; } } ! public bool IsUpdateable { get { return updateable; } set { updateable = value; } } ! public bool IsComposite { ! get { return value is Component; } } ! public Value Value { ! get { return value; } ! set { this.value = value; } } ! public Cascades.CascadeStyle CascadeStyle { get { ! IType type = value.Type; ! if (type.IsComponentType && !type.IsObjectType) { ! IAbstractComponentType actype = (IAbstractComponentType) value.Type; int length = actype.Subtypes.Length; ! for (int i=0; i<length; i++) { if ( actype.Cascade(i)!= Cascades.CascadeStyle.StyleNone ) return Cascades.CascadeStyle.StyleAll; } return Cascades.CascadeStyle.StyleNone; ! } else { ! if (cascade.Equals("all")) { return Cascades.CascadeStyle.StyleAll; ! } else if (cascade.Equals("none")) { return Cascades.CascadeStyle.StyleNone; ! } else if (cascade.Equals("save/update") || cascade.Equals("save-update")) { return Cascades.CascadeStyle.StyleSaveUpdate; ! } else if (cascade.Equals("delete")) { return Cascades.CascadeStyle.StyleOnlyDelete; ! } else { throw new MappingException("Unspported cascade style: " + cascade); } --- 4,99 ---- using NHibernate.Engine; ! namespace NHibernate.Mapping ! { ! public class Property ! { private string name; ! private Value propertyValue; private string cascade; private bool updateable; private bool insertable; ! public Property(Value propertyValue) ! { ! this.propertyValue = propertyValue; } ! public IType Type ! { ! get { return propertyValue.Type; } } ! public int ColumnSpan ! { ! get { return propertyValue.ColumnSpan; } } ! public ICollection ColumnCollection ! { ! get { return propertyValue.ColumnCollection; } } ! public string Name ! { get { return name; } set { name = value; } } ! public bool IsUpdateable ! { get { return updateable; } set { updateable = value; } } ! public bool IsComposite ! { ! get { return propertyValue is Component; } } ! public Value Value ! { ! get { return propertyValue; } ! set { this.propertyValue = value; } } ! public Cascades.CascadeStyle CascadeStyle ! { get { ! IType type = propertyValue.Type; ! if (type.IsComponentType && !type.IsObjectType) ! { ! IAbstractComponentType actype = (IAbstractComponentType) propertyValue.Type; int length = actype.Subtypes.Length; ! for (int i=0; i<length; i++) ! { if ( actype.Cascade(i)!= Cascades.CascadeStyle.StyleNone ) return Cascades.CascadeStyle.StyleAll; } + return Cascades.CascadeStyle.StyleNone; ! } ! else ! { ! if (cascade.Equals("all")) ! { return Cascades.CascadeStyle.StyleAll; ! } ! else if (cascade.Equals("all-delete-orphan") ) ! { ! return Cascades.CascadeStyle.StyleAllGC; ! } ! else if (cascade.Equals("none")) ! { return Cascades.CascadeStyle.StyleNone; ! } ! else if (cascade.Equals("save-update")) ! { return Cascades.CascadeStyle.StyleSaveUpdate; ! } ! else if (cascade.Equals("delete")) ! { return Cascades.CascadeStyle.StyleOnlyDelete; ! } ! else ! { throw new MappingException("Unspported cascade style: " + cascade); } *************** *** 74,78 **** } ! public string Cascade { get { return cascade; } set { cascade = value; } --- 102,107 ---- } ! public string Cascade ! { get { return cascade; } set { cascade = value; } *************** *** 80,86 **** public bool IsInsertable { ! get { return insertable; } set { insertable = value; } } } } \ No newline at end of file --- 109,125 ---- public bool IsInsertable { ! get { return insertable && !IsFormula; } set { insertable = value; } } + + public Formula Formula + { + get { return propertyValue.Formula; } + } + + public bool IsFormula + { + get { return Formula!=null; } + } } } \ No newline at end of file Index: List.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/List.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** List.cs 4 Mar 2003 16:38:12 -0000 1.5 --- List.cs 13 Apr 2004 02:06:54 -0000 1.6 *************** *** 1,21 **** using System; using NHibernate.Type; ! using HibernateList=NHibernate.Collection.List; ! namespace NHibernate.Mapping { ! /// <summary> /// A list has a primary key consisting of the key columns + index column /// </summary> ! public class List : IndexedCollection { ! ! public List(PersistentClass owner) : base(owner) { } ! public override PersistentCollectionType Type { get { return TypeFactory.List( Role ); } } ! public override System.Type WrapperClass { ! get { return typeof(HibernateList); } } --- 1,26 ---- using System; + using NHibernate.Type; ! using NHCollection = NHibernate.Collection; ! namespace NHibernate.Mapping ! { /// <summary> /// A list has a primary key consisting of the key columns + index column /// </summary> ! public class List : IndexedCollection ! { ! public List(PersistentClass owner) : base(owner) ! { ! } ! public override PersistentCollectionType Type ! { get { return TypeFactory.List( Role ); } } ! public override System.Type WrapperClass ! { ! get { return typeof(NHCollection.List); } } Index: Collection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Collection.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Collection.cs 10 Feb 2004 18:35:30 -0000 1.4 --- Collection.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 6,12 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! public abstract class Collection { public const string DefaultElementColumnName = "elt"; public const string DefaultKeyColumnName = "id"; --- 6,14 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public abstract class Collection ! { public const string DefaultElementColumnName = "elt"; public const string DefaultKeyColumnName = "id"; *************** *** 25,74 **** private PersistentClass owner; private bool sorted; - //private object comparator; //should be Comparator private IComparer comparer; ! protected Collection(PersistentClass owner) { this.owner = owner; } ! public virtual bool IsSet { get { return false; } } ! public Value Key { get { return key; } set { key = value; } } ! public Value Element { get { return element; } set { element = value; } } ! public virtual bool IsIndexed { get { return false; } } ! public Table Table { get { return table; } set { table = value; } } ! public bool IsSorted { get { return sorted; } set { sorted = value; } } ! public IComparer Comparer { get { return comparer; } set { comparer = value; } } ! public bool IsLazy { get { return lazy; } set { lazy = value; } } ! public string Role { get { return role; } set { role = value; } --- 27,86 ---- private PersistentClass owner; private bool sorted; private IComparer comparer; + private bool orphanDelete; ! protected Collection(PersistentClass owner) ! { this.owner = owner; } ! public virtual bool IsSet ! { get { return false; } } ! public Value Key ! { get { return key; } set { key = value; } } ! public Value Element ! { get { return element; } set { element = value; } } ! public virtual bool IsIndexed ! { get { return false; } } ! public Table Table ! { get { return table; } set { table = value; } } ! public bool IsSorted ! { get { return sorted; } set { sorted = value; } } ! public IComparer Comparer ! { get { return comparer; } set { comparer = value; } } ! public bool IsLazy ! { get { return lazy; } set { lazy = value; } } ! public string Role ! { get { return role; } set { role = value; } *************** *** 78,99 **** public abstract System.Type WrapperClass { get; } ! public virtual bool IsPrimitiveArray { get { return false; } } ! public virtual bool IsArray { get { return false; } } ! public bool IsOneToMany { get { return isOneToMany; } set { isOneToMany = value; } } ! public OneToMany OneToMany { get { return oneToMany; } set { oneToMany = value; } } public Index CreateIndex() { string name = "IX" + table.UniqueColumnString( Key.ColumnCollection ); --- 90,121 ---- public abstract System.Type WrapperClass { get; } ! public virtual bool IsPrimitiveArray ! { get { return false; } } ! public virtual bool IsArray ! { get { return false; } } ! public virtual bool IsIdentified ! { ! get { return false; } ! } ! ! public bool IsOneToMany ! { get { return isOneToMany; } set { isOneToMany = value; } } ! public OneToMany OneToMany ! { get { return oneToMany; } set { oneToMany = value; } } + //TODO: H2.0.3 - not in this class - where did it move to??? public Index CreateIndex() { string name = "IX" + table.UniqueColumnString( Key.ColumnCollection ); *************** *** 110,114 **** } ! public bool IsInverse { get { return inverse; } set { inverse = value; } --- 132,137 ---- } ! public bool IsInverse ! { get { return inverse; } set { inverse = value; } *************** *** 119,136 **** } ! public PersistentClass Owner { get { return owner; } set { owner = value; } } ! public string OrderBy { get { return orderBy; } set { orderBy = value; } } ! public string Where { get { return where; } set { where = value; } } } } --- 142,169 ---- } ! public PersistentClass Owner ! { get { return owner; } set { owner = value; } } ! public string OrderBy ! { get { return orderBy; } set { orderBy = value; } } ! public string Where ! { get { return where; } set { where = value; } } + + public bool OrphanDelete + { + get { return orphanDelete; } + set { orphanDelete = value; } + } + } } Index: OneToMany.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToMany.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OneToMany.cs 4 Mar 2003 03:59:28 -0000 1.2 --- OneToMany.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 2,21 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class OneToMany { private EntityType type; private Table referencingTable; ! public EntityType Type { get { return type; } set { type = value; } } ! public OneToMany(PersistentClass owner) { this.referencingTable = (owner==null) ? null : owner.Table; } ! public Table ReferencingTable { get { return referencingTable; } } --- 2,25 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class OneToMany ! { private EntityType type; private Table referencingTable; ! public EntityType Type ! { get { return type; } set { type = value; } } ! public OneToMany(PersistentClass owner) ! { this.referencingTable = (owner==null) ? null : owner.Table; } ! public Table ReferencingTable ! { get { return referencingTable; } } Index: Constraint.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Constraint.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Constraint.cs 10 Apr 2004 05:06:02 -0000 1.3 --- Constraint.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 6,43 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! ! public abstract class Constraint : IRelationalModel { private string name; private ArrayList columns = new ArrayList(); private Table table; ! public string Name { get { return name; } set { name = value; } } ! public ICollection ColumnCollection { get { return columns; } } ! public void AddColumn(Column column) { if ( !columns.Contains(column) ) columns.Add(column); } ! public int ColumnSpan { get { return columns.Count; } } ! public Table Table { get { return table; } set { table = value; } } ! public string SqlDropString(Dialect.Dialect dialect) { return "alter table " + Table.GetQualifiedName(dialect)+ " drop constraint " + Name; } ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("alter table ") .Append( Table.GetQualifiedName(dialect) ) --- 6,51 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public abstract class Constraint : IRelationalModel ! { private string name; private ArrayList columns = new ArrayList(); private Table table; ! public string Name ! { get { return name; } set { name = value; } } ! public ICollection ColumnCollection ! { get { return columns; } } ! public void AddColumn(Column column) ! { if ( !columns.Contains(column) ) columns.Add(column); } ! public int ColumnSpan ! { get { return columns.Count; } } ! public Table Table ! { get { return table; } set { table = value; } } ! public string SqlDropString(Dialect.Dialect dialect) ! { return "alter table " + Table.GetQualifiedName(dialect)+ " drop constraint " + Name; } ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) ! { StringBuilder buf = new StringBuilder("alter table ") .Append( Table.GetQualifiedName(dialect) ) Index: PrimaryKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/PrimaryKey.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PrimaryKey.cs 10 Apr 2004 05:06:02 -0000 1.4 --- PrimaryKey.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 5,16 **** using NHibernate.Util; ! namespace NHibernate.Mapping { ! ! public class PrimaryKey : Constraint { ! public string SqlConstraintString(Dialect.Dialect d) { StringBuilder buf = new StringBuilder(" primary key ("); int i=0; ! foreach(Column col in ColumnCollection) { buf.Append(col.GetQuotedName(d)); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); --- 5,19 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { ! public class PrimaryKey : Constraint ! { ! public string SqlConstraintString(Dialect.Dialect d) ! { StringBuilder buf = new StringBuilder(" primary key ("); int i=0; ! foreach(Column col in ColumnCollection) ! { buf.Append(col.GetQuotedName(d)); if (i < ColumnCollection.Count-1) buf.Append(StringHelper.CommaSpace); *************** *** 20,29 **** } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { StringBuilder buf = new StringBuilder( d.GetAddPrimaryKeyConstraintString(constraintName)) .Append('('); int i=0; ! foreach(Column col in ColumnCollection) { buf.Append( col.GetQuotedName(d) ); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); --- 23,34 ---- } ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) ! { StringBuilder buf = new StringBuilder( d.GetAddPrimaryKeyConstraintString(constraintName)) .Append('('); int i=0; ! foreach(Column col in ColumnCollection) ! { buf.Append( col.GetQuotedName(d) ); if (i < ColumnCollection.Count - 1) buf.Append(StringHelper.CommaSpace); Index: IRelationalModel.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IRelationalModel.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IRelationalModel.cs 26 Feb 2003 20:41:59 -0000 1.1 --- IRelationalModel.cs 13 Apr 2004 02:06:54 -0000 1.2 *************** *** 3,9 **** using NHibernate.Engine; ! namespace NHibernate.Mapping { ! ! public interface IRelationalModel { string SqlCreateString(Dialect.Dialect dialect, IMapping p); string SqlDropString(Dialect.Dialect dialect); --- 3,10 ---- using NHibernate.Engine; ! namespace NHibernate.Mapping ! { ! public interface IRelationalModel ! { string SqlCreateString(Dialect.Dialect dialect, IMapping p); string SqlDropString(Dialect.Dialect dialect); Index: Component.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Component.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Component.cs 17 Mar 2003 21:13:52 -0000 1.4 --- Component.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 3,31 **** using System.Collections; ! namespace NHibernate.Mapping { ! ! public class Component : Value { private ArrayList properties = new ArrayList(); private System.Type componentClass; private bool embedded; private string parentProperty; private PersistentClass owner; ! public int PropertySpan { get { return properties.Count; } } ! public ICollection PropertyCollection { get { return properties; } } ! public void AddProperty(Property p) { properties.Add(p); } ! public override void AddColumn(Column column) { throw new NotSupportedException("Cant add a column to a component"); } ! public override int ColumnSpan { ! get { int n=0; ! foreach(Property p in PropertyCollection) { n+= p.ColumnSpan; } --- 3,45 ---- using System.Collections; ! namespace NHibernate.Mapping ! { ! public class Component : Value ! { private ArrayList properties = new ArrayList(); private System.Type componentClass; + // TODO: H2.0.3 - make sure this is gone from the mapping file... + //private BasicDynaClass dynaClass private bool embedded; private string parentProperty; private PersistentClass owner; ! public int PropertySpan ! { get { return properties.Count; } } ! ! public ICollection PropertyCollection ! { get { return properties; } } ! ! public void AddProperty(Property p) ! { properties.Add(p); } ! ! public override void AddColumn(Column column) ! { throw new NotSupportedException("Cant add a column to a component"); } ! ! public override int ColumnSpan ! { ! get ! { int n=0; ! foreach(Property p in PropertyCollection) ! { n+= p.ColumnSpan; } *************** *** 35,39 **** public override ICollection ColumnCollection { ! get { ArrayList retVal = new ArrayList(); foreach(Property prop in PropertyCollection) { --- 49,54 ---- public override ICollection ColumnCollection { ! get ! { ArrayList retVal = new ArrayList(); foreach(Property prop in PropertyCollection) { *************** *** 44,83 **** } ! public Component(PersistentClass owner) : base(owner.Table) { this.owner = owner; } ! public Component(Table table) : base(table) { this.owner = null; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { } ! public bool IsEmbedded { get { return embedded; } set { embedded = value; } } ! public override bool IsComposite { get { return true; } } ! public System.Type ComponentClass { get { return componentClass; } set { componentClass = value; } } ! public PersistentClass Owner { get { return owner; } set { owner = value; } } ! public string ParentProperty { get { return parentProperty; } set { parentProperty = value; } } ! public ArrayList Properties { get { return properties; } } --- 59,107 ---- } ! public Component(PersistentClass owner) : base(owner.Table) ! { this.owner = owner; } ! public Component(Table table) : base(table) ! { this.owner = null; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { } ! public bool IsEmbedded ! { get { return embedded; } set { embedded = value; } } ! public override bool IsComposite ! { get { return true; } } ! public System.Type ComponentClass ! { get { return componentClass; } set { componentClass = value; } } ! public PersistentClass Owner ! { get { return owner; } set { owner = value; } } ! public string ParentProperty ! { get { return parentProperty; } set { parentProperty = value; } } ! public ArrayList Properties ! { get { return properties; } } Index: IntegerValue.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IntegerValue.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IntegerValue.cs 10 Feb 2004 18:35:30 -0000 1.3 --- IntegerValue.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 2,12 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class IntegerValue : Value{ ! public IntegerValue(Table table) : base(table) { } ! public override IType Type { get { return NHibernate.Int32; } } --- 2,13 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class IntegerValue : Value ! { public IntegerValue(Table table) : base(table) { } ! public override IType Type ! { get { return NHibernate.Int32; } } Index: UniqueKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/UniqueKey.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UniqueKey.cs 10 Apr 2004 05:06:02 -0000 1.3 --- UniqueKey.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 1,14 **** using System; - using System.Text; using System.Collections; ! using NHibernate.Util; using NHibernate.Dialect; namespace NHibernate.Mapping ! { ! public class UniqueKey : Constraint { - public string SqlConstraintString(Dialect.Dialect d) { --- 1,13 ---- using System; using System.Collections; ! using System.Text; ! using NHibernate.Dialect; + using NHibernate.Util; namespace NHibernate.Mapping ! { public class UniqueKey : Constraint { public string SqlConstraintString(Dialect.Dialect d) { Index: Value.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Value.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Value.cs 22 Apr 2003 19:46:38 -0000 1.8 --- Value.cs 13 Apr 2004 02:06:54 -0000 1.9 *************** *** 7,11 **** using NHibernate.Util; ! namespace NHibernate.Mapping { /// <summary> /// A value represents a simple thing that maps down to a table column or columns. --- 7,12 ---- using NHibernate.Util; ! namespace NHibernate.Mapping ! { /// <summary> /// A value represents a simple thing that maps down to a table column or columns. *************** *** 13,17 **** /// of this class /// </summary> ! public class Value { private ArrayList columns = new ArrayList(); private IType type; --- 14,19 ---- /// of this class /// </summary> ! public class Value ! { private ArrayList columns = new ArrayList(); private IType type; *************** *** 20,47 **** private string nullValue; private Table table; ! public Value(Table table) { this.table = table; } ! public virtual void AddColumn(Column column) { if ( !columns.Contains(column) ) columns.Add(column); } ! public virtual int ColumnSpan { get { return columns.Count; } } ! public virtual ICollection ColumnCollection { get { return columns; } } ! public virtual IList ConstraintColumns { get { return columns; } } ! 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++; --- 22,60 ---- private string nullValue; private Table table; + private Formula formula; ! public Value(Table table) ! { this.table = table; } ! public virtual void AddColumn(Column column) ! { if ( !columns.Contains(column) ) columns.Add(column); } ! public virtual int ColumnSpan ! { get { return columns.Count; } } ! public virtual ICollection ColumnCollection ! { get { return columns; } } ! ! public virtual IList ConstraintColumns ! { get { return columns; } } ! ! 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++; *************** *** 50,94 **** } ! public Table Table { get { return table; } set { table = value; } } ! public virtual void CreateForeignKey() { } ! public void CreateForeignKeyOfClass(System.Type persistentClass) { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } ! public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect) { ! ! return IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect); } ! 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); } } ! public virtual OuterJoinLoaderType OuterJoinFetchSetting { ! get { ! return OuterJoinLoaderType.Lazy; ! } ! set { ! throw new NotSupportedException(); ! } } --- 63,125 ---- } ! public Table Table ! { get { return table; } set { table = value; } } ! public virtual void CreateForeignKey() ! { } ! public void CreateForeignKeyOfClass(System.Type persistentClass) ! { ForeignKey fk = table.CreateForeignKey( ConstraintColumns ); fk.ReferencedClass = persistentClass; } ! private IIdentifierGenerator uniqueIdentifierGenerator; ! ! public IIdentifierGenerator CreateIdentifierGenerator(Dialect.Dialect dialect) ! { ! if ( uniqueIdentifierGenerator==null ) ! { ! uniqueIdentifierGenerator = IdentifierGeneratorFactory.Create(identifierGeneratorStrategy, type, identifierGeneratorProperties, dialect); ! } + return uniqueIdentifierGenerator; } ! 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); } } ! public virtual OuterJoinLoaderType OuterJoinFetchSetting ! { ! get { return OuterJoinLoaderType.Lazy; } ! set { throw new NotSupportedException(); } ! } ! ! public IDictionary IdentifierGeneratorProperties ! { ! get { return identifierGeneratorProperties; } ! set { identifierGeneratorProperties = value; } } *************** *** 98,105 **** } ! public IDictionary IdentifierGeneratorProperties { ! get { return identifierGeneratorProperties; } ! set { identifierGeneratorProperties = value; } ! } public virtual bool IsComposite { --- 129,133 ---- } ! public virtual bool IsComposite { *************** *** 107,120 **** } ! public string NullValue { get { return nullValue; } set { nullValue = value; } } ! public virtual bool IsAny { ! get { ! return false; ! } ! } } } --- 135,155 ---- } ! public string NullValue ! { get { return nullValue; } set { nullValue = value; } } ! public virtual bool IsAny ! { ! get { return false; } ! } ! ! ! public Formula Formula ! { ! get { return formula; } ! set { formula = value; } ! } } } Index: Any.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Any.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Any.cs 10 Feb 2004 18:35:30 -0000 1.3 --- Any.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 10,20 **** private IType metaType = TypeFactory.GetTypeType(); ! public Any(Table table) : base(table){ } ! public override bool IsAny { ! get { ! return true; ! } } --- 10,20 ---- private IType metaType = TypeFactory.GetTypeType(); ! public Any(Table table) : base(table) ! { } ! public override bool IsAny ! { ! get { return true; } } *************** *** 22,41 **** /// Get or set the identifier type /// </summary> ! public virtual IType IdentifierType { ! get { ! return identifierType; ! } ! set { ! this.identifierType = value; ! } } ! public override IType Type { ! get { ! return new ObjectType(metaType, identifierType); ! } ! set { ! throw new NotSupportedException("cannot set type of an Any"); ! } } --- 22,35 ---- /// Get or set the identifier type /// </summary> ! public virtual IType IdentifierType ! { ! get { return identifierType; } ! set { this.identifierType = value; } } ! public override IType Type ! { ! get { return new ObjectType(metaType, identifierType); } ! set { throw new NotSupportedException("cannot set type of an Any"); } } *************** *** 45,55 **** /// Get or set the metatype /// </summary> ! public virtual IType MetaType { ! get { ! return metaType; ! } ! set { ! metaType = value; ! } } } --- 39,46 ---- /// Get or set the metatype /// </summary> ! public virtual IType MetaType ! { ! get { return metaType; } ! set { metaType = value; } } } Index: Association.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Association.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Association.cs 4 Mar 2003 03:59:27 -0000 1.2 --- Association.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 2,13 **** using NHibernate.Loader; ! namespace NHibernate.Mapping { ! public abstract class Association : Value { private OuterJoinLoaderType joinedFetch; protected Association(Table table) : base(table) {} ! public override OuterJoinLoaderType OuterJoinFetchSetting { get { return joinedFetch; } set { joinedFetch = value; } --- 2,16 ---- using NHibernate.Loader; ! namespace NHibernate.Mapping ! { ! public abstract class Association : Value ! { private OuterJoinLoaderType joinedFetch; protected Association(Table table) : base(table) {} ! public override OuterJoinLoaderType OuterJoinFetchSetting ! { get { return joinedFetch; } set { joinedFetch = value; } Index: Set.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Set.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Set.cs 8 Apr 2004 21:11:32 -0000 1.3 --- Set.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 4,9 **** using NHibernate.Type; ! namespace NHibernate.Mapping { ! /// <summary> /// A Set with no nullable element columns will have a primary --- 4,9 ---- using NHibernate.Type; ! namespace NHibernate.Mapping ! { /// <summary> /// A Set with no nullable element columns will have a primary *************** *** 11,15 **** /// element columns). /// </summary> ! public class Set : Collection { public Set(PersistentClass owner) : base(owner) { } --- 11,16 ---- /// element columns). /// </summary> ! public class Set : Collection ! { public Set(PersistentClass owner) : base(owner) { } *************** *** 18,23 **** /// <see cref="Collection.IsSet"/> /// </summary> ! public override bool IsSet { ! get {return true; } } --- 19,25 ---- /// <see cref="Collection.IsSet"/> /// </summary> ! public override bool IsSet ! { ! get { return true; } } *************** *** 25,30 **** /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type { ! get { //TODO: modify when added implementation of sorted set return IsSorted ? --- 27,34 ---- /// <see cref="Collection.Type"/> /// </summary> ! public override PersistentCollectionType Type ! { ! get ! { //TODO: modify when added implementation of sorted set return IsSorted ? *************** *** 37,42 **** /// <see cref="Collection.WrapperClass"/> /// </summary> ! public override System.Type WrapperClass { ! get { return IsSorted ? typeof(NCollection.SortedSet) : --- 41,48 ---- /// <see cref="Collection.WrapperClass"/> /// </summary> ! public override System.Type WrapperClass ! { ! get ! { return IsSorted ? typeof(NCollection.SortedSet) : *************** *** 46,57 **** ! 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); --- 52,66 ---- ! 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); *************** *** 61,68 **** // column in a primary key - others (DB2) won't if(!nullable) Table.PrimaryKey = pk; - } - - } } --- 70,74 ---- Index: OneToOne.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/OneToOne.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OneToOne.cs 4 Mar 2003 03:59:28 -0000 1.2 --- OneToOne.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 1,35 **** using System; using System.Collections; using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.Mapping { ! ! public class OneToOne : Association { private bool constrained; private ForeignKeyType foreignKeyType; private Value identifier; ! public OneToOne(Table table, Value identifier) : base(table) { this.identifier = identifier; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) { ! try { if (Type==null) Type = TypeFactory.OneToOne(ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType, foreignKeyType); ! } catch (HibernateException he) { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() { if (constrained) CreateForeignKeyOfClass( ((EntityType)Type).PersistentClass ); } ! public override IList ConstraintColumns { ! get { ArrayList list = new ArrayList(); ! foreach(object obj in identifier.ColumnCollection) { list.Add(obj); } --- 1,46 ---- using System; using System.Collections; + using NHibernate.Util; using NHibernate.Type; ! namespace NHibernate.Mapping ! { ! public class OneToOne : Association ! { private bool constrained; private ForeignKeyType foreignKeyType; private Value identifier; ! public OneToOne(Table table, Value identifier) : base(table) ! { this.identifier = identifier; } ! public override void SetTypeByReflection(System.Type propertyClass, string propertyName) ! { ! try ! { if (Type==null) Type = TypeFactory.OneToOne(ReflectHelper.GetGetter(propertyClass, propertyName).ReturnType, foreignKeyType); ! } ! catch (HibernateException he) ! { throw new MappingException("Problem trying to set association type by reflection", he); } } ! public override void CreateForeignKey() ! { if (constrained) CreateForeignKeyOfClass( ((EntityType)Type).PersistentClass ); } ! public override IList ConstraintColumns ! { ! get ! { ArrayList list = new ArrayList(); ! foreach(object obj in identifier.ColumnCollection) ! { list.Add(obj); } *************** *** 38,52 **** } ! public bool IsConstrained { get { return constrained; } set { constrained = value; } } ! public ForeignKeyType ForeignKeyType { get { return foreignKeyType; } set { foreignKeyType = value; } } ! public Value Identifier { get { return identifier; } set { identifier = value; } --- 49,66 ---- } ! public bool IsConstrained ! { get { return constrained; } set { constrained = value; } } ! public ForeignKeyType ForeignKeyType ! { get { return foreignKeyType; } set { foreignKeyType = value; } } ! public Value Identifier ! { get { return identifier; } set { identifier = value; } Index: Index.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/Index.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Index.cs 10 Apr 2004 05:06:02 -0000 1.3 --- Index.cs 13 Apr 2004 02:06:54 -0000 1.4 *************** *** 6,17 **** using NHibernate.Dialect; ! namespace NHibernate.Mapping { ! ! public class Index : IRelationalModel { private Table table; private ArrayList columns = new ArrayList(); private string name; ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) { StringBuilder buf = new StringBuilder("create index ") .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) --- 6,19 ---- using NHibernate.Dialect; ! namespace NHibernate.Mapping ! { ! public class Index : IRelationalModel ! { private Table table; private ArrayList columns = new ArrayList(); private string name; ! public string SqlCreateString(Dialect.Dialect dialect, IMapping p) ! { StringBuilder buf = new StringBuilder("create index ") .Append( dialect.QualifyIndexName ? name : StringHelper.Unqualify(name) ) *************** *** 19,48 **** .Append( table.GetQualifiedName(dialect)) .Append(" ("); ! for(int i=0; i<columns.Count; i++) { buf.Append( ((Column)columns[i]).GetQuotedName(dialect) ); - if (i<columns.Count-1) buf.Append(StringHelper.CommaSpace); } buf.Append(StringHelper.ClosedParen); return buf.ToString(); } ! public string SqlDropString(Dialect.Dialect dialect) { return "drop index " + table.GetQualifiedName(dialect) + StringHelper.Dot + name; } ! public Table Table { get { return table; } set { table = value; } } ! public ICollection ColumnCollection { get { return columns; } } ! public void AddColumn(Column column) { if (!columns.Contains(column)) columns.Add(column); } ! public string Name { get { return name; } set { name = value; } --- 21,61 ---- .Append( table.GetQualifiedName(dialect)) .Append(" ("); ! ! bool commaNeeded = false; ! for(int i=0; i<columns.Count; i++) ! { ! if(commaNeeded) buf.Append(StringHelper.CommaSpace); ! commaNeeded = true; ! buf.Append( ((Column)columns[i]).GetQuotedName(dialect) ); } + buf.Append(StringHelper.ClosedParen); return buf.ToString(); } ! public string SqlDropString(Dialect.Dialect dialect) ! { return "drop index " + table.GetQualifiedName(dialect) + StringHelper.Dot + name; } ! public Table Table ! { get { return table; } set { table = value; } } ! public ICollection ColumnCollection ! { get { return columns; } } ! public void AddColumn(Column column) ! { if (!columns.Contains(column)) columns.Add(column); } ! public string Name ! { get { return name; } set { name = value; } Index: IndexedCollection.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/IndexedCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndexedCollection.cs 28 Feb 2003 22:14:00 -0000 1.2 --- IndexedCollection.cs 13 Apr 2004 02:06:54 -0000 1.3 *************** *** 1,30 **** using System; ! namespace NHibernate.Mapping { ! ! public abstract class IndexedCollection : Collection { public const string DefaultIndexColumnName = "idx"; private Value index; ! public IndexedCollection(PersistentClass owner) : base(owner) { } ! public Value Index { get { return index; } set { index = value; } } ! public override bool IsIndexed { get { return true; } } ! 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; } --- 1,44 ---- using System; ! namespace NHibernate.Mapping ! { ! /// <summary> ! /// Indexed collections include IList, IDictionary, Arrays ! /// and primitive Arrays. ! /// </summary> ! public abstract class IndexedCollection : Collection ! { public const string DefaultIndexColumnName = "idx"; private Value index; ! public IndexedCollection(PersistentClass owner) : base(owner) ! { ! } ! public Value Index ! { get { return index; } set { index = value; } } ! public override bool IsIndexed ! { get { return true; } } ! 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; } Index: ForeignKey.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Mapping/ForeignKey.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ForeignKey.cs 10 Apr 2004 05:06:02 -0000 1.4 --- ForeignKey.cs 13 Apr 2004 02:06:54 -0000 1.5 *************** *** 3,31 **** using NHibernate.Dialect; ! namespace NHibernate.Mapping { ! ! public class ForeignKey : Constraint { private Table referencedTable; private System.Type referencedClass; ! public override string SqlConstraintString(Dialect.Dialect d, string constraintName) { string[] cols = new string[ ColumnSpan ]; string[] refcols = new string[ ColumnSpan ]; int i=0; ! foreach(Column ... [truncated message content] |