|
From: <fab...@us...> - 2009-11-30 03:21:11
|
Revision: 4875
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4875&view=rev
Author: fabiomaulo
Date: 2009-11-30 03:21:02 +0000 (Mon, 30 Nov 2009)
Log Message:
-----------
binders refactoring (pushing down the XML parsing)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs
trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmAny.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmAny : IEntityPropertyMapping
+ public partial class HbmAny : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,25 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #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/MappingSchema/HbmArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmArray.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmArray : ICollectionPropertyMapping
+ public partial class HbmArray : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmBag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmBag.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmBag : ICollectionPropertyMapping
+ public partial class HbmBag : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,34 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmClass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -26,6 +26,26 @@
get { return Item1 as HbmTimestamp; }
}
+ public IEnumerable<HbmJoin> Joins
+ {
+ get { return Items1 != null ? Items1.OfType<HbmJoin>(): new HbmJoin[0]; }
+ }
+
+ public IEnumerable<HbmSubclass> Subclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmSubclass>() : new HbmSubclass[0]; }
+ }
+
+ public IEnumerable<HbmJoinedSubclass> JoinedSubclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmJoinedSubclass>() : new HbmJoinedSubclass[0]; }
+ }
+
+ public IEnumerable<HbmUnionSubclass> UnionSubclasses
+ {
+ get { return Items1 != null ? Items1.OfType<HbmUnionSubclass>() : new HbmUnionSubclass[0]; }
+ }
+
#region Implementation of IEntityMapping
protected override HbmMeta[] Metadatas
@@ -137,7 +157,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>(): new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -4,7 +4,7 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmComponent : IEntityPropertyMapping, IPropertiesContainerMapping
+ public partial class HbmComponent : AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
{
#region Implementation of IEntityPropertyMapping
@@ -13,15 +13,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
#region Implementation of IPropertiesContainerMapping
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return meta ?? new HbmMeta[0]; }
+ }
+
+ #endregion
+
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace NHibernate.Cfg.MappingSchema
+{
+ public partial class HbmDynamicComponent: AbstractDecoratable, IEntityPropertyMapping, IPropertiesContainerMapping
+ {
+ #region Implementation of IEntityPropertyMapping
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
+ #endregion
+
+ #region Implementation of IPropertiesContainerMapping
+
+ public IEnumerable<IEntityPropertyMapping> Properties
+ {
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
+ }
+
+ #endregion
+
+ #region Overrides of AbstractDecoratable
+
+ protected override HbmMeta[] Metadatas
+ {
+ get { return new HbmMeta[0]; }
+ }
+
+ #endregion
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmExtensions.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,4 +1,3 @@
-using System;
using NHibernate.Engine;
namespace NHibernate.Cfg.MappingSchema
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmIdbag : ICollectionPropertyMapping
+ public partial class HbmIdbag : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,34 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmJoinedSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmJoinedSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,11 @@
{
public partial class HbmJoinedSubclass : AbstractDecoratable, IEntityMapping
{
+ public IEnumerable<HbmJoinedSubclass> JoinedSubclasses
+ {
+ get { return joinedsubclass1 ?? new HbmJoinedSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -110,7 +115,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmList.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmList : ICollectionPropertyMapping
+ public partial class HbmList : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmManyToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,8 @@
+using System;
+
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmManyToOne : IEntityPropertyMapping
+ public partial class HbmManyToOne : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +11,26 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #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/MappingSchema/HbmMap.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmMap.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmMap : ICollectionPropertyMapping
+ public partial class HbmMap : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmNaturalId.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmNaturalId.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -10,7 +10,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmOneToOne : IEntityPropertyMapping
+ public partial class HbmOneToOne : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,26 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return true; }
+ }
+
#endregion
+
+ #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/MappingSchema/HbmPrimitiveArray.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmPrimitiveArray : ICollectionPropertyMapping
+ public partial class HbmPrimitiveArray : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,7 +9,35 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
-
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return "none"; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmProperty : IEntityPropertyMapping
+ public partial class HbmProperty : AbstractDecoratable, IEntityPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,25 @@
get { return name; }
}
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
#endregion
+
+ #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/MappingSchema/HbmSet.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSet.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public partial class HbmSet : ICollectionPropertyMapping
+ public partial class HbmSet : AbstractDecoratable, ICollectionPropertyMapping
{
#region Implementation of IEntityPropertyMapping
@@ -9,6 +9,35 @@
get { return name; }
}
- #endregion
+ public string Access
+ {
+ get { return access; }
+ }
+
+ public bool OptimisticKock
+ {
+ get { return optimisticlock; }
+ }
+
+ #endregion
+
+ #region Implementation of IReferencePropertyMapping
+
+ public string Cascade
+ {
+ get { return cascade; }
+ }
+
+ #endregion
+
+ #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/MappingSchema/HbmSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,16 @@
{
public partial class HbmSubclass : AbstractDecoratable, IEntityMapping, IEntityDiscriminableMapping
{
+ public IEnumerable<HbmJoin> Joins
+ {
+ get { return join ?? new HbmJoin[0]; }
+ }
+
+ public IEnumerable<HbmSubclass> Subclasses
+ {
+ get { return subclass1 ?? new HbmSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -120,7 +130,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/HbmUnionSubclass.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -5,6 +5,11 @@
{
public partial class HbmUnionSubclass : AbstractDecoratable, IEntityMapping
{
+ public IEnumerable<HbmUnionSubclass> UnionSubclasses
+ {
+ get { return unionsubclass1 ?? new HbmUnionSubclass[0]; }
+ }
+
#region Overrides of AbstractDecoratable
protected override HbmMeta[] Metadatas
@@ -111,7 +116,7 @@
public IEnumerable<IEntityPropertyMapping> Properties
{
- get { return Items.Cast<IEntityPropertyMapping>(); }
+ get { return Items != null ? Items.Cast<IEntityPropertyMapping>() : new IEntityPropertyMapping[0]; }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/ICollectionPropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,6 +1,6 @@
namespace NHibernate.Cfg.MappingSchema
{
- public interface ICollectionPropertyMapping: IEntityPropertyMapping
+ public interface ICollectionPropertyMapping : IEntityPropertyMapping, IReferencePropertyMapping
{
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,7 +1,9 @@
namespace NHibernate.Cfg.MappingSchema
{
- public interface IEntityPropertyMapping
+ public interface IEntityPropertyMapping: IDecoratable
{
string Name { get; }
+ string Access { get; }
+ bool OptimisticKock { get; }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/IReferencePropertyMapping.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,7 @@
+namespace NHibernate.Cfg.MappingSchema
+{
+ public interface IReferencePropertyMapping
+ {
+ string Cascade { get; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/Binder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -25,14 +25,6 @@
protected readonly Mappings mappings;
- protected Binder(Binder parent)
- {
- if (parent == null)
- throw new ArgumentNullException("parent");
-
- mappings = parent.mappings;
- }
-
protected Binder(Mappings mappings)
{
if (mappings == null)
@@ -41,6 +33,11 @@
this.mappings = mappings;
}
+ public Mappings Mappings
+ {
+ get { return mappings; }
+ }
+
/// <summary>
/// Converts a partial class name into a fully qualified one
/// </summary>
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -16,127 +16,20 @@
protected readonly Dialect.Dialect dialect;
protected readonly XmlNamespaceManager namespaceManager;
- protected ClassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent)
+ protected ClassBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings)
{
this.dialect = dialect;
this.namespaceManager = namespaceManager;
}
protected ClassBinder(ClassBinder parent)
- : base(parent)
+ : base(parent.Mappings)
{
dialect = parent.dialect;
namespaceManager = parent.namespaceManager;
}
- protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
- {
- PropertiesFromXML(node, model, inheritedMetas, null, true, true, false);
- }
-
- protected void PropertiesFromXML(XmlNode node, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas, UniqueKey uniqueKey, bool mutable, bool nullable, bool naturalId)
- {
- string entityName = model.EntityName;
-
- Table table = model.Table;
-
- foreach (XmlNode subnode in node.ChildNodes)
- {
- //I am only concerned with elements that are from the nhibernate namespace
- if (subnode.NamespaceURI != MappingSchemaXMLNS)
- continue;
-
- string name = subnode.LocalName; //.Name;
- string propertyName = GetPropertyName(subnode);
-
- IValue value = null;
- CollectionBinder collectionBinder = new CollectionBinder(this);
- if (collectionBinder.CanCreate(name))
- {
- Mapping.Collection collection = collectionBinder.Create(name, subnode, entityName, propertyName, model,
- model.MappedClass, inheritedMetas);
-
- mappings.AddCollection(collection);
- value = collection;
- }
- else if ("many-to-one".Equals(name))
- {
- value = new ManyToOne(table);
- BindManyToOne(subnode, (ManyToOne) value, propertyName, true);
- }
- else if ("any".Equals(name))
- {
- value = new Any(table);
- BindAny(subnode, (Any) value, true);
- }
- else if ("one-to-one".Equals(name))
- {
- value = new OneToOne(table, model);
- BindOneToOne(subnode, (OneToOne) value);
- }
- else if ("property".Equals(name))
- {
- value = new SimpleValue(table);
- BindSimpleValue(subnode, (SimpleValue) value, true, propertyName);
- }
- else if ("component".Equals(name) || "dynamic-component".Equals(name))
- {
- string subpath = StringHelper.Qualify(entityName, propertyName);
- // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
- System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
- value = new Component(model);
- BindComponent(subnode, (Component) value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas);
- }
- else if ("join".Equals(name))
- {
- Join join = new Join();
- join.PersistentClass = model;
- BindJoin(subnode, join, inheritedMetas);
- model.AddJoin(join);
- }
- else if ("subclass".Equals(name))
- new SubclassBinder(this).HandleSubclass(model, subnode, Deserialize<HbmSubclass>(subnode) , inheritedMetas);
-
- else if ("joined-subclass".Equals(name))
- new JoinedSubclassBinder(this).HandleJoinedSubclass(model, subnode, Deserialize<HbmJoinedSubclass>(subnode), inheritedMetas);
-
- else if ("union-subclass".Equals(name))
- new UnionSubclassBinder(this).HandleUnionSubclass(model, subnode, Deserialize<HbmUnionSubclass>(subnode), inheritedMetas);
-
- else if ("filter".Equals(name))
- ParseFilter(subnode, model);
- else if ("natural-id".Equals(name))
- {
- UniqueKey uk = new UniqueKey();
- uk.Name = "_UniqueKey";
- uk.Table = table;
- //by default, natural-ids are "immutable" (constant)
-
- bool mutableId = false;
- if (subnode.Attributes["mutable"] != null)
- {
- mutableId = "true".Equals(subnode.Attributes["mutable"]);
- }
-
- PropertiesFromXML(subnode, model, inheritedMetas, uk, mutableId, false, true);
- table.AddUniqueKey(uk);
- }
-
- if (value != null)
- {
- Property property = CreateProperty(value, propertyName, model.ClassName, subnode, inheritedMetas);
- if (!mutable)
- property.IsUpdateable = false;
- if (naturalId)
- property.IsNaturalIdentifier = true;
- model.AddProperty(property);
- if (uniqueKey != null)
- uniqueKey.AddColumns(new SafetyEnumerable<Column>(property.ColumnIterator));
- }
- }
- }
-
protected void BindClass(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
{
// handle the lazy attribute
@@ -160,6 +53,30 @@
BindPersistentClassCommonValues(classMapping, model, inheritedMetas);
}
+ protected void BindUnionSubclasses(IEnumerable<HbmUnionSubclass> unionSubclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ foreach (var unionSubclass in unionSubclasses)
+ {
+ new UnionSubclassBinder(this).HandleUnionSubclass(persistentClass, Serialize(unionSubclass), unionSubclass, inheritedMetas);
+ }
+ }
+
+ protected void BindJoinedSubclasses(IEnumerable<HbmJoinedSubclass> joinedSubclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ foreach (var joinedSubclass in joinedSubclasses)
+ {
+ new JoinedSubclassBinder(this).HandleJoinedSubclass(persistentClass, Serialize(joinedSubclass), joinedSubclass, inheritedMetas);
+ }
+ }
+
+ protected void BindSubclasses(IEnumerable<HbmSubclass> subclasses, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ foreach (var subclass in subclasses)
+ {
+ new SubclassBinder(this).HandleSubclass(persistentClass, Serialize(subclass), subclass, inheritedMetas);
+ }
+ }
+
private void BindPersistentClassCommonValues(IEntityMapping classMapping, PersistentClass model, IDictionary<string, MetaAttribute> inheritedMetas)
{
// DISCRIMINATOR
@@ -254,6 +171,16 @@
}
}
+ protected void BindJoins(IEnumerable<HbmJoin> joins, PersistentClass persistentClass, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ foreach (var hbmJoin in joins)
+ {
+ var join = new Join { PersistentClass = persistentClass };
+ BindJoin(Serialize(hbmJoin), join, inheritedMetas);
+ persistentClass.AddJoin(join);
+ }
+ }
+
private void BindJoin(XmlNode node, Join join, IDictionary<string, MetaAttribute> inheritedMetas)
{
PersistentClass persistentClass = join.PersistentClass;
@@ -310,7 +237,7 @@
XmlAttribute nameAttribute = subnode.Attributes["name"];
string propertyName = nameAttribute == null ? null : nameAttribute.Value;
IValue value = null;
- var collectionBinder = new CollectionBinder(this);
+ var collectionBinder = new CollectionBinder(Mappings, namespaceManager, dialect);
if (collectionBinder.CanCreate(name))
{
Mapping.Collection collection = collectionBinder.Create(name, subnode, persistentClass.EntityName, propertyName,
@@ -536,7 +463,7 @@
IValue value = null;
- CollectionBinder binder = new CollectionBinder(this);
+ CollectionBinder binder = new CollectionBinder(Mappings, namespaceManager, dialect);
if (binder.CanCreate(name))
{
@@ -882,7 +809,7 @@
BindColumns(node, model, isNullable, false, null);
}
- private void BindOneToOne(XmlNode node, OneToOne model)
+ protected void BindOneToOne(XmlNode node, OneToOne model)
{
//BindColumns( node, model, isNullable, false, null, mappings );
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -13,11 +13,6 @@
{
}
- public ClassIdBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent, namespaceManager, dialect)
- {
- }
-
public void BindId(HbmId idSchema, PersistentClass rootClass, Table table)
{
if (idSchema != null)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/CollectionBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -31,8 +31,7 @@
return SupportedCollections.Contains(type);
}
- public CollectionBinder(ClassBinder parent)
- : base(parent)
+ public CollectionBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect) : base(mappings, namespaceManager, dialect)
{
CreateCommandCollection();
}
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/FiltersBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class FiltersBinder: Binder
+ {
+ private readonly IFilterable filterable;
+
+ public FiltersBinder(IFilterable filterable, Mappings mappings) : base(mappings)
+ {
+ this.filterable = filterable;
+ }
+
+ public void Bind(IEnumerable<HbmFilter> filters)
+ {
+ if (filters == null)
+ {
+ return;
+ }
+ foreach (var filter in filters)
+ {
+ string name = filter.name;
+ if (name.IndexOf('.') > -1)
+ throw new MappingException("Filter name can't contain the character '.'(point): " + name);
+
+ string condition = (filter.Text.LinesToString() ?? string.Empty).Trim();
+ if (string.IsNullOrEmpty(condition))
+ {
+ condition = filter.condition;
+ }
+ if (string.IsNullOrEmpty(condition))
+ {
+ var fdef = mappings.GetFilterDefinition(name);
+ if (fdef != null)
+ {
+ // where immediately available, apply the condition
+ condition = fdef.DefaultFilterCondition;
+ }
+ }
+
+ mappings.ExpectedFilterDefinition(filterable, name, condition);
+
+ log.Debug(string.Format("Applying filter [{0}] as [{1}]", name, condition));
+ filterable.AddFilter(name, condition);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/JoinedSubclassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -8,8 +8,8 @@
{
public class JoinedSubclassBinder : ClassBinder
{
- public JoinedSubclassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent, namespaceManager, dialect)
+ public JoinedSubclassBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings, namespaceManager, dialect)
{
}
@@ -68,8 +68,10 @@
mytable.AddCheckConstraint(joinedSubclassMapping.check);
// properties
- PropertiesFromXML(subnode, subclass, inheritedMetas);
+ new PropertiesBinder(mappings, subclass, namespaceManager, dialect).Bind(joinedSubclassMapping.Properties, inheritedMetas);
+ BindJoinedSubclasses(joinedSubclassMapping.JoinedSubclasses, subclass, inheritedMetas);
+
model.AddSubclass(subclass);
mappings.AddClass(subclass);
}
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/MappingRootBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -79,9 +79,9 @@
private void AddRootClasses(XmlNode parentNode, HbmClass rootClass, IDictionary<string, MetaAttribute> inheritedMetas)
{
- var binder = new RootClassBinder(this, GetNamespaceManager(parentNode), dialect);
+ var binder = new RootClassBinder(Mappings, GetNamespaceManager(parentNode), dialect);
- binder.Bind(parentNode, rootClass, inheritedMetas);
+ binder.Bind(rootClass, inheritedMetas);
}
private XmlNamespaceManager GetNamespaceManager(XmlNode parentNode)
@@ -98,7 +98,7 @@
private void AddUnionSubclasses(XmlNode parentNode, HbmUnionSubclass unionSubclass,
IDictionary<string, MetaAttribute> inheritedMetas)
{
- var binder = new UnionSubclassBinder(this, GetNamespaceManager(parentNode), dialect);
+ var binder = new UnionSubclassBinder(Mappings, GetNamespaceManager(parentNode), dialect);
binder.Bind(parentNode, unionSubclass, inheritedMetas);
}
@@ -106,7 +106,7 @@
private void AddJoinedSubclasses(XmlNode parentNode, HbmJoinedSubclass joinedSubclass,
IDictionary<string, MetaAttribute> inheritedMetas)
{
- var binder = new JoinedSubclassBinder(this, GetNamespaceManager(parentNode), dialect);
+ var binder = new JoinedSubclassBinder(Mappings, GetNamespaceManager(parentNode), dialect);
binder.Bind(parentNode, joinedSubclass, inheritedMetas);
}
@@ -120,13 +120,13 @@
private void AddQueries(HbmMapping mappingSchema)
{
- var binder = new NamedQueryBinder(this);
+ var binder = new NamedQueryBinder(Mappings);
System.Array.ForEach(mappingSchema.HqlQueries, binder.AddQuery);
}
private void AddSqlQueries(HbmMapping mappingSchema)
{
- var binder = new NamedSQLQueryBinder(this);
+ var binder = new NamedSQLQueryBinder(Mappings);
System.Array.ForEach(mappingSchema.SqlQueries, binder.AddSqlQuery);
}
@@ -169,7 +169,7 @@
private void AddResultSetMappingDefinitions(HbmMapping mappingSchema)
{
- var binder = new ResultSetMappingBinder(this);
+ var binder = new ResultSetMappingBinder(Mappings);
foreach (HbmResultSet resultSetSchema in mappingSchema.ResultSets)
{
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedQueryBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -12,11 +12,6 @@
{
}
- public NamedQueryBinder(Binder parent)
- : base(parent)
- {
- }
-
public void AddQuery(HbmQuery querySchema)
{
string queryName = querySchema.name;
@@ -36,11 +31,9 @@
? CacheModeConverter.GetCacheMode(querySchema.cachemode)
: null;
-
-
IDictionary<string,string> parameterTypes = new LinkedHashMap<string,string>();
- NamedQueryDefinition namedQuery = new NamedQueryDefinition(queryText, cacheable, region, timeout,
+ var namedQuery = new NamedQueryDefinition(queryText, cacheable, region, timeout,
fetchSize, flushMode, cacheMode, readOnly, comment, parameterTypes);
mappings.AddQuery(queryName, namedQuery);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/NamedSQLQueryBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -12,11 +12,6 @@
{
}
- public NamedSQLQueryBinder(Binder parent)
- : base(parent)
- {
- }
-
public void AddSqlQuery(HbmSqlQuery querySchema)
{
mappings.AddSecondPass(delegate
@@ -45,7 +40,7 @@
if (string.IsNullOrEmpty(resultSetRef))
{
ResultSetMappingDefinition definition =
- new ResultSetMappingBinder(this).Create(querySchema);
+ new ResultSetMappingBinder(Mappings).Create(querySchema);
namedQuery = new NamedSQLQueryDefinition(queryText,
definition.GetQueryReturns(), synchronizedTables, cacheable, region, timeout,
Added: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -0,0 +1,254 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping;
+using System;
+using NHibernate.Util;
+
+namespace NHibernate.Cfg.XmlHbmBinding
+{
+ public class PropertiesBinder : ClassBinder
+ {
+ private readonly PersistentClass model;
+
+ public PropertiesBinder(Mappings mappings, PersistentClass model, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings, namespaceManager, dialect)
+ {
+ this.model = model;
+ }
+
+ public void Bind(IEnumerable<IEntityPropertyMapping> properties, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ Bind(properties, inheritedMetas, null);
+ }
+
+ public void Bind(IEnumerable<IEntityPropertyMapping> properties, IDictionary<string, MetaAttribute> inheritedMetas, Action<Property> modifier)
+ {
+ Action<Property> action = modifier ?? (p => { });
+ string entityName = model.EntityName;
+ Table table = model.Table;
+
+ foreach (var entityPropertyMapping in properties)
+ {
+ Property property= null;
+
+ string propertyName = entityPropertyMapping.Name;
+
+ ICollectionPropertyMapping collectionMapping;
+ HbmManyToOne manyToOneMapping;
+ HbmAny anyMapping;
+ HbmOneToOne oneToOneMapping;
+ HbmProperty propertyMapping;
+ HbmComponent componentMapping;
+ HbmDynamicComponent dynamicComponentMapping;
+
+ if ((propertyMapping = entityPropertyMapping as HbmProperty) != null)
+ {
+ var value = new SimpleValue(table);
+ BindSimpleValue(Serialize(propertyMapping), value, true, propertyName);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindValueProperty(propertyMapping, property);
+ }
+ else if ((collectionMapping = entityPropertyMapping as ICollectionPropertyMapping) != null)
+ {
+ var collectionBinder = new CollectionBinder(Mappings, namespaceManager, dialect);
+
+ Mapping.Collection collection = collectionBinder.Create(collectionMapping, entityName, propertyName, model,
+ model.MappedClass, inheritedMetas);
+
+ mappings.AddCollection(collection);
+
+ property = CreateProperty(collectionMapping, model.ClassName, collection, inheritedMetas);
+ BindCollectionProperty(collectionMapping, property);
+ }
+ else if ((manyToOneMapping = entityPropertyMapping as HbmManyToOne) != null)
+ {
+ var value = new ManyToOne(table);
+ BindManyToOne(Serialize(manyToOneMapping), value, propertyName, true);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindManyToOneProperty(manyToOneMapping, property);
+ }
+ else if ((componentMapping = entityPropertyMapping as HbmComponent) != null)
+ {
+ string subpath = StringHelper.Qualify(entityName, propertyName);
+ var subnode = Serialize(componentMapping);
+ var value = new Component(model);
+ // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
+ System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
+ BindComponent(subnode, value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindComponentProperty(componentMapping, property);
+ }
+ else if ((oneToOneMapping = entityPropertyMapping as HbmOneToOne) != null)
+ {
+ var value = new OneToOne(table, model);
+ BindOneToOne(Serialize(oneToOneMapping), value);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindOneToOneProperty(oneToOneMapping, property);
+ }
+ else if ((dynamicComponentMapping = entityPropertyMapping as HbmDynamicComponent) != null)
+ {
+ string subpath = StringHelper.Qualify(entityName, propertyName);
+ var subnode = Serialize(dynamicComponentMapping);
+ var value = new Component(model);
+ // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute
+ System.Type reflectedClass = GetPropertyType(subnode, model.MappedClass, propertyName);
+ BindComponent(subnode, value, reflectedClass, entityName, propertyName, subpath, true, inheritedMetas);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindComponentProperty(dynamicComponentMapping, property);
+ }
+ else if ((anyMapping = entityPropertyMapping as HbmAny) != null)
+ {
+ var value = new Any(table);
+ BindAny(Serialize(anyMapping), value, true);
+ property = CreateProperty(entityPropertyMapping, model.ClassName, value, inheritedMetas);
+ BindAnyProperty(anyMapping, property);
+ }
+
+ if(property != null)
+ {
+ action(property);
+ if (log.IsDebugEnabled)
+ {
+ string msg = "Mapped property: " + property.Name;
+ string columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray());
+ if (columns.Length > 0)
+ msg += " -> " + columns;
+ if (property.Type != null)
+ msg += ", type: " + property.Type.Name;
+ log.Debug(msg);
+ }
+ model.AddProperty(property);
+ }
+ }
+ }
+
+ private void BindValueProperty(HbmProperty propertyMapping, Property property)
+ {
+ property.IsUpdateable = propertyMapping.updateSpecified ? propertyMapping.update:true;
+ property.IsInsertable = propertyMapping.insertSpecified ? propertyMapping.insert:true;
+ PropertyGeneration generation;
+ switch (propertyMapping.generated)
+ {
+ case HbmPropertyGeneration.Never:
+ generation = PropertyGeneration.Never;
+ break;
+ case HbmPropertyGeneration.Insert:
+ generation = PropertyGeneration.Insert;
+ break;
+ case HbmPropertyGeneration.Always:
+ generation = PropertyGeneration.Always;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
+ }
+ property.Generation = generation;
+
+ if (generation == PropertyGeneration.Always || generation == PropertyGeneration.Insert)
+ {
+ // generated properties can *never* be insertable...
+ if (propertyMapping.insertSpecified && property.IsInsertable)
+ {
+ // the user specifically supplied insert="true",
+ // which constitutes an illegal combo
+ throw new MappingException("cannot specify both insert=\"true\" and generated=\"" + generation
+ + "\" for property: " + propertyMapping.Name);
+ }
+ else
+ {
+ property.IsInsertable = false;
+ }
+
+ // properties generated on update can never be updateable...
+ if (propertyMapping.updateSpecified && property.IsUpdateable && generation == PropertyGeneration.Always)
+ {
+ // the user specifically supplied update="true",
+ // which constitutes an illegal combo
+ throw new MappingException("cannot specify both update=\"true\" and generated=\"" + generation
+ + "\" for property: " + propertyMapping.Name);
+ }
+ else
+ {
+ property.IsUpdateable = false;
+ }
+ }
+ }
+
+ private void BindAnyProperty(HbmAny anyMapping, Property property)
+ {
+ property.Cascade = anyMapping.cascade ?? mappings.DefaultCascade;
+ property.IsUpdateable = anyMapping.update;
+ property.IsInsertable = anyMapping.insert;
+ }
+
+ private void BindOneToOneProperty(HbmOneToOne oneToOneMapping, Property property)
+ {
+ property.Cascade = oneToOneMapping.cascade ?? mappings.DefaultCascade;
+ var toOne = property.Value as ToOne;
+ if (toOne != null)
+ {
+ string propertyRef = toOne.ReferencedPropertyName;
+ if (propertyRef != null)
+ mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef);
+ toOne.CreateForeignKey();
+ }
+ }
+
+ private void BindComponentProperty(HbmDynamicComponent dynamicComponentMapping, Property property)
+ {
+ property.IsUpdateable = dynamicComponentMapping.update;
+ property.IsInsertable = dynamicComponentMapping.insert;
+ }
+
+ private void BindComponentProperty(HbmComponent componentMapping, Property property)
+ {
+ property.IsUpdateable = componentMapping.update;
+ property.IsInsertable = componentMapping.insert;
+ }
+
+ private void BindManyToOneProperty(HbmManyToOne manyToOneMapping, Property property)
+ {
+ property.Cascade = manyToOneMapping.cascade ?? mappings.DefaultCascade;
+ property.IsUpdateable = manyToOneMapping.update;
+ property.IsInsertable = manyToOneMapping.insert;
+ var toOne = property.Value as ToOne;
+ if (toOne != null)
+ {
+ string propertyRef = toOne.ReferencedPropertyName;
+ if (propertyRef != null)
+ mappings.AddUniquePropertyReference(toOne.ReferencedEntityName, propertyRef);
+ toOne.CreateForeignKey();
+ }
+ }
+
+ private void BindCollectionProperty(ICollectionPropertyMapping collectionMapping, Property property)
+ {
+ property.Cascade = collectionMapping.Cascade ?? mappings.DefaultCascade;
+ }
+
+ private Property CreateProperty(IEntityPropertyMapping propertyMapping, string className, IValue value, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ if (string.IsNullOrEmpty(propertyMapping.Name))
+ {
+ throw new MappingException("A property mapping must define the name attribute [" + className + "]");
+ }
+
+ var propertyAccessorName = propertyMapping.Access ?? Mappings.DefaultAccess;
+
+ if (!string.IsNullOrEmpty(className) && value.IsSimpleValue)
+ value.SetTypeUsingReflection(className, propertyMapping.Name, propertyAccessorName);
+
+ var property = new Property
+ {
+ Name = propertyMapping.Name,
+ PropertyAccessorName = propertyAccessorName,
+ Value = value,
+ IsOptimisticLocked = propertyMapping.OptimisticKock,
+ MetaAttributes = GetMetas(propertyMapping, inheritedMetas)
+ };
+
+ return property;
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ResultSetMappingBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -18,11 +18,6 @@
{
}
- public ResultSetMappingBinder(Binder parent)
- : base(parent)
- {
- }
-
public ResultSetMappingDefinition Create(HbmResultSet resultSetSchema)
{
return Create(resultSetSchema.name, resultSetSchema.Items);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/RootClassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Xml;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping;
@@ -8,12 +9,12 @@
{
public class RootClassBinder : ClassBinder
{
- public RootClassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent, namespaceManager, dialect)
+ public RootClassBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings, namespaceManager, dialect)
{
}
- public void Bind(XmlNode node, HbmClass classSchema, IDictionary<string, MetaAttribute> inheritedMetas)
+ public void Bind(HbmClass classSchema, IDictionary<string, MetaAttribute> inheritedMetas)
{
RootClass rootClass = new RootClass();
BindClass(classSchema, rootClass, inheritedMetas);
@@ -55,10 +56,40 @@
BindVersion(classSchema.Version, rootClass, table, inheritedMetas);
rootClass.CreatePrimaryKey(dialect);
- PropertiesFromXML(node, rootClass, inheritedMetas);
+ BindNaturalId(classSchema.naturalid, rootClass, inheritedMetas);
+ new PropertiesBinder(mappings, rootClass, namespaceManager, dialect).Bind(classSchema.Properties, inheritedMetas);
+
+ BindJoins(classSchema.Joins, rootClass, inheritedMetas);
+ BindSubclasses(classSchema.Subclasses, rootClass, inheritedMetas);
+ BindJoinedSubclasses(classSchema.JoinedSubclasses, rootClass, inheritedMetas);
+ BindUnionSubclasses(classSchema.UnionSubclasses, rootClass, inheritedMetas);
+
+ new FiltersBinder(rootClass, Mappings).Bind(classSchema.filter);
+
mappings.AddClass(rootClass);
}
+ private void BindNaturalId(HbmNaturalId naturalid, PersistentClass rootClass, IDictionary<string, MetaAttribute> inheritedMetas)
+ {
+ if (naturalid == null)
+ {
+ return;
+ }
+ //by default, natural-ids are "immutable" (constant)
+ var propBinder = new PropertiesBinder(mappings, rootClass, namespaceManager, dialect);
+ var uk = new UniqueKey { Name = "_UniqueKey", Table = rootClass.Table };
+ propBinder.Bind(naturalid.Properties, inheritedMetas, property =>
+ {
+ if (!naturalid.mutable)
+ property.IsUpdateable = false;
+ property.IsNaturalIdentifier = true;
+
+ uk.AddColumns(property.ColumnIterator.OfType<Column>());
+ });
+
+ rootClass.Table.AddUniqueKey(uk);
+ }
+
private string GetClassTableName(PersistentClass model, HbmClass classSchema)
{
if (classSchema.table == null)
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/SubclassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -9,7 +9,7 @@
public class SubclassBinder : ClassBinder
{
public SubclassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent, namespaceManager, dialect)
+ : base(parent.Mappings, namespaceManager, dialect)
{
}
@@ -37,7 +37,9 @@
log.InfoFormat("Mapping subclass: {0} -> {1}", subclass.EntityName, subclass.Table.Name);
// properties
- PropertiesFromXML(subnode, subclass, inheritedMetas);
+ new PropertiesBinder(mappings, subclass, namespaceManager, dialect).Bind(subClassMapping.Properties, inheritedMetas);
+ BindJoins(subClassMapping.Joins, subclass, inheritedMetas);
+ BindSubclasses(subClassMapping.Subclasses, subclass, inheritedMetas);
model.AddSubclass(subclass);
mappings.AddClass(subclass);
Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/UnionSubclassBinder.cs 2009-11-30 03:21:02 UTC (rev 4875)
@@ -8,8 +8,8 @@
{
public class UnionSubclassBinder : ClassBinder
{
- public UnionSubclassBinder(Binder parent, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
- : base(parent, namespaceManager, dialect)
+ public UnionSubclassBinder(Mappings mappings, XmlNamespaceManager namespaceManager, Dialect.Dialect dialect)
+ : base(mappings, namespaceManager, dialect)
{
}
@@ -48,7 +48,8 @@
log.InfoFormat("Mapping union-subclass: {0} -> {1}", unionSubclass.EntityName, unionSubclass.Table.Name);
// properties
- PropertiesFromXML(subnode, unionSubclass, inheritedMetas);
+ new PropertiesBinder(mappings, unionSubclass, namespaceManager, dialect).Bind(unionSubclassMapping.Properties, inheritedMetas);
+ BindUnionSubclasses(unionSubclassMapping.UnionSubclasses, unionSubclass, inheritedMetas);
model.AddSubclass(unionSubclass);
mappings.AddClass(unionSubclass);
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-29 20:47:58 UTC (rev 4874)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-11-30 03:21:02 UTC (rev 4875)
@@ -499,6 +499,7 @@
<Compile Include="Cfg\MappingSchema\HbmBag.cs" />
<Compile Include="Cfg\MappingSchema\HbmComponent.cs" />
<Compile Include="Cfg\MappingSchema\HbmDefinition.cs" />
+ <Compile Include="Cfg\MappingSchema\HbmDynamicComponent.cs" />
<Compile Include="Cfg\MappingSchema\HbmExtensions.cs" />
<Compile Include="Cfg\MappingSchema\HbmIdbag.cs" />
<Compile Include="Cfg\MappingSchema\HbmJoinedSubclass.cs" />
@@ -518,6 +519,7 @@
<Compile Include="Cfg\MappingSchema\IEntityPropertyMapping.cs" />
<Compile Include="Cfg\MappingSchema\IEntitySqlsMapping.cs" />
<Compile Include="Cfg\MappingSchema\IPropertiesContainerMapping.cs" />
+ <Compile Include="Cfg\MappingSchema\IReferencePropertyMapping.cs" />
<Compile Include="Cfg\SchemaAutoAction.cs" />
<Compile Include="Cfg\SessionFactoryConfigurationBase.cs" />
<Compile Include="Cfg\ISessionFactoryConfiguration.cs" />
@@ -525,6 +527,10 @@
<Compile Include="Cfg\MappingSchema\HbmTimestamp.cs" />
<Compile Include="Cfg\MappingSchema\HbmVersion.cs" />
<Compile Include="Cfg\MappingSchema\IDecoratable.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\FiltersBinder.cs" />
+ <Compile Include="Cfg\XmlHbmBinding\PropertiesBind...
[truncated message content] |