|
From: <fab...@us...> - 2009-12-01 14:26:42
|
Revision: 4881
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4881&view=rev
Author: fabiomaulo
Date: 2009-12-01 14:26:29 +0000 (Tue, 01 Dec 2009)
Log Message:
-----------
binders refactoring
-ColumnsBinder on the road
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmId.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace NHibernate.Cfg.MappingSchema
@@ -2,3 +3,3 @@
{
- public partial class HbmId: IColumnsMapping
+ public partial class HbmId: AbstractDecoratable, IColumnsMapping
{
@@ -28,5 +29,14 @@
};
}
}
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -7,16 +7,15 @@
{
public class ClassCompositeIdBinder : ClassBinder
{
- public ClassCompositeIdBinder(ClassBinder parent)
- : base(parent)
- {
- }
-
private Component compositeId;
+ public ClassCompositeIdBinder(ClassBinder parent) : base(parent) {}
+
public void BindCompositeId(HbmCompositeId idSchema, PersistentClass rootClass)
{
if (idSchema == null)
+ {
return;
+ }
compositeId = new Component(rootClass);
rootClass.Identifier = compositeId;
@@ -28,12 +27,11 @@
}
else
{
- System.Type reflectedClass = GetPropertyType(rootClass.MappedClass,
- idSchema.name, idSchema);
+ System.Type reflectedClass = GetPropertyType(rootClass.MappedClass, idSchema.name, idSchema);
BindComponent(reflectedClass, idSchema.name, idSchema);
- Mapping.Property prop = new Mapping.Property(compositeId);
+ var prop = new Property(compositeId);
BindProperty(prop, idSchema);
rootClass.IdentifierProperty = prop;
}
@@ -43,24 +41,22 @@
System.Type compIdClass = compositeId.ComponentClass;
if (!ReflectHelper.OverridesEquals(compIdClass))
- throw new MappingException(
- "composite-id class must override Equals(): " + compIdClass.FullName
- );
+ {
+ throw new MappingException("composite-id class must override Equals(): " + compIdClass.FullName);
+ }
if (!ReflectHelper.OverridesGetHashCode(compIdClass))
- throw new MappingException(
- "composite-id class must override GetHashCode(): " + compIdClass.FullName
- );
+ {
+ throw new MappingException("composite-id class must override GetHashCode(): " + compIdClass.FullName);
+ }
// Serializability check not ported
}
- private void BindComponent(System.Type reflectedClass, string path,
- HbmCompositeId idSchema)
+ private void BindComponent(System.Type reflectedClass, string path, HbmCompositeId idSchema)
{
if (idSchema.@class != null)
{
- compositeId.ComponentClass = ClassForNameChecked(idSchema.@class, mappings,
- "component class not found: {0}");
+ compositeId.ComponentClass = ClassForNameChecked(idSchema.@class, mappings, "component class not found: {0}");
compositeId.IsEmbedded = false;
}
@@ -78,48 +74,45 @@
foreach (object item in idSchema.Items ?? new object[0])
{
- HbmKeyManyToOne keyManyToOneSchema = item as HbmKeyManyToOne;
- HbmKeyProperty keyPropertySchema = item as HbmKeyProperty;
+ var keyManyToOneSchema = item as HbmKeyManyToOne;
+ var keyPropertySchema = item as HbmKeyProperty;
if (keyManyToOneSchema != null)
{
- ManyToOne manyToOne = new ManyToOne(compositeId.Table);
+ var manyToOne = new ManyToOne(compositeId.Table);
- string propertyName = keyManyToOneSchema.name == null
- ? null
- : StringHelper.Qualify(path, keyManyToOneSchema.name);
+ string propertyName = keyManyToOneSchema.name == null ? null : StringHelper.Qualify(path, keyManyToOneSchema.name);
BindManyToOne(keyManyToOneSchema, manyToOne, propertyName, false);
- Mapping.Property property = CreateProperty(manyToOne, keyManyToOneSchema.name,
- compositeId.ComponentClass, keyManyToOneSchema);
+ Property property = CreateProperty(manyToOne, keyManyToOneSchema.name, compositeId.ComponentClass,
+ keyManyToOneSchema);
compositeId.AddProperty(property);
}
else if (keyPropertySchema != null)
{
- SimpleValue value = new SimpleValue(compositeId.Table);
+ var value = new SimpleValue(compositeId.Table);
- string propertyName = keyPropertySchema.name == null
- ? null
- : StringHelper.Qualify(path, keyPropertySchema.name);
+ string propertyName = keyPropertySchema.name == null ? null : StringHelper.Qualify(path, keyPropertySchema.name);
BindSimpleValue(keyPropertySchema, value, false, propertyName);
- Mapping.Property property = CreateProperty(value, keyPropertySchema.name,
- compositeId.ComponentClass, keyPropertySchema);
+ Property property = CreateProperty(value, keyPropertySchema.name, compositeId.ComponentClass, keyPropertySchema);
compositeId.AddProperty(property);
}
}
}
- private void BindProperty(Mapping.Property property, HbmCompositeId idSchema)
+ private void BindProperty(Property property, HbmCompositeId idSchema)
{
property.Name = idSchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = idSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
@@ -132,14 +125,17 @@
LogMappedProperty(property);
}
- private System.Type GetPropertyType(System.Type containingType, string propertyName,
- HbmCompositeId idSchema)
+ private System.Type GetPropertyType(System.Type containingType, string propertyName, HbmCompositeId idSchema)
{
if (idSchema.@class != null)
+ {
return ClassForNameChecked(idSchema.@class, mappings, "could not find class: {0}");
+ }
else if (containingType == null)
+ {
return null;
+ }
else
{
@@ -149,14 +145,15 @@
}
private void BindManyToOne(HbmKeyManyToOne keyManyToOneSchema, ManyToOne manyToOne, string defaultColumnName,
- bool isNullable)
+ bool isNullable)
{
- BindColumns(keyManyToOneSchema, manyToOne, isNullable, true, defaultColumnName);
+ new ColumnsBinder(manyToOne, mappings).Bind(keyManyToOneSchema.Columns, isNullable,
+ () => new HbmColumn { name = mappings.NamingStrategy.PropertyToColumnName(defaultColumnName) });
manyToOne.FetchMode = FetchMode.Default;
manyToOne.IsLazy = !keyManyToOneSchema.lazySpecified
- ? manyToOne.IsLazy
- : keyManyToOneSchema.lazy == HbmRestrictedLaziness.Proxy;
+ ? manyToOne.IsLazy
+ : keyManyToOneSchema.lazy == HbmRestrictedLaziness.Proxy;
string typeNode = keyManyToOneSchema.@class;
if (typeNode != null)
@@ -171,81 +168,25 @@
manyToOne.IsIgnoreNotFound = false;
if (keyManyToOneSchema.foreignkey != null)
- manyToOne.ForeignKeyName = keyManyToOneSchema.foreignkey;
- }
-
- private void BindColumns(HbmKeyManyToOne keyManyToOneSchema, SimpleValue model, bool isNullable,
- bool autoColumn, string propertyPath)
- {
- Table table = model.Table;
- //COLUMN(S)
- if (keyManyToOneSchema.column1 == null)
{
- int count = 0;
-
- foreach (HbmColumn columnSchema in keyManyToOneSchema.column ?? new HbmColumn[0])
- {
- Column col = new Column();
- col.Value = model;
- col.TypeIndex = count++;
- BindColumn(columnSchema, col, isNullable);
-
- string name = columnSchema.name;
- col.Name = mappings.NamingStrategy.ColumnName(name);
- if (table != null)
- table.AddColumn(col);
- //table=null -> an association, fill it in later
- model.AddColumn(col);
-
- //column index
- BindIndex(columnSchema.index, table, col);
- //column group index (although it can serve as a separate column index)
-
- BindUniqueKey(columnSchema.uniquekey, table, col);
- }
+ manyToOne.ForeignKeyName = keyManyToOneSchema.foreignkey;
}
- else
- {
- Column col = new Column();
- col.Value = compositeId;
- BindColumn(col, isNullable);
- col.Name = mappings.NamingStrategy.ColumnName(keyManyToOneSchema.column1);
- if (table != null)
- table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
-
- if (autoColumn && model.ColumnSpan == 0)
- {
- Column col = new Column();
- col.Value = model;
- BindColumn(col, isNullable);
- col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath);
- model.Table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
}
- private static void BindColumn(Column model, bool isNullable)
- {
- model.IsNullable = isNullable;
- model.IsUnique = false;
- model.CheckConstraint = string.Empty;
- model.SqlType = null;
- }
-
private Property CreateProperty(ToOne value, string propertyName, System.Type parentClass,
- HbmKeyManyToOne keyManyToOneSchema)
+ HbmKeyManyToOne keyManyToOneSchema)
{
if (parentClass != null && value.IsSimpleValue)
+ {
value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName,
keyManyToOneSchema.access ?? mappings.DefaultAccess);
+ }
string propertyRef = value.ReferencedPropertyName;
if (propertyRef != null)
+ {
mappings.AddUniquePropertyReference(value.ReferencedEntityName, propertyRef);
+ }
value.CreateForeignKey();
var prop = new Property {Value = value};
@@ -259,7 +200,9 @@
property.Name = keyManyToOneSchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = keyManyToOneSchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
@@ -275,80 +218,21 @@
private void BindSimpleValue(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, string path)
{
if (keyPropertySchema.type1 != null)
- model.TypeName = keyPropertySchema.type1;
- BindColumns(keyPropertySchema, model, isNullable, true, path);
- }
-
- private void BindColumns(HbmKeyProperty keyPropertySchema, SimpleValue model, bool isNullable, bool autoColumn,
- string propertyPath)
- {
- Table table = model.Table;
-
- if (keyPropertySchema.column1 == null)
{
- int count = 0;
-
- foreach (HbmColumn columnSchema in keyPropertySchema.column ?? new HbmColumn[0])
- {
- Column col = new Column();
- col.Value = model;
- col.TypeIndex = count++;
- BindColumn(columnSchema, col, isNullable);
-
- col.Name = mappings.NamingStrategy.ColumnName(columnSchema.name);
- if (table != null)
- table.AddColumn(col);
- //table=null -> an association, fill it in later
- model.AddColumn(col);
-
- //column index
- BindIndex(columnSchema.index, table, col);
- //column group index (although it can serve as a separate column index)
-
- BindUniqueKey(columnSchema.uniquekey, table, col);
- }
+ model.TypeName = keyPropertySchema.type1;
}
- else
- {
- Column col = new Column();
- col.Value = compositeId;
- BindColumn(keyPropertySchema, col, isNullable);
- col.Name = mappings.NamingStrategy.ColumnName(keyPropertySchema.column1);
- if (table != null)
- table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
-
- if (autoColumn && model.ColumnSpan == 0)
- {
- Column col = new Column();
- col.Value = model;
- BindColumn(keyPropertySchema, col, isNullable);
- col.Name = mappings.NamingStrategy.PropertyToColumnName(propertyPath);
- model.Table.AddColumn(col);
- model.AddColumn(col);
- //column group index (although can serve as a separate column index)
- }
+ new ColumnsBinder(model, Mappings).Bind(keyPropertySchema.Columns, isNullable,
+ () => new HbmColumn { name = mappings.NamingStrategy.PropertyToColumnName(path), length = keyPropertySchema.length });
}
- private static void BindColumn(HbmKeyProperty keyPropertySchema, Column model, bool isNullable)
- {
- if (keyPropertySchema.length != null)
- model.Length = int.Parse(keyPropertySchema.length);
-
- model.IsNullable = isNullable;
- model.IsUnique = false;
- model.CheckConstraint = string.Empty;
- model.SqlType = null;
- }
-
private Property CreateProperty(SimpleValue value, string propertyName, System.Type parentClass,
- HbmKeyProperty keyPropertySchema)
+ HbmKeyProperty keyPropertySchema)
{
if (parentClass != null && value.IsSimpleValue)
+ {
value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName,
keyPropertySchema.access ?? mappings.DefaultAccess);
+ }
// This is done here 'cos we might only know the type here (ugly!)
var toOne = value as ToOne;
@@ -356,7 +240,9 @@
{
string propertyRef = toOne.ReferencedPropertyName;
if (propertyRef != null)
+ {
mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef);
+ }
}
value.CreateForeignKey();
@@ -371,7 +257,9 @@
property.Name = keyPropertySchema.name;
if (property.Value.Type == null)
+ {
throw new MappingException("could not determine a property type for: " + property.Name);
+ }
property.PropertyAccessorName = keyPropertySchema.access ?? mappings.DefaultAccess;
property.Cascade = mappings.DefaultCascade;
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -1,5 +1,5 @@
+using System;
using System.Collections.Generic;
-using System.Xml;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping;
using NHibernate.Util;
@@ -17,9 +17,16 @@
{
if (idSchema != null)
{
- SimpleValue id = CreateIdentifier(idSchema, rootClass, table);
+ var id = new SimpleValue(table) { TypeName = idSchema.type1 };
+ rootClass.Identifier = id;
- AddColumns(idSchema, id);
+ Func<HbmColumn> defaultColumn = () => new HbmColumn
+ {
+ name = idSchema.name ?? RootClass.DefaultIdentifierColumnName,
+ length = idSchema.length
+ };
+ new ColumnsBinder(id, Mappings).Bind(idSchema.Columns, false, defaultColumn);
+
CreateIdentifierProperty(idSchema, rootClass, id);
VerifiyIdTypeIsValid(id, rootClass.EntityName);
BindGenerator(idSchema, id);
@@ -28,26 +35,6 @@
}
}
- private static SimpleValue CreateIdentifier(HbmId idSchema, PersistentClass rootClass, Table table)
- {
- SimpleValue iv = new SimpleValue(table);
- iv.TypeName = idSchema.type1;
- rootClass.Identifier = iv;
-
- return iv;
- }
-
- private void AddColumns(HbmId idSchema, SimpleValue id)
- {
- if (idSchema.column1 != null)
- AddColumnFromAttribute(idSchema, id);
- else
- AddColumnsFromList(idSchema, id);
-
- if (id.ColumnSpan == 0)
- AddDefaultColumn(idSchema, id);
- }
-
private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, SimpleValue id)
{
if (idSchema.name != null)
@@ -56,8 +43,7 @@
id.SetTypeUsingReflection(rootClass.MappedClass == null ? null : rootClass.MappedClass.AssemblyQualifiedName,
idSchema.name, access);
- Property property = new Property(id);
- property.Name = idSchema.name;
+ var property = new Property(id) {Name = idSchema.name};
if (property.Value.Type == null)
throw new MappingException("could not determine a property type for: " + property.Name);
@@ -68,7 +54,7 @@
property.IsInsertable = true;
property.IsOptimisticLocked = true;
property.Generation = PropertyGeneration.Never;
- property.MetaAttributes = GetMetas(idSchema);
+ property.MetaAttributes = GetMetas(idSchema, EmptyMeta);
rootClass.IdentifierProperty = property;
@@ -114,7 +100,7 @@
private IDictionary<string,string> GetGeneratorProperties(HbmId idSchema, IValue id)
{
- Dictionary<string, string> results = new Dictionary<string, string>();
+ var results = new Dictionary<string, string>();
if (id.Table.Schema != null)
results.Add(Id.PersistentIdGeneratorParmsNames.Schema, id.Table.Schema);
@@ -131,110 +117,5 @@
{
id.NullValue = idSchema.unsavedvalue ?? (id.IdentifierGeneratorStrategy == "assigned" ? "undefined" : null);
}
-
- private void AddColumnFromAttribute(HbmId idSchema, SimpleValue id)
- {
- Column column = CreateColumn(idSchema);
- column.Value = id;
- column.Name = mappings.NamingStrategy.ColumnName(idSchema.column1);
-
- if (id.Table != null)
- id.Table.AddColumn(column);
-
- id.AddColumn(column);
- }
-
- private void AddColumnsFromList(HbmId idSchema, SimpleValue id)
- {
- int count = 0;
-
- foreach (HbmColumn columnSchema in idSchema.column ?? new HbmColumn[0])
- {
- Column column = CreateColumn(columnSchema, id, count++);
- column.Name = mappings.NamingStrategy.ColumnName(columnSchema.name);
-
- if (id.Table != null)
- id.Table.AddColumn(column);
- //table=null -> an association, fill it in later
-
- id.AddColumn(column);
-
- if (columnSchema.index != null && id.Table != null)
- {
- var tokens = new StringTokenizer(columnSchema.index, ",", false);
- foreach (string token in tokens)
- id.Table.GetOrCreateIndex(token.Trim()).AddColumn(column);
- }
-
- if (columnSchema.uniquekey != null && id.Table != null)
- {
- var tokens = new StringTokenizer(columnSchema.uniquekey, ",", false);
- foreach (string token in tokens)
- id.Table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column);
- }
- }
- }
-
- private void AddDefaultColumn(HbmId idSchema, SimpleValue id)
- {
- Column column = CreateColumn(idSchema);
- column.Value = id;
- string propertyName = idSchema.name ?? RootClass.DefaultIdentifierColumnName;
- column.Name = mappings.NamingStrategy.PropertyToColumnName(propertyName);
-
- id.Table.AddColumn(column);
- id.AddColumn(column);
- }
-
- private static IDictionary<string, MetaAttribute> GetMetas(HbmId idSchema)
- {
- Dictionary<string, MetaAttribute> map = new Dictionary<string, MetaAttribute>();
-
- foreach (HbmMeta metaSchema in idSchema.meta ?? new HbmMeta[0])
- {
- MetaAttribute meta;
- if (!map.TryGetValue(metaSchema.attribute, out meta))
- {
- meta = new MetaAttribute(metaSchema.attribute);
- map[metaSchema.attribute] = meta;
- }
-
- meta.AddValue(metaSchema.GetText());
- }
-
- return map;
- }
-
- private static Column CreateColumn(HbmId idSchema)
- {
- Column column = new Column();
-
- if (idSchema.length != null)
- column.Length = int.Parse(idSchema.length);
-
- column.IsNullable = false;
- column.IsUnique = false;
- column.CheckConstraint = string.Empty;
- column.SqlType = null;
-
- return column;
- }
-
- private static Column CreateColumn(HbmColumn columnSchema, IValue type, int index)
- {
- Column column = new Column();
- column.Value = type;
- column.TypeIndex = index;
-
- if (columnSchema.length != null)
- column.Length = int.Parse(columnSchema.length);
-
- column.IsNullable = columnSchema.notnullSpecified ? !columnSchema.notnull : false;
- column.IsUnique = columnSchema.uniqueSpecified && columnSchema.unique;
- column.CheckConstraint = columnSchema.check ?? string.Empty;
- column.SqlType = columnSchema.sqltype;
-
- return column;
- }
}
}
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ColumnsBinder.cs 2009-12-01 14:26:29 UTC (rev 4881)
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class ColumnsBinder: Binder
+ {
+ private readonly SimpleValue value;
+
+ public ColumnsBinder(SimpleValue value, Mappings mappings)
+ : base(mappings)
+ {
+ this.value = value;
+ }
+
+ public void Bind(IEnumerable<HbmColumn> columns, bool isNullable, Func<HbmColumn> defaultColumnDelegate)
+ {
+ var table = value.Table;
+ int colIndex = 0;
+ foreach (var hbmColumn in columns)
+ {
+ BindColumn(hbmColumn, table, colIndex++, isNullable);
+ }
+
+ if (value.ColumnSpan == 0 && defaultColumnDelegate != null)
+ {
+ BindColumn(defaultColumnDelegate(), table, colIndex, isNullable);
+ }
+ }
+
+ private void BindColumn(HbmColumn hbmColumn, Table table, int colIndex, bool isNullable)
+ {
+ var col = new Column {Value = value, TypeIndex = colIndex};
+ BindColumn(hbmColumn, col, isNullable);
+
+ if (table != null)
+ table.AddColumn(col);
+
+ value.AddColumn(col);
+
+ //column index
+ BindIndex(hbmColumn.index, table, col);
+ //column group index (although it can serve as a separate column index)
+ BindUniqueKey(hbmColumn.uniquekey, table, col);
+ }
+
+ private void BindColumn(HbmColumn columnMapping, Column column, bool isNullable)
+ {
+ column.Name = mappings.NamingStrategy.ColumnName(columnMapping.name);
+
+ if (columnMapping.length != null)
+ column.Length = int.Parse(columnMapping.length);
+ if (columnMapping.scale != null)
+ column.Scale = int.Parse(columnMapping.scale);
+ if (columnMapping.precision != null)
+ column.Precision = int.Parse(columnMapping.precision);
+
+ column.IsNullable = columnMapping.notnullSpecified ? !columnMapping.notnull : isNullable;
+ column.IsUnique = columnMapping.uniqueSpecified && columnMapping.unique;
+ column.CheckConstraint = columnMapping.check ?? string.Empty;
+ column.SqlType = columnMapping.sqltype;
+ column.DefaultValue = columnMapping.@default;
+ if (columnMapping.comment != null)
+ column.Comment = columnMapping.comment.Text.LinesToString().Trim();
+ }
+
+ private static void BindIndex(string indexAttribute, Table table, Column column)
+ {
+ if (indexAttribute != null && table != null)
+ {
+ var tokens = indexAttribute.Split(',');
+ System.Array.ForEach(tokens, t => table.GetOrCreateIndex(t.Trim()).AddColumn(column));
+ }
+ }
+
+ private static void BindUniqueKey(string uniqueKeyAttribute, Table table, Column column)
+ {
+ if (uniqueKeyAttribute != null && table != null)
+ {
+ var tokens = uniqueKeyAttribute.Split(',');
+ System.Array.ForEach(tokens, t => table.GetOrCreateUniqueKey(t.Trim()).AddColumn(column));
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 00:18:30 UTC (rev 4880)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-12-01 14:26:29 UTC (rev 4881)
@@ -545,6 +545,7 @@
<Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" />
<Compile Include="Cfg\MappingSchema\HbmVersion.cs" />
<Compile Include="Cfg\MappingSchema\IDecoratable.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\ColumnsBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\FiltersBinder.cs" />
<Compile Include="Cfg\XmlHbmBinding\PropertiesBinder.cs">
<SubType>Code</SubType>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|