|
From: <fab...@us...> - 2011-04-01 17:11:15
|
Revision: 5572
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5572&view=rev
Author: fabiomaulo
Date: 2011-04-01 17:11:05 +0000 (Fri, 01 Apr 2011)
Log Message:
-----------
Initial upload mapping by code
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/
trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheInclude.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheUsage.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Cascade.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/CascadeExtensions.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionFetchMode.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionLazy.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ForClass.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IAccessorPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IAnyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IBagPropertiesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICacheMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionElementRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionPropertiesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionSqlsMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IColumnMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IColumnsMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentParentMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IDiscriminatorMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IEntityAttributesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IEntityPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IEntitySqlsMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IFilterMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IGenerator.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IGeneratorDef.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IGeneratorMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IIdMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinedSubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IListIndexMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IListPropertiesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyManyToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapPropertiesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelExplicitDeclarationsHolder.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/INaturalIdMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IOneToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IOneToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISetPropertiesMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ISubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IUnionSubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IVersionMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/AbstractBasePropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/AbstractPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/AccessorPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/AnyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/BagMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CacheMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CascadeConverter.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CollectionElementRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ColumnMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ComponentElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ComponentMapKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ComponentMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ComponentNestedElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ComponentParentMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersHolder.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/BagPropertiesCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementRelationCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionKeyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionPropertiesCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentElementCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/JoinedSubclassKeyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ListPropertiesCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ManyToManyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyComponentCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyManyToManyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyRelationCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapPropertiesCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/OneToManyCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SetPropertiesCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/SubclassCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/UnionSubclassCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/DefaultCandidatePersistentMembersProvider.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/DiscriminatorMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/FilterMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/GeneratorMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ICandidatePersistentMembersProvider.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ICustomizersHolder.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/IdMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinedSubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ListIndexMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ListMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/MapKeyManyToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/MapKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/MapKeyRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/MapMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/MapperEventsHandlersDefinitions.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/NaturalIdMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/NoMemberPropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/OneToManyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/OneToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/PropertyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/PropertyPath.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/PropertyPathExtensions.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SetMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/SubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/TypeNameUtil.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/UnionSubclassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/VersionMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Lazy.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ModelMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/NotFoundMode.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/SchemaAction.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/TypeExtensions.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/VersionGeneration.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/
trunk/nhibernate/src/NHibernate.Test/MappingByCode/BasicMappingOfSimpleClass.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ColumnsNamingConvetions.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappingOfPrivateMembersOnRootEntity.cs
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheInclude.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheInclude.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheInclude.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,36 @@
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public abstract class CacheInclude
+ {
+ public static CacheInclude All = new AllCacheInclude();
+ public static CacheInclude NonLazy = new NonLazyCacheInclude();
+
+ public abstract HbmCacheInclude ToHbm();
+
+ #region Nested type: AllCacheInclude
+
+ public class AllCacheInclude : CacheInclude
+ {
+ public override HbmCacheInclude ToHbm()
+ {
+ return HbmCacheInclude.All;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: NonLazyCacheInclude
+
+ public class NonLazyCacheInclude : CacheInclude
+ {
+ public override HbmCacheInclude ToHbm()
+ {
+ return HbmCacheInclude.NonLazy;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheUsage.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheUsage.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/CacheUsage.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,62 @@
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public abstract class CacheUsage
+ {
+ public static CacheUsage ReadOnly = new ReadOnlyUsage();
+ public static CacheUsage ReadWrite = new ReadWriteUsage();
+ public static CacheUsage NonstrictReadWrite = new NonstrictReadWriteUsage();
+ public static CacheUsage Transactional = new TransactionalUsage();
+
+ public abstract HbmCacheUsage ToHbm();
+
+ #region Nested type: NonstrictReadWriteUsage
+
+ private class NonstrictReadWriteUsage : CacheUsage
+ {
+ public override HbmCacheUsage ToHbm()
+ {
+ return HbmCacheUsage.NonstrictReadWrite;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: ReadOnlyUsage
+
+ private class ReadOnlyUsage : CacheUsage
+ {
+ public override HbmCacheUsage ToHbm()
+ {
+ return HbmCacheUsage.ReadOnly;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: ReadWriteUsage
+
+ private class ReadWriteUsage : CacheUsage
+ {
+ public override HbmCacheUsage ToHbm()
+ {
+ return HbmCacheUsage.ReadWrite;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: TransactionalUsage
+
+ private class TransactionalUsage : CacheUsage
+ {
+ public override HbmCacheUsage ToHbm()
+ {
+ return HbmCacheUsage.Transactional;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Cascade.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Cascade.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Cascade.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,27 @@
+using System;
+
+namespace NHibernate.Mapping.ByCode
+{
+ /// <summary>
+ /// Defines behavior of soft-cascade actions.
+ /// </summary>
+ /// <remarks>
+ /// To check the content or to include/exclude values, from cascade, is strongly recommanded the usage of extensions methods defined in <see cref="CascadeExtensions"/>
+ /// </remarks>
+ /// <seealso cref="CascadeExtensions.Has"/>
+ /// <seealso cref="CascadeExtensions.Include"/>
+ /// <seealso cref="CascadeExtensions.Exclude"/>
+ [Flags]
+ public enum Cascade
+ {
+ None = 0,
+ Persist = 2,
+ Refresh = 4,
+ Merge = 8,
+ Remove = 16,
+ Detach = 32,
+ ReAttach = 64,
+ DeleteOrphans = 128,
+ All = 256,
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/CascadeExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/CascadeExtensions.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/CascadeExtensions.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,40 @@
+namespace NHibernate.Mapping.ByCode
+{
+ public static class CascadeExtensions
+ {
+ private const Cascade AnyButOrphans = Cascade.Persist | Cascade.Refresh | Cascade.Merge | Cascade.Remove | Cascade.Detach | Cascade.ReAttach;
+
+ public static bool Has(this Cascade source, Cascade value)
+ {
+ return (source & value) == value;
+ }
+
+ public static Cascade Include(this Cascade source, Cascade value)
+ {
+ return Cleanup(source | value);
+ }
+
+ private static Cascade Cleanup(Cascade cascade)
+ {
+ bool hasAll = cascade.Has(Cascade.All) || cascade.Has(AnyButOrphans);
+ if (hasAll && cascade.Has(Cascade.DeleteOrphans))
+ {
+ return Cascade.All | Cascade.DeleteOrphans;
+ }
+ if (hasAll)
+ {
+ return Cascade.All;
+ }
+ return cascade;
+ }
+
+ public static Cascade Exclude(this Cascade source, Cascade value)
+ {
+ if (source.Has(Cascade.All) && !value.Has(Cascade.All))
+ {
+ return Cleanup(((source & ~Cascade.All) | AnyButOrphans) & ~value);
+ }
+ return Cleanup(source & ~value);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionFetchMode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionFetchMode.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionFetchMode.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,49 @@
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public abstract class CollectionFetchMode
+ {
+ public static CollectionFetchMode Select = new SelectFetchMode();
+ public static CollectionFetchMode Join = new JoinFetchMode();
+ public static CollectionFetchMode Subselect = new SubselectFetchMode();
+
+ public abstract HbmCollectionFetchMode ToHbm();
+
+ #region Nested type: JoinFetchMode
+
+ private class JoinFetchMode : CollectionFetchMode
+ {
+ public override HbmCollectionFetchMode ToHbm()
+ {
+ return HbmCollectionFetchMode.Join;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: SelectFetchMode
+
+ private class SelectFetchMode : CollectionFetchMode
+ {
+ public override HbmCollectionFetchMode ToHbm()
+ {
+ return HbmCollectionFetchMode.Select;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: SubselectFetchMode
+
+ private class SubselectFetchMode : CollectionFetchMode
+ {
+ public override HbmCollectionFetchMode ToHbm()
+ {
+ return HbmCollectionFetchMode.Subselect;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionLazy.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionLazy.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/CollectionLazy.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,9 @@
+namespace NHibernate.Mapping.ByCode
+{
+ public enum CollectionLazy
+ {
+ Lazy,
+ NoLazy,
+ Extra
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,383 @@
+using System.Collections.Generic;
+using System.Reflection;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public class ExplicitlyDeclaredModel : IModelInspector, IModelExplicitDeclarationsHolder
+ {
+ private readonly HashSet<MemberInfo> any = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> arrays = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> bags = new HashSet<MemberInfo>();
+ private readonly HashSet<System.Type> components = new HashSet<System.Type>();
+ private readonly HashSet<MemberInfo> dictionaries = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> idBags = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> lists = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> manyToManyRelations = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> manyToOneRelations = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> naturalIds = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> oneToManyRelations = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> oneToOneRelations = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> persistentProperties = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> poids = new HashSet<MemberInfo>();
+ private readonly HashSet<MemberInfo> properties = new HashSet<MemberInfo>();
+ private readonly HashSet<System.Type> rootEntities = new HashSet<System.Type>();
+ private readonly HashSet<MemberInfo> sets = new HashSet<MemberInfo>();
+ private readonly HashSet<System.Type> tablePerClassEntities = new HashSet<System.Type>();
+ private readonly HashSet<System.Type> tablePerClassHierarchyEntities = new HashSet<System.Type>();
+ private readonly HashSet<System.Type> tablePerClassHierarchyJoinEntities = new HashSet<System.Type>();
+ private readonly HashSet<System.Type> tablePerConcreteClassEntities = new HashSet<System.Type>();
+ private readonly HashSet<MemberInfo> versionProperties = new HashSet<MemberInfo>();
+
+ #region IModelExplicitDeclarationsHolder Members
+
+ public IEnumerable<System.Type> RootEntities
+ {
+ get { return rootEntities; }
+ }
+
+ public IEnumerable<System.Type> Components
+ {
+ get { return components; }
+ }
+
+ public IEnumerable<System.Type> TablePerClassEntities
+ {
+ get { return tablePerClassEntities; }
+ }
+
+ public IEnumerable<System.Type> TablePerClassHierarchyEntities
+ {
+ get { return tablePerClassHierarchyEntities; }
+ }
+
+ public IEnumerable<System.Type> TablePerClassHierarchyJoinEntities
+ {
+ get { return tablePerClassHierarchyJoinEntities; }
+ }
+
+ public IEnumerable<System.Type> TablePerConcreteClassEntities
+ {
+ get { return tablePerConcreteClassEntities; }
+ }
+
+ public IEnumerable<MemberInfo> OneToOneRelations
+ {
+ get { return oneToOneRelations; }
+ }
+
+ public IEnumerable<MemberInfo> ManyToOneRelations
+ {
+ get { return manyToOneRelations; }
+ }
+
+ public IEnumerable<MemberInfo> ManyToManyRelations
+ {
+ get { return manyToManyRelations; }
+ }
+
+ public IEnumerable<MemberInfo> OneToManyRelations
+ {
+ get { return oneToManyRelations; }
+ }
+
+ public IEnumerable<MemberInfo> Any
+ {
+ get { return any; }
+ }
+
+ public IEnumerable<MemberInfo> Poids
+ {
+ get { return poids; }
+ }
+
+ public IEnumerable<MemberInfo> VersionProperties
+ {
+ get { return versionProperties; }
+ }
+
+ public IEnumerable<MemberInfo> NaturalIds
+ {
+ get { return naturalIds; }
+ }
+
+ public IEnumerable<MemberInfo> Sets
+ {
+ get { return sets; }
+ }
+
+ public IEnumerable<MemberInfo> Bags
+ {
+ get { return bags; }
+ }
+
+ public IEnumerable<MemberInfo> IdBags
+ {
+ get { return idBags; }
+ }
+
+ public IEnumerable<MemberInfo> Lists
+ {
+ get { return lists; }
+ }
+
+ public IEnumerable<MemberInfo> Arrays
+ {
+ get { return arrays; }
+ }
+
+ public IEnumerable<MemberInfo> Dictionaries
+ {
+ get { return dictionaries; }
+ }
+
+ public IEnumerable<MemberInfo> Properties
+ {
+ get { return properties; }
+ }
+
+ public void AddAsRootEntity(System.Type type)
+ {
+ rootEntities.Add(type);
+ }
+
+ public void AddAsComponent(System.Type type)
+ {
+ components.Add(type);
+ }
+
+ public void AddAsTablePerClassEntity(System.Type type)
+ {
+ tablePerClassEntities.Add(type);
+ }
+
+ public void AddAsTablePerClassHierarchyEntity(System.Type type)
+ {
+ tablePerClassHierarchyEntities.Add(type);
+ }
+
+ public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
+ {
+ tablePerClassHierarchyJoinEntities.Add(type);
+ }
+
+ public void AddAsTablePerConcreteClassEntity(System.Type type)
+ {
+ tablePerConcreteClassEntities.Add(type);
+ }
+
+ public void AddAsOneToOneRelation(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ oneToOneRelations.Add(member);
+ }
+
+ public void AddAsManyToOneRelation(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ manyToOneRelations.Add(member);
+ }
+
+ public void AddAsManyToManyRelation(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ manyToManyRelations.Add(member);
+ }
+
+ public void AddAsOneToManyRelation(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ oneToManyRelations.Add(member);
+ }
+
+ public void AddAsAny(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ any.Add(member);
+ }
+
+ public void AddAsPoid(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ poids.Add(member);
+ }
+
+ public void AddAsVersionProperty(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ versionProperties.Add(member);
+ }
+
+ public void AddAsNaturalId(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ naturalIds.Add(member);
+ }
+
+ public void AddAsSet(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ sets.Add(member);
+ }
+
+ public void AddAsBag(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ bags.Add(member);
+ }
+
+ public void AddAsIdBag(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ idBags.Add(member);
+ }
+
+ public void AddAsList(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ lists.Add(member);
+ }
+
+ public void AddAsArray(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ arrays.Add(member);
+ }
+
+ public void AddAsMap(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ dictionaries.Add(member);
+ }
+
+ public void AddAsProperty(MemberInfo member)
+ {
+ persistentProperties.Add(member);
+ properties.Add(member);
+ }
+
+ #endregion
+
+ #region Implementation of IModelInspector
+
+ public bool IsRootEntity(System.Type type)
+ {
+ return rootEntities.Contains(type);
+ }
+
+ public bool IsComponent(System.Type type)
+ {
+ return components.Contains(type);
+ }
+
+ public bool IsEntity(System.Type type)
+ {
+ return rootEntities.Contains(type) ||
+ tablePerClassEntities.Contains(type) ||
+ tablePerClassHierarchyEntities.Contains(type) ||
+ tablePerClassHierarchyJoinEntities.Contains(type) ||
+ tablePerConcreteClassEntities.Contains(type);
+ }
+
+ public bool IsTablePerClass(System.Type type)
+ {
+ return tablePerClassEntities.Contains(type);
+ }
+
+ public bool IsTablePerClassHierarchy(System.Type type)
+ {
+ return tablePerClassHierarchyEntities.Contains(type);
+ }
+
+ public bool IsTablePerClassHierarchyJoin(System.Type type)
+ {
+ return tablePerClassHierarchyJoinEntities.Contains(type);
+ }
+
+ public bool IsTablePerConcreteClass(System.Type type)
+ {
+ return tablePerConcreteClassEntities.Contains(type);
+ }
+
+ public bool IsOneToOne(MemberInfo member)
+ {
+ return oneToOneRelations.Contains(member);
+ }
+
+ public bool IsManyToOne(MemberInfo member)
+ {
+ return manyToOneRelations.Contains(member);
+ }
+
+ public bool IsManyToMany(MemberInfo member)
+ {
+ return manyToManyRelations.Contains(member);
+ }
+
+ public bool IsOneToMany(MemberInfo member)
+ {
+ return oneToManyRelations.Contains(member);
+ }
+
+ public bool IsHeterogeneousAssociation(MemberInfo member)
+ {
+ return any.Contains(member);
+ }
+
+ public bool IsPersistentId(MemberInfo member)
+ {
+ return poids.Contains(member);
+ }
+
+ public bool IsVersion(MemberInfo member)
+ {
+ return versionProperties.Contains(member);
+ }
+
+ public bool IsMemberOfNaturalId(MemberInfo member)
+ {
+ return naturalIds.Contains(member);
+ }
+
+ public bool IsPersistentProperty(MemberInfo member)
+ {
+ return persistentProperties.Contains(member);
+ }
+
+ public bool IsSet(MemberInfo role)
+ {
+ return sets.Contains(role);
+ }
+
+ public bool IsBag(MemberInfo role)
+ {
+ return bags.Contains(role);
+ }
+
+ public bool IsIdBag(MemberInfo role)
+ {
+ return idBags.Contains(role);
+ }
+
+ public bool IsList(MemberInfo role)
+ {
+ return lists.Contains(role);
+ }
+
+ public bool IsArray(MemberInfo role)
+ {
+ return arrays.Contains(role);
+ }
+
+ public bool IsDictionary(MemberInfo role)
+ {
+ return dictionaries.Contains(role);
+ }
+
+ public bool IsProperty(MemberInfo member)
+ {
+ return properties.Contains(member);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/FakeModelExplicitDeclarationsHolder.cs 2011-04-01 17:11:05 UTC (rev 5572)
@@ -0,0 +1,182 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public class FakeModelExplicitDeclarationsHolder : IModelExplicitDeclarationsHolder
+ {
+ private readonly IEnumerable<MemberInfo> any = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> arrays = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> bags = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<System.Type> components = Enumerable.Empty<System.Type>();
+ private readonly IEnumerable<MemberInfo> dictionaries = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> idBags = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> lists = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> manyToManyRelations = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> manyToOneRelations = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> naturalIds = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> oneToManyRelations = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> oneToOneRelations = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> poids = Enumerable.Empty<MemberInfo>();
+ private readonly IEnumerable<MemberInfo> properties = Enumerable.Empty<MemberIn...
[truncated message content] |
|
From: <fab...@us...> - 2011-04-02 18:31:10
|
Revision: 5574
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5574&view=rev
Author: fabiomaulo
Date: 2011-04-02 18:31:03 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
Root classes registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 15:10:48 UTC (rev 5573)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:31:03 UTC (rev 5574)
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
namespace NHibernate.Mapping.ByCode
@@ -147,22 +148,55 @@
public void AddAsTablePerClassEntity(System.Type type)
{
- tablePerClassEntities.Add(type);
+ var rootEntity = GetRootEntityOrNull(type);
+ if(rootEntity != null)
+ {
+ if(rootEntity.Equals(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class strategy", type.FullName));
+ }
+ tablePerClassEntities.Add(rootEntity);
+ }
}
public void AddAsTablePerClassHierarchyEntity(System.Type type)
{
- tablePerClassHierarchyEntities.Add(type);
+ var rootEntity = GetRootEntityOrNull(type);
+ if (rootEntity != null)
+ {
+ if (rootEntity.Equals(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
+ }
+ tablePerClassHierarchyEntities.Add(rootEntity);
+ }
}
public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
{
+ var rootEntity = GetRootEntityOrNull(type);
+ if (rootEntity != null)
+ {
+ if (rootEntity.Equals(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
+ }
+ tablePerClassHierarchyEntities.Add(rootEntity);
+ }
tablePerClassHierarchyJoinEntities.Add(type);
}
public void AddAsTablePerConcreteClassEntity(System.Type type)
{
- tablePerConcreteClassEntities.Add(type);
+ var rootEntity = GetRootEntityOrNull(type);
+ if (rootEntity != null)
+ {
+ if (rootEntity.Equals(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-concrete-class strategy", type.FullName));
+ }
+ tablePerConcreteClassEntities.Add(rootEntity);
+ }
}
public void AddAsOneToOneRelation(MemberInfo member)
@@ -379,5 +413,18 @@
}
#endregion
+
+ private System.Type GetRootEntityOrNull(System.Type entityType)
+ {
+ if (entityType == null)
+ {
+ return null;
+ }
+ if (IsRootEntity(entityType))
+ {
+ return entityType;
+ }
+ return entityType.GetBaseTypes().SingleOrDefault(IsRootEntity);
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs 2011-04-02 18:31:03 UTC (rev 5574)
@@ -0,0 +1,158 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class RootClassMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1: MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsRootThenDoesNotRegisterTheStrategy()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredJoinedSubclassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredJoinedDeepSubclassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited2));
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredSubclassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredDeepSubclassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredSubclassJoinThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredDeepSubclassJoinThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredConcreteClassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisteredDeepConcreteClassThenTheStrategyIsDefinedEvenForRoot()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisteredAsRootThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.Executing(x=> x.AddAsTablePerClassEntity(typeof(MyClass))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsRootThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(MyClass))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsRootThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(MyClass))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 15:10:48 UTC (rev 5573)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:31:03 UTC (rev 5574)
@@ -508,6 +508,7 @@
<Compile Include="Logging\LoggerProviderTest.cs" />
<Compile Include="MappingByCode\BasicMappingOfSimpleClass.cs" />
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Model.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 18:49:32
|
Revision: 5575
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5575&view=rev
Author: fabiomaulo
Date: 2011-04-02 18:49:26 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
joined subclasses registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:31:03 UTC (rev 5574)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:49:26 UTC (rev 5575)
@@ -168,6 +168,10 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
+ if(IsMappedFor(tablePerClassEntities, type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
+ }
tablePerClassHierarchyEntities.Add(rootEntity);
}
}
@@ -181,6 +185,10 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
+ if (IsMappedFor(tablePerClassEntities, type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
+ }
tablePerClassHierarchyEntities.Add(rootEntity);
}
tablePerClassHierarchyJoinEntities.Add(type);
@@ -195,6 +203,10 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-concrete-class strategy", type.FullName));
}
+ if (IsMappedFor(tablePerClassEntities, type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
+ }
tablePerConcreteClassEntities.Add(rootEntity);
}
}
@@ -314,7 +326,7 @@
public bool IsTablePerClass(System.Type type)
{
- return tablePerClassEntities.Contains(type);
+ return IsMappedFor(tablePerClassEntities, type);
}
public bool IsTablePerClassHierarchy(System.Type type)
@@ -426,5 +438,21 @@
}
return entityType.GetBaseTypes().SingleOrDefault(IsRootEntity);
}
+
+ protected bool IsMappedFor(ICollection<System.Type> explicitMappedEntities, System.Type type)
+ {
+ bool isExplicitMapped = explicitMappedEntities.Contains(type);
+ bool isDerived = false;
+
+ if (!isExplicitMapped)
+ {
+ isDerived = type.GetBaseTypes().Any(explicitMappedEntities.Contains);
+ if (isDerived)
+ {
+ explicitMappedEntities.Add(type);
+ }
+ }
+ return isExplicitMapped || isDerived;
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs 2011-04-02 18:49:26 UTC (rev 5575)
@@ -0,0 +1,78 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class JoinedSubclassMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsJoinedSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsDeppJoinedSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsSubclassJoin()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:31:03 UTC (rev 5574)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:49:26 UTC (rev 5575)
@@ -508,6 +508,7 @@
<Compile Include="Logging\LoggerProviderTest.cs" />
<Compile Include="MappingByCode\BasicMappingOfSimpleClass.cs" />
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 18:58:57
|
Revision: 5576
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5576&view=rev
Author: fabiomaulo
Date: 2011-04-02 18:58:51 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
subclasses registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:49:26 UTC (rev 5575)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:58:51 UTC (rev 5576)
@@ -155,6 +155,10 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class strategy", type.FullName));
}
+ if (IsMappedFor(tablePerClassHierarchyEntities, type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
+ }
tablePerClassEntities.Add(rootEntity);
}
}
@@ -185,7 +189,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerClassHierarchyEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -203,7 +207,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-concrete-class strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerClassHierarchyEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -331,7 +335,7 @@
public bool IsTablePerClassHierarchy(System.Type type)
{
- return tablePerClassHierarchyEntities.Contains(type);
+ return IsMappedFor(tablePerClassHierarchyEntities, type);
}
public bool IsTablePerClassHierarchyJoin(System.Type type)
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs 2011-04-02 18:58:51 UTC (rev 5576)
@@ -0,0 +1,79 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class SubclassMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsDeepSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassThenCantRegisterAsSubclassJoin()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:49:26 UTC (rev 5575)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:58:51 UTC (rev 5576)
@@ -510,6 +510,7 @@
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Model.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 19:07:01
|
Revision: 5577
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5577&view=rev
Author: fabiomaulo
Date: 2011-04-02 19:06:54 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
subclass-join classes registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 18:58:51 UTC (rev 5576)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:06:54 UTC (rev 5577)
@@ -172,7 +172,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if(IsMappedFor(tablePerClassEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || tablePerClassHierarchyJoinEntities.Contains(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-02 19:06:54 UTC (rev 5577)
@@ -0,0 +1,78 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class SubclassJoinMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.True();
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsDeepSubclassJoinThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.True();
+ inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 18:58:51 UTC (rev 5576)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:06:54 UTC (rev 5577)
@@ -510,6 +510,7 @@
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 19:14:14
|
Revision: 5578
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5578&view=rev
Author: fabiomaulo
Date: 2011-04-02 19:14:08 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
union-subclass classes registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:06:54 UTC (rev 5577)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:14:08 UTC (rev 5578)
@@ -155,7 +155,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassHierarchyEntities, type))
+ if (IsMappedFor(tablePerClassHierarchyEntities, type) || IsMappedFor(tablePerConcreteClassEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -172,7 +172,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassEntities, type) || tablePerClassHierarchyJoinEntities.Contains(type))
+ if (IsMappedFor(tablePerClassEntities, type) || tablePerClassHierarchyJoinEntities.Contains(type) || IsMappedFor(tablePerConcreteClassEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -189,7 +189,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerClassHierarchyEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerClassHierarchyEntities, type) || IsMappedFor(tablePerConcreteClassEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -345,7 +345,7 @@
public bool IsTablePerConcreteClass(System.Type type)
{
- return tablePerConcreteClassEntities.Contains(type);
+ return IsMappedFor(tablePerConcreteClassEntities, type);
}
public bool IsOneToOne(MemberInfo member)
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs 2011-04-02 19:14:08 UTC (rev 5578)
@@ -0,0 +1,78 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class UnionSubclassMappingStrategyTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+ private class Inherited2 : Inherited1
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsUnionSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisteredAsDeepUnionSubclassThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited2));
+
+ inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
+ inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisteredAsUnionSubclassThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsUnionSubclassThenCantRegisterAsSubclassJoin()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsUnionSubclassThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:06:54 UTC (rev 5577)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:14:08 UTC (rev 5578)
@@ -512,6 +512,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Model.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 19:38:50
|
Revision: 5579
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5579&view=rev
Author: fabiomaulo
Date: 2011-04-02 19:38:43 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
components registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:14:08 UTC (rev 5578)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:38:43 UTC (rev 5579)
@@ -138,16 +138,29 @@
public void AddAsRootEntity(System.Type type)
{
+ if (IsComponent(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
rootEntities.Add(type);
}
public void AddAsComponent(System.Type type)
{
+ var rootEntity = GetRootEntityOrNull(type);
+ if (rootEntity != null)
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
components.Add(type);
}
public void AddAsTablePerClassEntity(System.Type type)
{
+ if (IsComponent(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
var rootEntity = GetRootEntityOrNull(type);
if(rootEntity != null)
{
@@ -165,6 +178,10 @@
public void AddAsTablePerClassHierarchyEntity(System.Type type)
{
+ if (IsComponent(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
var rootEntity = GetRootEntityOrNull(type);
if (rootEntity != null)
{
@@ -182,6 +199,10 @@
public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
{
+ if (IsComponent(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
var rootEntity = GetRootEntityOrNull(type);
if (rootEntity != null)
{
@@ -200,6 +221,10 @@
public void AddAsTablePerConcreteClassEntity(System.Type type)
{
+ if (IsComponent(type))
+ {
+ throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
+ }
var rootEntity = GetRootEntityOrNull(type);
if (rootEntity != null)
{
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs 2011-04-02 19:38:43 UTC (rev 5579)
@@ -0,0 +1,77 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class ComponentMappingRegistrationTests
+ {
+ private class MyComponent
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponentThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.IsComponent(typeof(MyComponent)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisteredAsEntityThenCantRegisterAsComponent()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsComponent(typeof(MyComponent))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponetThenCantRegisterAsRootEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsRootEntity(typeof(MyComponent))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponetThenCantRegisterAsJoinedSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(MyComponent))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponetThenCantRegisterAsSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(MyComponent))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponetThenCantRegisterAsSubclassJoin()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(MyComponent))).Throws<MappingException>();
+ }
+
+ [Test]
+ public void WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsComponent(typeof(MyComponent));
+
+ inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(MyComponent))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:14:08 UTC (rev 5578)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:38:43 UTC (rev 5579)
@@ -508,6 +508,7 @@
<Compile Include="Logging\LoggerProviderTest.cs" />
<Compile Include="MappingByCode\BasicMappingOfSimpleClass.cs" />
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\ComponentMappingRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 20:32:37
|
Revision: 5580
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5580&view=rev
Author: fabiomaulo
Date: 2011-04-02 20:32:31 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
JoinedSubclass Sequence registration fix
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 19:38:43 UTC (rev 5579)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:32:31 UTC (rev 5580)
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -28,6 +29,7 @@
private readonly HashSet<System.Type> tablePerClassHierarchyJoinEntities = new HashSet<System.Type>();
private readonly HashSet<System.Type> tablePerConcreteClassEntities = new HashSet<System.Type>();
private readonly HashSet<MemberInfo> versionProperties = new HashSet<MemberInfo>();
+ private Dictionary<System.Type, Action<System.Type>> delayedTypeRegistration = new Dictionary<System.Type, Action<System.Type>>();
#region IModelExplicitDeclarationsHolder Members
@@ -157,14 +159,19 @@
public void AddAsTablePerClassEntity(System.Type type)
{
+ AddAsTablePerClassEntity(type, false);
+ }
+
+ public void AddAsTablePerClassEntity(System.Type type, bool rootEntityMustExists)
+ {
if (IsComponent(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
}
var rootEntity = GetRootEntityOrNull(type);
- if(rootEntity != null)
+ if (rootEntity != null)
{
- if(rootEntity.Equals(type))
+ if (rootEntity.Equals(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class strategy", type.FullName));
}
@@ -174,6 +181,14 @@
}
tablePerClassEntities.Add(rootEntity);
}
+ else
+ {
+ if(rootEntityMustExists)
+ {
+ throw new MappingException(string.Format("The root entity for {0} was never registered", type.FullName));
+ }
+ EnlistTypeRegistration(type, t => AddAsTablePerClassEntity(t, true));
+ }
}
public void AddAsTablePerClassHierarchyEntity(System.Type type)
@@ -355,6 +370,7 @@
public bool IsTablePerClass(System.Type type)
{
+ ExecuteDelayedTypeRegistration(type);
return IsMappedFor(tablePerClassEntities, type);
}
@@ -483,5 +499,19 @@
}
return isExplicitMapped || isDerived;
}
+
+ private void EnlistTypeRegistration(System.Type type, Action<System.Type> registration)
+ {
+ delayedTypeRegistration.Add(type, registration);
+ }
+
+ private void ExecuteDelayedTypeRegistration(System.Type type)
+ {
+ Action<System.Type> registration;
+ if(delayedTypeRegistration.TryGetValue(type, out registration))
+ {
+ registration(type);
+ }
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs 2011-04-02 20:32:31 UTC (rev 5580)
@@ -0,0 +1,37 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class JoinedSubclassSequenceRegistrationTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisterJoinedSubclassBeforeRootThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisterJoinedSubclassWithNoRootThenThrows()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.IsTablePerClass(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 19:38:43 UTC (rev 5579)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:32:31 UTC (rev 5580)
@@ -510,6 +510,7 @@
<Compile Include="MappingByCode\ColumnsNamingConvetions.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\ComponentMappingRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 20:40:41
|
Revision: 5581
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5581&view=rev
Author: fabiomaulo
Date: 2011-04-02 20:40:33 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
Subclass Sequence registration fix
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:32:31 UTC (rev 5580)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:40:33 UTC (rev 5581)
@@ -193,6 +193,11 @@
public void AddAsTablePerClassHierarchyEntity(System.Type type)
{
+ AddAsTablePerClassHierarchyEntity(type, false);
+ }
+
+ public void AddAsTablePerClassHierarchyEntity(System.Type type, bool rootEntityMustExists)
+ {
if (IsComponent(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
@@ -210,6 +215,14 @@
}
tablePerClassHierarchyEntities.Add(rootEntity);
}
+ else
+ {
+ if (rootEntityMustExists)
+ {
+ throw new MappingException(string.Format("The root entity for {0} was never registered", type.FullName));
+ }
+ EnlistTypeRegistration(type, t => AddAsTablePerClassHierarchyEntity(t, true));
+ }
}
public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
@@ -376,6 +389,7 @@
public bool IsTablePerClassHierarchy(System.Type type)
{
+ ExecuteDelayedTypeRegistration(type);
return IsMappedFor(tablePerClassHierarchyEntities, type);
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs 2011-04-02 20:40:33 UTC (rev 5581)
@@ -0,0 +1,37 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class SubclassSequenceRegistrationTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisterSubclassBeforeRootThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisterSubclassWithNoRootThenThrows()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.IsTablePerClass(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:32:31 UTC (rev 5580)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:40:33 UTC (rev 5581)
@@ -514,6 +514,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 20:48:19
|
Revision: 5582
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5582&view=rev
Author: fabiomaulo
Date: 2011-04-02 20:48:13 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
Subclass-Join Sequence registration fix
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:40:33 UTC (rev 5581)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:48:13 UTC (rev 5582)
@@ -227,6 +227,11 @@
public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
{
+ AddAsTablePerClassHierarchyJoinEntity(type, false);
+ }
+
+ public void AddAsTablePerClassHierarchyJoinEntity(System.Type type, bool rootEntityMustExists)
+ {
if (IsComponent(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
@@ -243,8 +248,16 @@
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
tablePerClassHierarchyEntities.Add(rootEntity);
+ tablePerClassHierarchyJoinEntities.Add(type);
}
- tablePerClassHierarchyJoinEntities.Add(type);
+ else
+ {
+ if (rootEntityMustExists)
+ {
+ throw new MappingException(string.Format("The root entity for {0} was never registered", type.FullName));
+ }
+ EnlistTypeRegistration(type, t => AddAsTablePerClassHierarchyJoinEntity(t, true));
+ }
}
public void AddAsTablePerConcreteClassEntity(System.Type type)
@@ -395,6 +408,7 @@
public bool IsTablePerClassHierarchyJoin(System.Type type)
{
+ ExecuteDelayedTypeRegistration(type);
return tablePerClassHierarchyJoinEntities.Contains(type);
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs 2011-04-02 20:48:13 UTC (rev 5582)
@@ -0,0 +1,37 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class SubclassJoinSequenceRegistrationTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisterSubclassJoinBeforeRootThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisterSubclassWithNoRootThenThrows()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.IsTablePerClassHierarchyJoin(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs 2011-04-02 20:40:33 UTC (rev 5581)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassSequenceRegistrationTests.cs 2011-04-02 20:48:13 UTC (rev 5582)
@@ -31,7 +31,7 @@
var inspector = new ExplicitlyDeclaredModel();
inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
- inspector.Executing(x => x.IsTablePerClass(typeof(Inherited1))).Throws<MappingException>();
+ inspector.Executing(x => x.IsTablePerClassHierarchy(typeof(Inherited1))).Throws<MappingException>();
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:40:33 UTC (rev 5581)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:48:13 UTC (rev 5582)
@@ -513,6 +513,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 20:54:44
|
Revision: 5583
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5583&view=rev
Author: fabiomaulo
Date: 2011-04-02 20:54:38 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
union-Subclass Sequence registration fix
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:48:13 UTC (rev 5582)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 20:54:38 UTC (rev 5583)
@@ -262,6 +262,11 @@
public void AddAsTablePerConcreteClassEntity(System.Type type)
{
+ AddAsTablePerConcreteClassEntity(type, false);
+ }
+
+ public void AddAsTablePerConcreteClassEntity(System.Type type, bool rootEntityMustExists)
+ {
if (IsComponent(type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
@@ -279,6 +284,14 @@
}
tablePerConcreteClassEntities.Add(rootEntity);
}
+ else
+ {
+ if (rootEntityMustExists)
+ {
+ throw new MappingException(string.Format("The root entity for {0} was never registered", type.FullName));
+ }
+ EnlistTypeRegistration(type, t => AddAsTablePerConcreteClassEntity(t, true));
+ }
}
public void AddAsOneToOneRelation(MemberInfo member)
@@ -414,6 +427,7 @@
public bool IsTablePerConcreteClass(System.Type type)
{
+ ExecuteDelayedTypeRegistration(type);
return IsMappedFor(tablePerConcreteClassEntities, type);
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassSequenceRegistrationTests.cs 2011-04-02 20:54:38 UTC (rev 5583)
@@ -0,0 +1,37 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
+{
+ public class UnionSubclassSequenceRegistrationTests
+ {
+ private class MyClass
+ {
+
+ }
+ private class Inherited1 : MyClass
+ {
+
+ }
+
+ [Test]
+ public void WhenRegisterUnionSubclassBeforeRootThenIsRegistered()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.True();
+ }
+
+ [Test]
+ public void WhenRegisterUnionSubclassWithNoRootThenThrows()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.Executing(x => x.IsTablePerConcreteClass(typeof(Inherited1))).Throws<MappingException>();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:48:13 UTC (rev 5582)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-02 20:54:38 UTC (rev 5583)
@@ -517,6 +517,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
+ <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
<Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Model.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 21:26:26
|
Revision: 5585
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5585&view=rev
Author: fabiomaulo
Date: 2011-04-02 21:26:20 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
IsEntity should use enlisted registrations
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 21:18:48 UTC (rev 5584)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-02 21:26:20 UTC (rev 5585)
@@ -404,7 +404,9 @@
tablePerClassEntities.Contains(type) ||
tablePerClassHierarchyEntities.Contains(type) ||
tablePerClassHierarchyJoinEntities.Contains(type) ||
- tablePerConcreteClassEntities.Contains(type);
+ tablePerConcreteClassEntities.Contains(type) ||
+ HasDelayedEntityRegistration(type)
+ ;
}
public bool IsTablePerClass(System.Type type)
@@ -556,5 +558,10 @@
registration(type);
}
}
+
+ private bool HasDelayedEntityRegistration(System.Type type)
+ {
+ return delayedEntityRegistrations.ContainsKey(type);
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs 2011-04-02 21:18:48 UTC (rev 5584)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassSequenceRegistrationTests.cs 2011-04-02 21:26:20 UTC (rev 5585)
@@ -33,5 +33,14 @@
inspector.Executing(x => x.IsTablePerClass(typeof(Inherited1))).Throws<MappingException>();
}
+
+ [Test]
+ public void WhenRegisterJoinedSubclassWithNoRootThenCanAskForIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-02 23:00:49
|
Revision: 5586
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5586&view=rev
Author: fabiomaulo
Date: 2011-04-02 23:00:42 +0000 (Sat, 02 Apr 2011)
Log Message:
-----------
- Domain to play with the API (note incomplete mapping)
- some API simplifications
- ported extensions to create the XML mapping to ask for support in forums.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionElementRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentElementMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapKeyMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyRelation.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementRelationCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentElementCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyComponentCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyRelationCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Generators.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/MappingsExtensions.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Address.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Animal.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Classification.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/DomesticAnimal.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Human.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Mammal.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Name.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Reptile.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/StateProvince.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/User.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Zoo.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/ShowXmlDemo.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs
Copied: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Generators.cs (from rev 5574, trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Generators.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Generators.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,185 @@
+using System;
+using System.Linq.Expressions;
+using System.Reflection;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public static class Generators
+ {
+ static Generators()
+ {
+ Native = new NativeGeneratorDef();
+ HighLow = new HighLowGeneratorDef();
+ Guid = new GuidGeneratorDef();
+ GuidComb = new GuidCombGeneratorDef();
+ Sequence = new SequenceGeneratorDef();
+ Identity = new IdentityGeneratorDef();
+ Assigned = new AssignedGeneratorDef();
+ }
+
+ public static IGeneratorDef Assigned { get; private set; }
+ public static IGeneratorDef Native { get; private set; }
+ public static IGeneratorDef HighLow { get; private set; }
+ public static IGeneratorDef Guid { get; private set; }
+ public static IGeneratorDef GuidComb { get; private set; }
+ public static IGeneratorDef Sequence { get; private set; }
+ public static IGeneratorDef Identity { get; private set; }
+
+ public static IGeneratorDef Foreign<TEntity>(Expression<Func<TEntity, object>> property)
+ {
+ return new ForeignGeneratorDef(TypeExtensions.DecodeMemberAccessExpression(property));
+ }
+
+ public static IGeneratorDef Foreign(MemberInfo property)
+ {
+ return new ForeignGeneratorDef(property);
+ }
+ }
+
+ public class AssignedGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "assigned"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class ForeignGeneratorDef : IGeneratorDef
+ {
+ private readonly object param;
+
+ public ForeignGeneratorDef(MemberInfo foreignProperty)
+ {
+ if (foreignProperty == null)
+ {
+ throw new ArgumentNullException("foreignProperty");
+ }
+ param = new {property = foreignProperty.Name};
+ }
+
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "foreign"; }
+ }
+
+ public object Params
+ {
+ get { return param; }
+ }
+
+ #endregion
+ }
+
+ public class NativeGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "native"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class HighLowGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "hilo"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class GuidGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "guid"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class GuidCombGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "guid.comb"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class SequenceGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "sequence"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+
+ public class IdentityGeneratorDef : IGeneratorDef
+ {
+ #region Implementation of IGeneratorDef
+
+ public string Class
+ {
+ get { return "identity"; }
+ }
+
+ public object Params
+ {
+ get { return null; }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionElementRelation.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionElementRelation.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ICollectionElementRelation.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -12,8 +12,11 @@
public interface ICollectionElementRelation<TElement>
{
+ void Element();
void Element(Action<IElementMapper> mapping);
+ void OneToMany();
void OneToMany(Action<IOneToManyMapper> mapping);
+ void ManyToMany();
void ManyToMany(Action<IManyToManyMapper> mapping);
void Component(Action<IComponentElementMapper<TElement>> mapping);
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentElementMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentElementMapper.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentElementMapper.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -16,11 +16,13 @@
public interface IComponentElementMapper<TComponent> : IComponentAttributesMapper<TComponent>
{
void Property<TProperty>(Expression<Func<TComponent, TProperty>> property, Action<IPropertyMapper> mapping);
+ void Property<TProperty>(Expression<Func<TComponent, TProperty>> property);
void Component<TNestedComponent>(Expression<Func<TComponent, TNestedComponent>> property,
Action<IComponentElementMapper<TNestedComponent>> mapping)
where TNestedComponent : class;
void ManyToOne<TProperty>(Expression<Func<TComponent, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class;
+ void ManyToOne<TProperty>(Expression<Func<TComponent, TProperty>> property) where TProperty : class;
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapKeyMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapKeyMapper.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IComponentMapKeyMapper.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -14,6 +14,7 @@
public interface IComponentMapKeyMapper<TComponent>
{
void Property<TProperty>(Expression<Func<TComponent, TProperty>> property, Action<IPropertyMapper> mapping);
+ void Property<TProperty>(Expression<Func<TComponent, TProperty>> property);
void ManyToOne<TProperty>(Expression<Func<TComponent, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class;
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyRelation.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyRelation.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IMapKeyRelation.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -11,7 +11,9 @@
public interface IMapKeyRelation<TKey>
{
+ void Element();
void Element(Action<IMapKeyMapper> mapping);
+ void ManyToMany();
void ManyToMany(Action<IMapKeyManyToManyMapper> mapping);
void Component(Action<IComponentMapKeyMapper<TKey>> mapping);
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -29,6 +29,8 @@
Action<IComponentMapper<TComponent>> mapping) where TComponent : class;
void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class;
+ void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property) where TProperty : class;
+
void OneToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IOneToOneMapper> mapping) where TProperty : class;
void Any<TProperty>(Expression<Func<TContainer, TProperty>> property, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class;
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementRelationCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementRelationCustomizer.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/CollectionElementRelationCustomizer.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -21,18 +21,33 @@
#region ICollectionElementRelation<TElement> Members
+ public void Element()
+ {
+ Element(x => { });
+ }
+
public void Element(Action<IElementMapper> mapping)
{
var collectionElementCustomizer = new CollectionElementCustomizer(propertyPath, customizersHolder);
mapping(collectionElementCustomizer);
}
+ public void OneToMany()
+ {
+ OneToMany(x => { });
+ }
+
public void OneToMany(Action<IOneToManyMapper> mapping)
{
var oneToManyCustomizer = new OneToManyCustomizer(explicitDeclarationsHolder, propertyPath, customizersHolder);
mapping(oneToManyCustomizer);
}
+ public void ManyToMany()
+ {
+ ManyToMany(x => { });
+ }
+
public void ManyToMany(Action<IManyToManyMapper> mapping)
{
var manyToManyCustomizer = new ManyToManyCustomizer(explicitDeclarationsHolder, propertyPath, customizersHolder);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentElementCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentElementCustomizer.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ComponentElementCustomizer.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -63,6 +63,11 @@
customizersHolder.AddCustomizer(new PropertyPath(propertyPath, memberOf), mapping);
}
+ public void Property<TProperty>(Expression<Func<TComponent, TProperty>> property)
+ {
+ Property(property, x => { });
+ }
+
public void Component<TNestedComponent>(Expression<Func<TComponent, TNestedComponent>> property, Action<IComponentElementMapper<TNestedComponent>> mapping)
where TNestedComponent : class
{
@@ -80,6 +85,11 @@
customizersHolder.AddCustomizer(new PropertyPath(propertyPath, memberOf), mapping);
}
+ public void ManyToOne<TProperty>(Expression<Func<TComponent, TProperty>> property) where TProperty : class
+ {
+ ManyToOne(property, x => { });
+ }
+
public void Access(Accessor accessor)
{
customizersHolder.AddCustomizer(typeof (TComponent), (IComponentAttributesMapper x) => x.Access(accessor));
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyComponentCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyComponentCustomizer.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyComponentCustomizer.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -23,6 +23,11 @@
customizersHolder.AddCustomizer(new PropertyPath(propertyPath, member), mapping);
}
+ public void Property<TProperty>(Expression<Func<TKey, TProperty>> property)
+ {
+ Property(property, x => { });
+ }
+
public void ManyToOne<TProperty>(Expression<Func<TKey, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyRelationCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyRelationCustomizer.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/MapKeyRelationCustomizer.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -21,12 +21,22 @@
#region IMapKeyRelation<TKey> Members
+ public void Element()
+ {
+ Element(x => { });
+ }
+
public void Element(Action<IMapKeyMapper> mapping)
{
var mapKeyCustomizer = new MapKeyCustomizer(propertyPath, customizersHolder);
mapping(mapKeyCustomizer);
}
+ public void ManyToMany()
+ {
+ ManyToMany(x => { });
+ }
+
public void ManyToMany(Action<IMapKeyManyToManyMapper> mapping)
{
var manyToManyCustomizer = new MapKeyManyToManyCustomizer(explicitDeclarationsHolder, propertyPath, customizersHolder);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -64,6 +64,11 @@
explicitDeclarationsHolder.AddAsManyToOneRelation(memberOf);
}
+ public void ManyToOne<TProperty>(Expression<Func<TEntity, TProperty>> property) where TProperty : class
+ {
+ ManyToOne(property, x => { });
+ }
+
public void OneToOne<TProperty>(Expression<Func<TEntity, TProperty>> property, Action<IOneToOneMapper> mapping)
where TProperty : class
{
Deleted: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/Generators.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -1,185 +0,0 @@
-using System;
-using System.Linq.Expressions;
-using System.Reflection;
-
-namespace NHibernate.Mapping.ByCode.Impl
-{
- public static class Generators
- {
- static Generators()
- {
- Native = new NativeGeneratorDef();
- HighLow = new HighLowGeneratorDef();
- Guid = new GuidGeneratorDef();
- GuidComb = new GuidCombGeneratorDef();
- Sequence = new SequenceGeneratorDef();
- Identity = new IdentityGeneratorDef();
- Assigned = new AssignedGeneratorDef();
- }
-
- public static IGeneratorDef Assigned { get; private set; }
- public static IGeneratorDef Native { get; private set; }
- public static IGeneratorDef HighLow { get; private set; }
- public static IGeneratorDef Guid { get; private set; }
- public static IGeneratorDef GuidComb { get; private set; }
- public static IGeneratorDef Sequence { get; private set; }
- public static IGeneratorDef Identity { get; private set; }
-
- public static IGeneratorDef Foreign<TEntity>(Expression<Func<TEntity, object>> property)
- {
- return new ForeignGeneratorDef(TypeExtensions.DecodeMemberAccessExpression(property));
- }
-
- public static IGeneratorDef Foreign(MemberInfo property)
- {
- return new ForeignGeneratorDef(property);
- }
- }
-
- public class AssignedGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "assigned"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class ForeignGeneratorDef : IGeneratorDef
- {
- private readonly object param;
-
- public ForeignGeneratorDef(MemberInfo foreignProperty)
- {
- if (foreignProperty == null)
- {
- throw new ArgumentNullException("foreignProperty");
- }
- param = new {property = foreignProperty.Name};
- }
-
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "foreign"; }
- }
-
- public object Params
- {
- get { return param; }
- }
-
- #endregion
- }
-
- public class NativeGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "native"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class HighLowGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "hilo"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class GuidGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "guid"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class GuidCombGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "guid.comb"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class SequenceGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "sequence"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-
- public class IdentityGeneratorDef : IGeneratorDef
- {
- #region Implementation of IGeneratorDef
-
- public string Class
- {
- get { return "identity"; }
- }
-
- public object Params
- {
- get { return null; }
- }
-
- #endregion
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/MappingsExtensions.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/MappingsExtensions.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/MappingsExtensions.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml;
+using System.Xml.Serialization;
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode
+{
+ /// <summary>
+ /// Util extensions to use in your test or where you need to see the XML mappings
+ /// </summary>
+ public static class MappingsExtensions
+ {
+ public static void WriteAllXmlMapping(this IEnumerable<HbmMapping> mappings)
+ {
+ if (mappings == null)
+ {
+ throw new ArgumentNullException("mappings");
+ }
+ string mappingsFolderPath = ArrangeMappingsFolderPath();
+ foreach (HbmMapping hbmMapping in mappings)
+ {
+ string fileName = GetFileName(hbmMapping);
+ string document = Serialize(hbmMapping);
+ File.WriteAllText(Path.Combine(mappingsFolderPath, fileName), document);
+ }
+ }
+
+ public static string AsString(this HbmMapping mappings)
+ {
+ if (mappings == null)
+ {
+ throw new ArgumentNullException("mappings");
+ }
+ return Serialize(mappings);
+ }
+
+ private static string ArrangeMappingsFolderPath()
+ {
+ string baseDir = AppDomain.CurrentDomain.BaseDirectory;
+ string relativeSearchPath = AppDomain.CurrentDomain.RelativeSearchPath;
+ string binPath = relativeSearchPath != null ? Path.Combine(baseDir, relativeSearchPath): baseDir;
+ string mappingsFolderPath = Path.Combine(binPath, "Mappings");
+
+ if (!Directory.Exists(mappingsFolderPath))
+ {
+ Directory.CreateDirectory(mappingsFolderPath);
+ }
+ else
+ {
+ System.Array.ForEach(Directory.GetFiles(mappingsFolderPath), File.Delete);
+ }
+ return mappingsFolderPath;
+ }
+
+ private static string GetFileName(HbmMapping hbmMapping)
+ {
+ string name = "MyMapping";
+ HbmClass rc = hbmMapping.RootClasses.FirstOrDefault();
+ if (rc != null)
+ {
+ name = rc.Name;
+ }
+ HbmSubclass sc = hbmMapping.SubClasses.FirstOrDefault();
+ if (sc != null)
+ {
+ name = sc.Name;
+ }
+ HbmJoinedSubclass jc = hbmMapping.JoinedSubclasses.FirstOrDefault();
+ if (jc != null)
+ {
+ name = jc.Name;
+ }
+ HbmUnionSubclass uc = hbmMapping.UnionSubclasses.FirstOrDefault();
+ if (uc != null)
+ {
+ name = uc.Name;
+ }
+ return name + ".hbm.xml";
+ }
+
+ private static string Serialize(HbmMapping hbmElement)
+ {
+ string result;
+ var setting = new XmlWriterSettings { Indent = true };
+ var serializer = new XmlSerializer(typeof(HbmMapping));
+ using (var memStream = new MemoryStream(2048))
+ {
+ using (XmlWriter xmlWriter = XmlWriter.Create(memStream, setting))
+ {
+ serializer.Serialize(xmlWriter, hbmElement);
+ }
+ memStream.Position = 0;
+ using (var sr = new StreamReader(memStream))
+ {
+ result = sr.ReadToEnd();
+ }
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-02 21:26:20 UTC (rev 5585)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-02 23:00:42 UTC (rev 5586)
@@ -363,7 +363,7 @@
<Compile Include="Mapping\ByCode\Impl\ElementMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\FilterMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\GeneratorMapper.cs" />
- <Compile Include="Mapping\ByCode\Impl\Generators.cs" />
+ <Compile Include="Mapping\ByCode\Generators.cs" />
<Compile Include="Mapping\ByCode\Impl\ICandidatePersistentMembersProvider.cs" />
<Compile Include="Mapping\ByCode\Impl\ICustomizersHolder.cs" />
<Compile Include="Mapping\ByCode\Impl\IdMapper.cs" />
@@ -404,6 +404,7 @@
<Compile Include="Mapping\ByCode\IVersionMapper.cs" />
<Compile Include="Mapping\ByCode\Lazy.cs" />
<Compile Include="Mapping\ByCode\ModelMapper.cs" />
+ <Compile Include="Mapping\ByCode\MappingsExtensions.cs" />
<Compile Include="Mapping\ByCode\NotFoundMode.cs" />
<Compile Include="Mapping\ByCode\SchemaAction.cs" />
<Compile Include="Mapping\ByCode\TypeExtensions.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Address.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Address.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Address.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,15 @@
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public class Address
+ {
+ public string Street { get; set; }
+
+ public string City { get; set; }
+
+ public string PostalCode { get; set; }
+
+ public string Country { get; set; }
+
+ public StateProvince StateProvince { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Animal.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Animal.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Animal.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,33 @@
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public class Animal
+ {
+ public virtual long Id { get; set; }
+
+ public virtual float BodyWeight { get; set; }
+
+ public virtual ISet<Animal> Offspring { get; set; }
+
+ public virtual Animal Mother { get; set; }
+
+ public virtual Animal Father { get; set; }
+
+ public virtual string Description { get; set; }
+
+ public virtual Zoo Zoo { get; set; }
+
+ public virtual string SerialNumber { get; set; }
+
+ public virtual void AddOffspring(Animal offSpring)
+ {
+ if (Offspring == null)
+ {
+ Offspring = new HashedSet<Animal>();
+ }
+
+ Offspring.Add(offSpring);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Classification.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Classification.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Classification.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public enum Classification
+ {
+ Cool = 0,
+ Lame = 1
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/DomesticAnimal.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/DomesticAnimal.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/DomesticAnimal.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,10 @@
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public class DomesticAnimal: Mammal
+ {
+ public virtual Human Owner { get; set; }
+ }
+
+ public class Cat : DomesticAnimal { }
+ public class Dog : DomesticAnimal { }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Human.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Human.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Human.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,32 @@
+using System.Collections.Generic;
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public class Human : Mammal
+ {
+ public virtual Name Name { get; set; }
+
+ public virtual string NickName { get; set; }
+
+ public virtual ICollection<Human> Friends { get; set; }
+
+ public virtual ICollection<DomesticAnimal> Pets { get; set; }
+
+ public virtual IDictionary<string, Human> Family { get; set; }
+
+ public virtual double Height { get; set; }
+
+ public virtual long BigIntegerValue { get; set; }
+
+ public virtual decimal BigDecimalValue { get; set; }
+
+ public virtual int IntValue { get; set; }
+
+ public virtual float FloatValue { get; set; }
+
+ public virtual ISet<string> NickNames { get; set; }
+
+ public virtual IDictionary<string, Address> Addresses { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Mammal.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Mammal.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/Naturalness/Mammal.cs 2011-04-02 23:00:42 UTC (rev 5586)
@@ -0,0 +1,16 @@
+using System;
+
+namespace NHibernate.Test.MappingByCode.NatureDemo.Naturalness
+{
+ public class Mammal : Animal
+ {
+ public Mammal()
+ {
+ Birthdate = DateTime.Today;
+ }
+
+ public virtual bool Pregnant { get; set; }
+
+ public virtual DateTime Birthdate { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NH...
[truncated message content] |
|
From: <fab...@us...> - 2011-04-03 13:29:07
|
Revision: 5588
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5588&view=rev
Author: fabiomaulo
Date: 2011-04-03 13:29:00 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Fixed IsEntity
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -400,13 +400,7 @@
public bool IsEntity(System.Type type)
{
- return rootEntities.Contains(type) ||
- tablePerClassEntities.Contains(type) ||
- tablePerClassHierarchyEntities.Contains(type) ||
- tablePerClassHierarchyJoinEntities.Contains(type) ||
- tablePerConcreteClassEntities.Contains(type) ||
- HasDelayedEntityRegistration(type)
- ;
+ return rootEntities.Contains(type) || type.GetBaseTypes().Any(t => rootEntities.Contains(t)) || HasDelayedEntityRegistration(type);
}
public bool IsTablePerClass(System.Type type)
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -74,5 +74,15 @@
inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
}
+
+ [Test]
+ public void WhenRegisteredAsJoinedSubclassThenIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassEntity(typeof(Inherited1));
+
+ inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -154,5 +154,14 @@
inspector.AddAsRootEntity(typeof(MyClass));
inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(MyClass))).Throws<MappingException>();
}
+
+ [Test]
+ public void WhenRegisteredAsRootThenIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+
+ inspector.IsEntity(typeof(MyClass)).Should().Be.True();
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -74,5 +74,15 @@
inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
}
+
+ [Test]
+ public void WhenRegisteredAsSubclassJoinThenIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
+
+ inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -75,5 +75,14 @@
inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
}
+ [Test]
+ public void WhenRegisteredAsSubclassThenIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
+
+ inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs 2011-04-03 11:20:11 UTC (rev 5587)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs 2011-04-03 13:29:00 UTC (rev 5588)
@@ -74,5 +74,15 @@
inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
}
+
+ [Test]
+ public void WhenRegisteredAsUnionSubclassThenIsEntity()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ inspector.AddAsRootEntity(typeof(MyClass));
+ inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
+
+ inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-03 13:52:13
|
Revision: 5590
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5590&view=rev
Author: fabiomaulo
Date: 2011-04-03 13:52:07 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Simplified API
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/ShowXmlDemo.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-04-03 13:43:54 UTC (rev 5589)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-04-03 13:52:07 UTC (rev 5590)
@@ -39,5 +39,8 @@
Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
Action<IMapKeyRelation<TKey>> keyMapping,
Action<ICollectionElementRelation<TElement>> mapping);
+ void Map<TKey, TElement>(Expression<Func<TEntity, IDictionary<TKey, TElement>>> property,
+ Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
+ Action<ICollectionElementRelation<TElement>> mapping);
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-03 13:43:54 UTC (rev 5589)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-03 13:52:07 UTC (rev 5590)
@@ -149,5 +149,12 @@
keyMapping(new MapKeyRelationCustomizer<TKey>(explicitDeclarationsHolder, memberOfPath, CustomizersHolder));
mapping(new CollectionElementRelationCustomizer<TElement>(explicitDeclarationsHolder, memberOfPath, CustomizersHolder));
}
+
+ public void Map<TKey, TElement>(Expression<Func<TEntity, IDictionary<TKey, TElement>>> property,
+ Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
+ Action<ICollectionElementRelation<TElement>> mapping)
+ {
+ Map(property, collectionMapping, keyMapping => { }, mapping);
+ }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/ShowXmlDemo.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/ShowXmlDemo.cs 2011-04-03 13:43:54 UTC (rev 5589)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/NatureDemo/ShowXmlDemo.cs 2011-04-03 13:52:07 UTC (rev 5590)
@@ -66,7 +66,7 @@
jsc.Property(human => human.BigDecimalValue);
jsc.Property(human => human.BigIntegerValue);
jsc.Bag(human => human.Friends, cm => { }, rel => rel.ManyToMany());
- jsc.Map(human => human.Family, cm => { }, km=> { }, rel => rel.ManyToMany());
+ jsc.Map(human => human.Family, cm => { }, rel => rel.ManyToMany());
jsc.Bag(human => human.Pets, cm => { cm.Inverse(true); }, rel => rel.OneToMany());
jsc.Set(human => human.NickNames, cm =>
{
@@ -97,8 +97,8 @@
rc.Id(x => x.Id, map => map.Generator(Generators.Native));
rc.Property(zoo => zoo.Name);
rc.Property(zoo => zoo.Classification);
- rc.Map(zoo => zoo.Mammals, cm => { }, km => { km.Element(); }, rel => rel.OneToMany());
- rc.Map(zoo => zoo.Animals, cm => { cm.Inverse(true); }, km => { km.Element(); }, rel => rel.OneToMany());
+ rc.Map(zoo => zoo.Mammals, cm => { }, rel => rel.OneToMany());
+ rc.Map(zoo => zoo.Animals, cm => { cm.Inverse(true); }, rel => rel.OneToMany());
rc.Component(zoo => zoo.Address, comp =>
{
comp.Property(address => address.Street);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-03 16:25:23
|
Revision: 5594
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5594&view=rev
Author: fabiomaulo
Date: 2011-04-03 16:25:16 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Natural Id mapping fixed
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/NaturalIdTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/For.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -36,7 +36,8 @@
void Schema(string schemaName);
void Mutable(bool isMutable);
void Version<TProperty>(Expression<Func<TEntity, TProperty>> versionProperty, Action<IVersionMapper> versionMapping);
- void NaturalId(Action<INaturalIdAttributesMapper> naturalIdMapping);
+ void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping, Action<INaturalIdAttributesMapper> naturalIdMapping);
+ void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping);
void Cache(Action<ICacheMapper> cacheMapping);
void Filter(string filterName, Action<IFilterMapper> filterMapping);
void Where(string whereClause);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPlainPropertyContainerMapper.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -19,19 +19,23 @@
void OneToOne(MemberInfo property, Action<IOneToOneMapper> mapping);
}
- public interface IPlainPropertyContainerMapper<TContainer>
+ public interface IBasePlainPropertyContainerMapper<TContainer>
{
void Property<TProperty>(Expression<Func<TContainer, TProperty>> property);
void Property<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IPropertyMapper> mapping);
void Property(FieldInfo member, Action<IPropertyMapper> mapping);
void Component<TComponent>(Expression<Func<TContainer, TComponent>> property,
- Action<IComponentMapper<TComponent>> mapping) where TComponent : class;
+ Action<IComponentMapper<TComponent>> mapping) where TComponent : class;
void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IManyToOneMapper> mapping) where TProperty : class;
void ManyToOne<TProperty>(Expression<Func<TContainer, TProperty>> property) where TProperty : class;
- void OneToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IOneToOneMapper> mapping) where TProperty : class;
void Any<TProperty>(Expression<Func<TContainer, TProperty>> property, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping) where TProperty : class;
}
+
+ public interface IPlainPropertyContainerMapper<TContainer> : IBasePlainPropertyContainerMapper<TContainer>
+ {
+ void OneToOne<TProperty>(Expression<Func<TContainer, TProperty>> property, Action<IOneToOneMapper> mapping) where TProperty : class;
+ }
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -75,11 +75,17 @@
CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.Version(member, versionMapping));
}
- public void NaturalId(Action<INaturalIdAttributesMapper> naturalIdMapping)
+ public void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping, Action<INaturalIdAttributesMapper> naturalIdMapping)
{
- CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.NaturalId(nidm => naturalIdMapping(nidm)));
+ naturalIdPropertiesMapping(new NaturalIdCustomizer<TEntity>(ExplicitDeclarationsHolder, CustomizersHolder));
+ CustomizersHolder.AddCustomizer(typeof(TEntity), (IClassAttributesMapper m) => m.NaturalId(nidm => naturalIdMapping(nidm)));
}
+ public void NaturalId(Action<IBasePlainPropertyContainerMapper<TEntity>> naturalIdPropertiesMapping)
+ {
+ NaturalId(naturalIdPropertiesMapping, mapAttr => { });
+ }
+
public void Cache(Action<ICacheMapper> cacheMapping)
{
CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.Cache(cacheMapping));
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/NaturalIdCustomizer.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -0,0 +1,61 @@
+using System.Reflection;
+
+namespace NHibernate.Mapping.ByCode.Impl.CustomizersImpl
+{
+ public class NaturalIdCustomizer<TEntity> : PropertyContainerCustomizer<TEntity>, IBasePlainPropertyContainerMapper<TEntity> where TEntity : class
+ {
+ public NaturalIdCustomizer(IModelExplicitDeclarationsHolder explicitDeclarationsHolder, ICustomizersHolder customizersHolder)
+ : base(explicitDeclarationsHolder, customizersHolder, null) {}
+
+ public override void Property<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IPropertyMapper> mapping)
+ {
+ MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
+ MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ ExplicitDeclarationsHolder.AddAsNaturalId(memberOf);
+ base.Property(property, mapping);
+ }
+
+ public override void Property(FieldInfo member, System.Action<IPropertyMapper> mapping)
+ {
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ base.Property(member, mapping);
+ }
+
+ public override void Component<TComponent>(System.Linq.Expressions.Expression<System.Func<TEntity, TComponent>> property, System.Action<IComponentMapper<TComponent>> mapping)
+ {
+ MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
+ MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ ExplicitDeclarationsHolder.AddAsNaturalId(memberOf);
+ base.Component(property, mapping);
+ }
+
+ public override void Any<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Type idTypeOfMetaType, System.Action<IAnyMapper> mapping)
+ {
+ MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
+ MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ ExplicitDeclarationsHolder.AddAsNaturalId(memberOf);
+ base.Any(property, idTypeOfMetaType, mapping);
+ }
+
+ public override void ManyToOne<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property)
+ {
+ MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
+ MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ ExplicitDeclarationsHolder.AddAsNaturalId(memberOf);
+ base.ManyToOne(property);
+ }
+
+ public override void ManyToOne<TProperty>(System.Linq.Expressions.Expression<System.Func<TEntity, TProperty>> property, System.Action<IManyToOneMapper> mapping)
+ {
+ MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
+ MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
+ ExplicitDeclarationsHolder.AddAsNaturalId(member);
+ ExplicitDeclarationsHolder.AddAsNaturalId(memberOf);
+ base.ManyToOne(property, mapping);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/PropertyContainerCustomizer.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -22,13 +22,17 @@
protected ICustomizersHolder CustomizersHolder { get; private set; }
protected PropertyPath PropertyPath { get; private set; }
+ protected IModelExplicitDeclarationsHolder ExplicitDeclarationsHolder
+ {
+ get { return explicitDeclarationsHolder; }
+ }
public void Property<TProperty>(Expression<Func<TEntity, TProperty>> property)
{
Property(property, x => { });
}
- public void Property<TProperty>(Expression<Func<TEntity, TProperty>> property, Action<IPropertyMapper> mapping)
+ public virtual void Property<TProperty>(Expression<Func<TEntity, TProperty>> property, Action<IPropertyMapper> mapping)
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property);
@@ -38,13 +42,13 @@
explicitDeclarationsHolder.AddAsProperty(memberOf);
}
- public void Property(FieldInfo member, Action<IPropertyMapper> mapping)
+ public virtual void Property(FieldInfo member, Action<IPropertyMapper> mapping)
{
CustomizersHolder.AddCustomizer(new PropertyPath(PropertyPath, member), mapping);
explicitDeclarationsHolder.AddAsProperty(member);
}
- public void Component<TComponent>(Expression<Func<TEntity, TComponent>> property,
+ public virtual void Component<TComponent>(Expression<Func<TEntity, TComponent>> property,
Action<IComponentMapper<TComponent>> mapping) where TComponent : class
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
@@ -53,7 +57,7 @@
mapping(new ComponentCustomizer<TComponent>(explicitDeclarationsHolder, CustomizersHolder, new PropertyPath(PropertyPath, memberOf)));
}
- public void ManyToOne<TProperty>(Expression<Func<TEntity, TProperty>> property, Action<IManyToOneMapper> mapping)
+ public virtual void ManyToOne<TProperty>(Expression<Func<TEntity, TProperty>> property, Action<IManyToOneMapper> mapping)
where TProperty : class
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
@@ -64,7 +68,7 @@
explicitDeclarationsHolder.AddAsManyToOneRelation(memberOf);
}
- public void ManyToOne<TProperty>(Expression<Func<TEntity, TProperty>> property) where TProperty : class
+ public virtual void ManyToOne<TProperty>(Expression<Func<TEntity, TProperty>> property) where TProperty : class
{
ManyToOne(property, x => { });
}
@@ -80,7 +84,7 @@
explicitDeclarationsHolder.AddAsOneToOneRelation(memberOf);
}
- public void Any<TProperty>(Expression<Func<TEntity, TProperty>> property, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping)
+ public virtual void Any<TProperty>(Expression<Func<TEntity, TProperty>> property, System.Type idTypeOfMetaType, Action<IAnyMapper> mapping)
where TProperty : class
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property);
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-03 16:25:16 UTC (rev 5594)
@@ -353,6 +353,7 @@
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\MapKeyManyToManyCustomizer.cs" />
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\MapKeyRelationCustomizer.cs" />
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\MapPropertiesCustomizer.cs" />
+ <Compile Include="Mapping\ByCode\Impl\CustomizersImpl\NaturalIdCustomizer.cs" />
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\OneToManyCustomizer.cs" />
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\PropertyContainerCustomizer.cs" />
<Compile Include="Mapping\ByCode\Impl\CustomizersImpl\SetPropertiesCustomizer.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/NaturalIdTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/NaturalIdTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/NaturalIdTests.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -0,0 +1,55 @@
+using System;
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExpliticMappingTests
+{
+ public class NaturalIdTests
+ {
+ private class MyClass
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public Related Related { get; set; }
+ public MyComponent MyComponent { get; set; }
+ public object Any { get; set; }
+ }
+
+ private class Related
+ {
+ public int Id { get; set; }
+ }
+
+ private class MyComponent
+ {
+ public string FirstName { get; set; }
+ }
+
+ [Test]
+ public void WhenDefineRootEntityThenRegister()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ var mapper = new ModelMapper(inspector);
+ mapper.Class<MyClass>(map =>
+ {
+ map.Id(x => x.Id, idmap => { });
+ map.NaturalId(nidm =>
+ {
+ nidm.Property(x => x.Name);
+ nidm.ManyToOne(x => x.Related);
+ nidm.Component(x => x.MyComponent, cmap =>
+ {
+ cmap.Property(y => y.FirstName);
+ });
+ nidm.Any(x => x.Any, typeof(int), anymap => { });
+ });
+ });
+
+ inspector.IsMemberOfNaturalId(For<MyClass>.Property(x => x.Name)).Should().Be.True();
+ inspector.IsMemberOfNaturalId(For<MyClass>.Property(x => x.Related)).Should().Be.True();
+ inspector.IsMemberOfNaturalId(For<MyClass>.Property(x => x.MyComponent)).Should().Be.True();
+ inspector.IsMemberOfNaturalId(For<MyClass>.Property(x => x.Any)).Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/For.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/For.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/For.cs 2011-04-03 16:25:16 UTC (rev 5594)
@@ -0,0 +1,19 @@
+using System;
+using System.Linq.Expressions;
+using System.Reflection;
+using NHibernate.Mapping.ByCode;
+
+namespace NHibernate.Test.MappingByCode
+{
+ public static class For<T>
+ {
+ public static MemberInfo Property(Expression<Func<T, object>> propertyGetter)
+ {
+ if (propertyGetter == null)
+ {
+ return null;
+ }
+ return TypeExtensions.DecodeMemberAccessExpression(propertyGetter);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 14:46:14 UTC (rev 5593)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 16:25:16 UTC (rev 5594)
@@ -519,6 +519,8 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\MappingOfPrivateMembersOnRootEntity.cs" />
+ <Compile Include="MappingByCode\ExpliticMappingTests\NaturalIdTests.cs" />
+ <Compile Include="MappingByCode\For.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Address.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Animal.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Classification.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-03 16:35:49
|
Revision: 5595
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5595&view=rev
Author: fabiomaulo
Date: 2011-04-03 16:35:43 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Fixed poid properties registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/PoidTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 16:25:16 UTC (rev 5594)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 16:35:43 UTC (rev 5595)
@@ -27,11 +27,13 @@
public void Id<TProperty>(Expression<Func<TEntity, TProperty>> idProperty, Action<IIdMapper> idMapper)
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(idProperty);
+ ExplicitDeclarationsHolder.AddAsPoid(member);
CustomizersHolder.AddCustomizer(typeof (TEntity), m => m.Id(member, idMapper));
}
public void Id(FieldInfo idProperty, Action<IIdMapper> idMapper)
{
+ ExplicitDeclarationsHolder.AddAsPoid(idProperty);
CustomizersHolder.AddCustomizer(typeof(TEntity), m => m.Id(idProperty, idMapper));
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/PoidTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/PoidTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/PoidTests.cs 2011-04-03 16:35:43 UTC (rev 5595)
@@ -0,0 +1,24 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExpliticMappingTests
+{
+ public class PoidTests
+ {
+ private class MyClass
+ {
+ public int Id { get; set; }
+ }
+
+ [Test]
+ public void WhenPropertyUsedAsPoidThenRegister()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ var mapper = new ModelMapper(inspector);
+ mapper.Class<MyClass>(map => map.Id(x => x.Id, idmap => { }));
+
+ inspector.IsPersistentId(For<MyClass>.Property(x => x.Id)).Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 16:25:16 UTC (rev 5594)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 16:35:43 UTC (rev 5595)
@@ -520,6 +520,7 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\NaturalIdTests.cs" />
+ <Compile Include="MappingByCode\ExpliticMappingTests\PoidTests.cs" />
<Compile Include="MappingByCode\For.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Address.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Animal.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-03 17:00:34
|
Revision: 5596
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5596&view=rev
Author: fabiomaulo
Date: 2011-04-03 17:00:28 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Fixed version property registration
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/VersionTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 16:35:43 UTC (rev 5595)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 17:00:28 UTC (rev 5596)
@@ -74,6 +74,7 @@
public void Version<TProperty>(Expression<Func<TEntity, TProperty>> versionProperty, Action<IVersionMapper> versionMapping)
{
MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(versionProperty);
+ ExplicitDeclarationsHolder.AddAsVersionProperty(member);
CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.Version(member, versionMapping));
}
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/VersionTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/VersionTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/VersionTests.cs 2011-04-03 17:00:28 UTC (rev 5596)
@@ -0,0 +1,30 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExpliticMappingTests
+{
+ public class VersionTests
+ {
+ private class MyClass
+ {
+ public int Id { get; set; }
+ public int Version { get; set; }
+ }
+
+ [Test]
+ public void WhenPropertyUsedAsPoidThenRegister()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ var mapper = new ModelMapper(inspector);
+ mapper.Class<MyClass>(
+ map =>
+ {
+ map.Id(x => x.Id, idmap => { });
+ map.Version(x => x.Version, vm => { });
+ });
+
+ inspector.IsVersion(For<MyClass>.Property(x => x.Version)).Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 16:35:43 UTC (rev 5595)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 17:00:28 UTC (rev 5596)
@@ -521,6 +521,7 @@
<Compile Include="MappingByCode\ExpliticMappingTests\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\NaturalIdTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\PoidTests.cs" />
+ <Compile Include="MappingByCode\ExpliticMappingTests\VersionTests.cs" />
<Compile Include="MappingByCode\For.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Address.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Animal.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-03 19:15:24
|
Revision: 5599
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5599&view=rev
Author: fabiomaulo
Date: 2011-04-03 19:15:17 +0000 (Sun, 03 Apr 2011)
Log Message:
-----------
Removed not well thought possible API
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelExplicitDeclarationsHolder.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -26,7 +26,6 @@
private readonly HashSet<MemberInfo> sets = new HashSet<MemberInfo>();
private readonly HashSet<System.Type> tablePerClassEntities = new HashSet<System.Type>();
private readonly HashSet<System.Type> tablePerClassHierarchyEntities = new HashSet<System.Type>();
- private readonly HashSet<System.Type> tablePerClassHierarchyJoinEntities = new HashSet<System.Type>();
private readonly HashSet<System.Type> tablePerConcreteClassEntities = new HashSet<System.Type>();
private readonly HashSet<MemberInfo> versionProperties = new HashSet<MemberInfo>();
private readonly Dictionary<System.Type, Action<System.Type>> delayedEntityRegistrations = new Dictionary<System.Type, Action<System.Type>>();
@@ -53,11 +52,6 @@
get { return tablePerClassHierarchyEntities; }
}
- public IEnumerable<System.Type> TablePerClassHierarchyJoinEntities
- {
- get { return tablePerClassHierarchyJoinEntities; }
- }
-
public IEnumerable<System.Type> TablePerConcreteClassEntities
{
get { return tablePerConcreteClassEntities; }
@@ -209,7 +203,7 @@
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
}
- if (IsMappedFor(tablePerClassEntities, type) || tablePerClassHierarchyJoinEntities.Contains(type) || IsMappedFor(tablePerConcreteClassEntities, type))
+ if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerConcreteClassEntities, type))
{
throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
}
@@ -225,41 +219,6 @@
}
}
- public void AddAsTablePerClassHierarchyJoinEntity(System.Type type)
- {
- AddAsTablePerClassHierarchyJoinEntity(type, false);
- }
-
- public void AddAsTablePerClassHierarchyJoinEntity(System.Type type, bool rootEntityMustExists)
- {
- if (IsComponent(type))
- {
- throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as entity and as component", type.FullName));
- }
- var rootEntity = GetRootEntityOrNull(type);
- if (rootEntity != null)
- {
- if (rootEntity.Equals(type))
- {
- throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered as root-entity and as subclass for table-per-class-hierarchy strategy", type.FullName));
- }
- if (IsMappedFor(tablePerClassEntities, type) || IsMappedFor(tablePerClassHierarchyEntities, type) || IsMappedFor(tablePerConcreteClassEntities, type))
- {
- throw new MappingException(string.Format("Abiguous mapping of {0}. It was registered with more than one class-hierarchy strategy", type.FullName));
- }
- tablePerClassHierarchyEntities.Add(rootEntity);
- tablePerClassHierarchyJoinEntities.Add(type);
- }
- else
- {
- if (rootEntityMustExists)
- {
- throw new MappingException(string.Format("The root entity for {0} was never registered", type.FullName));
- }
- EnlistTypeRegistration(type, t => AddAsTablePerClassHierarchyJoinEntity(t, true));
- }
- }
-
public void AddAsTablePerConcreteClassEntity(System.Type type)
{
AddAsTablePerConcreteClassEntity(type, false);
@@ -415,12 +374,6 @@
return IsMappedFor(tablePerClassHierarchyEntities, type);
}
- public bool IsTablePerClassHierarchyJoin(System.Type type)
- {
- ExecuteDelayedTypeRegistration(type);
- return tablePerClassHierarchyJoinEntities.Contains(type);
- }
-
public bool IsTablePerConcreteClass(System.Type type)
{
ExecuteDelayedTypeRegistration(type);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelExplicitDeclarationsHolder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelExplicitDeclarationsHolder.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelExplicitDeclarationsHolder.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -9,7 +9,6 @@
IEnumerable<System.Type> Components { get; }
IEnumerable<System.Type> TablePerClassEntities { get; }
IEnumerable<System.Type> TablePerClassHierarchyEntities { get; }
- IEnumerable<System.Type> TablePerClassHierarchyJoinEntities { get; }
IEnumerable<System.Type> TablePerConcreteClassEntities { get; }
IEnumerable<MemberInfo> OneToOneRelations { get; }
@@ -34,7 +33,6 @@
void AddAsComponent(System.Type type);
void AddAsTablePerClassEntity(System.Type type);
void AddAsTablePerClassHierarchyEntity(System.Type type);
- void AddAsTablePerClassHierarchyJoinEntity(System.Type type);
void AddAsTablePerConcreteClassEntity(System.Type type);
void AddAsOneToOneRelation(MemberInfo member);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -10,7 +10,6 @@
bool IsTablePerClass(System.Type type);
bool IsTablePerClassHierarchy(System.Type type);
- bool IsTablePerClassHierarchyJoin(System.Type type);
bool IsTablePerConcreteClass(System.Type type);
bool IsOneToOne(MemberInfo member);
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/ComponentMappingRegistrationTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -57,15 +57,6 @@
}
[Test]
- public void WhenRegisteredAsComponetThenCantRegisterAsSubclassJoin()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsComponent(typeof(MyComponent));
-
- inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(MyComponent))).Throws<MappingException>();
- }
-
- [Test]
public void WhenRegisteredAsComponetThenCantRegisterAsUnionSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/JoinedSubclassMappingStrategyTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -28,7 +28,6 @@
inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.True();
inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
}
@@ -41,7 +40,6 @@
inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.True();
inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
}
@@ -56,16 +54,6 @@
}
[Test]
- public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsSubclassJoin()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
public void WhenRegisteredAsJoinedSubclassThenCantRegisterAsUnionSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/RootClassMappingStrategyTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -26,7 +26,6 @@
inspector.AddAsRootEntity(typeof(MyClass));
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
@@ -38,7 +37,6 @@
inspector.AddAsTablePerClassEntity(typeof(Inherited1));
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
@@ -50,7 +48,6 @@
inspector.AddAsTablePerClassEntity(typeof(Inherited2));
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.True();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
@@ -62,7 +59,6 @@
inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
@@ -75,37 +71,11 @@
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
}
- [Test]
- public void WhenRegisteredSubclassJoinThenTheStrategyIsDefinedEvenForRoot()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
- inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
- }
-
[Test]
- public void WhenRegisteredDeepSubclassJoinThenTheStrategyIsDefinedEvenForRoot()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited2));
-
- inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.False();
- }
-
- [Test]
public void WhenRegisteredConcreteClassThenTheStrategyIsDefinedEvenForRoot()
{
var inspector = new ExplicitlyDeclaredModel();
@@ -114,7 +84,6 @@
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True();
}
@@ -127,7 +96,6 @@
inspector.IsTablePerClass(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(MyClass)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(MyClass)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(MyClass)).Should().Be.True();
}
Deleted: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinMappingStrategyTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -1,88 +0,0 @@
-using NHibernate.Mapping.ByCode;
-using NUnit.Framework;
-using SharpTestsEx;
-
-namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
-{
- public class SubclassJoinMappingStrategyTests
- {
- private class MyClass
- {
-
- }
- private class Inherited1 : MyClass
- {
-
- }
- private class Inherited2 : Inherited1
- {
-
- }
-
- [Test]
- public void WhenRegisteredAsSubclassJoinThenIsRegistered()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
- inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.True();
- inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
- }
-
- [Test]
- public void WhenRegisteredAsDeepSubclassJoinThenIsRegistered()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited2));
-
- inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
- inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.True();
- inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
- }
-
- [Test]
- public void WhenRegisteredAsSubclassJoinThenCantRegisterAsJoinedSubclass()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerClassEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
- public void WhenRegisteredAsSubclassJoinThenCantRegisterAsSubclass()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerClassHierarchyEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
- public void WhenRegisteredAsSubclassJoinThenCantRegisterAsUnionSubclass()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerConcreteClassEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
- public void WhenRegisteredAsSubclassJoinThenIsEntity()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.IsEntity(typeof(Inherited1)).Should().Be.True();
- }
- }
-}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassJoinSequenceRegistrationTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -1,37 +0,0 @@
-using NHibernate.Mapping.ByCode;
-using NUnit.Framework;
-using SharpTestsEx;
-
-namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
-{
- public class SubclassJoinSequenceRegistrationTests
- {
- private class MyClass
- {
-
- }
- private class Inherited1 : MyClass
- {
-
- }
-
- [Test]
- public void WhenRegisterSubclassJoinBeforeRootThenIsRegistered()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.True();
- }
-
- [Test]
- public void WhenRegisterSubclassWithNoRootThenThrows()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.IsTablePerClassHierarchyJoin(typeof(Inherited1))).Throws<MappingException>();
- }
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/SubclassMappingStrategyTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -28,7 +28,6 @@
inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.False();
}
@@ -41,7 +40,6 @@
inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.True();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.False();
}
@@ -56,16 +54,6 @@
}
[Test]
- public void WhenRegisteredAsSubclassThenCantRegisterAsSubclassJoin()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerClassHierarchyEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
public void WhenRegisteredAsSubclassThenCantRegisterAsUnionSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExplicitlyDeclaredModelTests/UnionSubclassMappingStrategyTests.cs 2011-04-03 19:15:17 UTC (rev 5599)
@@ -28,7 +28,6 @@
inspector.IsTablePerClass(typeof(Inherited1)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(Inherited1)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited1)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited1)).Should().Be.True();
}
@@ -41,7 +40,6 @@
inspector.IsTablePerClass(typeof(Inherited2)).Should().Be.False();
inspector.IsTablePerClassHierarchy(typeof(Inherited2)).Should().Be.False();
- inspector.IsTablePerClassHierarchyJoin(typeof(Inherited2)).Should().Be.False();
inspector.IsTablePerConcreteClass(typeof(Inherited2)).Should().Be.True();
}
@@ -56,16 +54,6 @@
}
[Test]
- public void WhenRegisteredAsUnionSubclassThenCantRegisterAsSubclassJoin()
- {
- var inspector = new ExplicitlyDeclaredModel();
- inspector.AddAsRootEntity(typeof(MyClass));
- inspector.AddAsTablePerConcreteClassEntity(typeof(Inherited1));
-
- inspector.Executing(x => x.AddAsTablePerClassHierarchyJoinEntity(typeof(Inherited1))).Throws<MappingException>();
- }
-
- [Test]
public void WhenRegisteredAsUnionSubclassThenCantRegisterAsJoinedSubclass()
{
var inspector = new ExplicitlyDeclaredModel();
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 17:53:11 UTC (rev 5598)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 19:15:17 UTC (rev 5599)
@@ -512,8 +512,6 @@
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\JoinedSubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\RootClassMappingStrategyTests.cs" />
- <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinMappingStrategyTests.cs" />
- <Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassJoinSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassMappingStrategyTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\SubclassSequenceRegistrationTests.cs" />
<Compile Include="MappingByCode\ExplicitlyDeclaredModelTests\UnionSubclassMappingStrategyTests.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 15:23:03
|
Revision: 5600
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5600&view=rev
Author: fabiomaulo
Date: 2011-04-04 15:22:56 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
Starting properties split management (<join>)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/RootClassPropertiesSplitsTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/ExplicitlyDeclaredModel.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -368,6 +368,11 @@
return IsMappedFor(tablePerClassEntities, type);
}
+ public bool IsTablePerClassSplit(System.Type type, object splitGroupId, MemberInfo member)
+ {
+ return false;
+ }
+
public bool IsTablePerClassHierarchy(System.Type type)
{
ExecuteDelayedTypeRegistration(type);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -44,5 +44,8 @@
void SchemaAction(SchemaAction action);
}
- public interface IClassMapper<TEntity> : IClassAttributesMapper<TEntity>, IPropertyContainerMapper<TEntity> where TEntity : class {}
+ public interface IClassMapper<TEntity> : IClassAttributesMapper<TEntity>, IPropertyContainerMapper<TEntity> where TEntity : class
+ {
+ void Join(Action<IJoinMapper<TEntity>> splittedMapping);
+ }
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
===================================================================
(Binary files differ)
Property changes on: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IModelInspector.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -9,6 +9,7 @@
bool IsEntity(System.Type type);
bool IsTablePerClass(System.Type type);
+ bool IsTablePerClassSplit(System.Type type, object splitGroupId, MemberInfo member);
bool IsTablePerClassHierarchy(System.Type type);
bool IsTablePerConcreteClass(System.Type type);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IPropertyContainerMapper.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -5,7 +5,7 @@
namespace NHibernate.Mapping.ByCode
{
- public interface IPropertyContainerMapper : IPlainPropertyContainerMapper
+ public interface ICollectionPropertiesContainerMapper
{
void Set(MemberInfo property, Action<ISetPropertiesMapper> collectionMapping,
Action<ICollectionElementRelation> mapping);
@@ -21,7 +21,9 @@
Action<ICollectionElementRelation> mapping);
}
- public interface IPropertyContainerMapper<TEntity> : IPlainPropertyContainerMapper<TEntity> where TEntity : class
+ public interface IPropertyContainerMapper : ICollectionPropertiesContainerMapper, IPlainPropertyContainerMapper {}
+
+ public interface ICollectionPropertiesContainerMapper<TEntity> where TEntity : class
{
void Set<TElement>(Expression<Func<TEntity, IEnumerable<TElement>>> property,
Action<ISetPropertiesMapper<TEntity, TElement>> collectionMapping,
@@ -39,8 +41,11 @@
Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
Action<IMapKeyRelation<TKey>> keyMapping,
Action<ICollectionElementRelation<TElement>> mapping);
+
void Map<TKey, TElement>(Expression<Func<TEntity, IDictionary<TKey, TElement>>> property,
- Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
- Action<ICollectionElementRelation<TElement>> mapping);
+ Action<IMapPropertiesMapper<TEntity, TKey, TElement>> collectionMapping,
+ Action<ICollectionElementRelation<TElement>> mapping);
}
+
+ public interface IPropertyContainerMapper<TEntity> : ICollectionPropertiesContainerMapper<TEntity>, IPlainPropertyContainerMapper<TEntity> where TEntity : class {}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/CustomizersImpl/ClassCustomizer.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -109,6 +109,11 @@
CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.SchemaAction(action));
}
+ public void Join(Action<IJoinMapper<TEntity>> splittedMapping)
+ {
+ throw new NotImplementedException();
+ }
+
public void EntityName(string value)
{
CustomizersHolder.AddCustomizer(typeof (TEntity), (IClassAttributesMapper m) => m.EntityName(value));
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-04 15:22:56 UTC (rev 5600)
@@ -309,6 +309,7 @@
<Compile Include="Mapping\ByCode\IGeneratorMapper.cs" />
<Compile Include="Mapping\ByCode\IIdMapper.cs" />
<Compile Include="Mapping\ByCode\IJoinedSubclassMapper.cs" />
+ <Compile Include="Mapping\ByCode\IJoinMapper.cs" />
<Compile Include="Mapping\ByCode\IKeyMapper.cs" />
<Compile Include="Mapping\ByCode\IListIndexMapper.cs" />
<Compile Include="Mapping\ByCode\IListPropertiesMapper.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/RootClassPropertiesSplitsTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/RootClassPropertiesSplitsTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/ExpliticMappingTests/RootClassPropertiesSplitsTests.cs 2011-04-04 15:22:56 UTC (rev 5600)
@@ -0,0 +1,51 @@
+using NHibernate.Mapping.ByCode;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.ExpliticMappingTests
+{
+ public class RootClassPropertiesSplitsTests
+ {
+ private class MyClass
+ {
+ public int Id { get; set; }
+ public string Something0 { get; set; }
+ public string SomethingA1 { get; set; }
+ public string SomethingA2 { get; set; }
+ public string SomethingB1 { get; set; }
+ public string SomethingB2 { get; set; }
+ }
+
+ [Test, Ignore("Not implemented yet")]
+ public void WhenSplittedPropertiesThenRegister()
+ {
+ var inspector = new ExplicitlyDeclaredModel();
+ var mapper = new ModelMapper(inspector);
+ mapper.Class<MyClass>(map =>
+ {
+ map.Id(x => x.Id, idmap => { });
+ map.Join(mj=>
+ {
+ mj.Table("MyClassSplit1");
+ mj.Property(x => x.SomethingA1);
+ mj.Property(x => x.SomethingA2);
+ });
+ map.Join(mj =>
+ {
+ mj.Table("MyClassSplit2");
+ mj.Property(x => x.SomethingB1);
+ mj.Property(x => x.SomethingB2);
+ });
+ map.Property(x => x.Something0);
+ });
+
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.Something0)).Should().Be.False();
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.Something0)).Should().Be.False();
+
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.SomethingA1)).Should().Be.True();
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit1", For<MyClass>.Property(x => x.SomethingA2)).Should().Be.True();
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.SomethingB1)).Should().Be.True();
+ inspector.IsTablePerClassSplit(typeof(MyClass), "MyClassSplit2", For<MyClass>.Property(x => x.SomethingB2)).Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-03 19:15:17 UTC (rev 5599)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-04 15:22:56 UTC (rev 5600)
@@ -519,6 +519,7 @@
<Compile Include="MappingByCode\ExpliticMappingTests\MappingOfPrivateMembersOnRootEntity.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\NaturalIdTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\PoidTests.cs" />
+ <Compile Include="MappingByCode\ExpliticMappingTests\RootClassPropertiesSplitsTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\VersionTests.cs" />
<Compile Include="MappingByCode\For.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Address.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 17:05:36
|
Revision: 5601
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5601&view=rev
Author: fabiomaulo
Date: 2011-04-04 17:05:30 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
Ctor and TableName management for JoinMapper
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-04 15:22:56 UTC (rev 5600)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IClassMapper.cs 2011-04-04 17:05:30 UTC (rev 5601)
@@ -22,7 +22,10 @@
void SchemaAction(SchemaAction action);
}
- public interface IClassMapper : IClassAttributesMapper, IPropertyContainerMapper {}
+ public interface IClassMapper : IClassAttributesMapper, IPropertyContainerMapper
+ {
+ void Join(Action<IJoinMapper> splittedMapping);
+ }
public interface IClassAttributesMapper<TEntity> : IEntityAttributesMapper, IEntitySqlsMapper where TEntity : class
{
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
===================================================================
(Binary files differ)
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs 2011-04-04 15:22:56 UTC (rev 5600)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ClassMapper.cs 2011-04-04 17:05:30 UTC (rev 5601)
@@ -168,6 +168,11 @@
classMapping.schemaaction = action.ToSchemaActionString();
}
+ public void Join(Action<IJoinMapper> splittedMapping)
+ {
+ throw new NotImplementedException();
+ }
+
#endregion
#region Implementation of IEntityAttributesMapper
Added: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:05:30 UTC (rev 5601)
@@ -0,0 +1,120 @@
+using System;
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode.Impl
+{
+ public class TableNameChangedEventArgs
+ {
+ public TableNameChangedEventArgs(string oldName, string newName)
+ {
+ OldName = oldName;
+ NewName = newName;
+ }
+ public string OldName { get; private set; }
+ public string NewName { get; private set; }
+ }
+ public delegate void TableNameChangedHandler(IJoinMapper mapper, TableNameChangedEventArgs args);
+
+ public class JoinMapper: AbstractPropertyContainerMapper,IJoinMapper
+ {
+ private readonly HbmJoin hbmJoin;
+
+ public JoinMapper(System.Type container, string splitGroupId, HbmJoin hbmJoin, HbmMapping mapDoc) : base(container, mapDoc)
+ {
+ if (splitGroupId == null)
+ {
+ throw new ArgumentNullException("splitGroupId");
+ }
+ if (hbmJoin == null)
+ {
+ throw new ArgumentNullException("hbmJoin");
+ }
+ this.hbmJoin = hbmJoin;
+ this.hbmJoin.table = splitGroupId.Trim();
+ if (string.IsNullOrEmpty(this.hbmJoin.table))
+ {
+ throw new ArgumentOutOfRangeException("splitGroupId", "The table-name cant be empty.");
+ }
+ }
+
+ public event TableNameChangedHandler TableNameChanged;
+
+ public void InvokeTableNameChanged(TableNameChangedEventArgs e)
+ {
+ TableNameChangedHandler handler = TableNameChanged;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+
+ protected override void AddProperty(object property)
+ {
+ }
+
+ public void Loader(string namedQueryReference)
+ {
+ // not supported by Join
+ }
+
+ public void SqlInsert(string sql)
+ {
+ }
+
+ public void SqlUpdate(string sql)
+ {
+ }
+
+ public void SqlDelete(string sql)
+ {
+ }
+
+ public void Subselect(string sql)
+ {
+ }
+
+ public void Table(string tableName)
+ {
+ if (tableName == null)
+ {
+ throw new ArgumentNullException("tableName");
+ }
+
+ var trimmedName = tableName.Trim();
+ if (string.IsNullOrEmpty(trimmedName))
+ {
+ throw new ArgumentOutOfRangeException("tableName", "The table-name cant be empty.");
+ }
+ var oldName = hbmJoin.table;
+ hbmJoin.table = trimmedName;
+ if(!trimmedName.Equals(oldName))
+ {
+ InvokeTableNameChanged(new TableNameChangedEventArgs(oldName, trimmedName));
+ }
+ }
+
+ public void Catalog(string catalogName)
+ {
+ }
+
+ public void Schema(string schemaName)
+ {
+ }
+
+ public void Key(Action<IKeyMapper> keyMapping)
+ {
+ }
+
+ public void Inverse(bool value)
+ {
+ }
+
+ public void Optional(bool isOptional)
+ {
+ }
+
+ public void Fetch(FetchMode fetchMode)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-04 15:22:56 UTC (rev 5600)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-04 17:05:30 UTC (rev 5601)
@@ -370,6 +370,7 @@
<Compile Include="Mapping\ByCode\Impl\ICustomizersHolder.cs" />
<Compile Include="Mapping\ByCode\Impl\IdMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\JoinedSubclassMapper.cs" />
+ <Compile Include="Mapping\ByCode\Impl\JoinMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\KeyManyToOneMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\KeyMapper.cs" />
<Compile Include="Mapping\ByCode\Impl\KeyPropertyMapper.cs" />
Added: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:05:30 UTC (rev 5601)
@@ -0,0 +1,81 @@
+using System;
+using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping.ByCode.Impl;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.MappingByCode.MappersTests
+{
+ public class JoinMapperTests
+ {
+ private class MyClass
+ {
+ public int Something { get; set; }
+ }
+
+ [Test]
+ public void WhenCreateWithEmptySplitGroupThenThrows()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ Executing.This(() => new JoinMapper(typeof(MyClass), null, hbmJoin, mapdoc)).Should().Throw<ArgumentNullException>();
+ Executing.This(() => new JoinMapper(typeof(MyClass), "", hbmJoin, mapdoc)).Should().Throw<ArgumentOutOfRangeException>();
+ Executing.This(() => new JoinMapper(typeof(MyClass), " ", hbmJoin, mapdoc)).Should().Throw<ArgumentOutOfRangeException>();
+ }
+
+ [Test]
+ public void WhenCreateWithNullHbmJoinThenThrows()
+ {
+ var mapdoc = new HbmMapping();
+ Executing.This(() => new JoinMapper(typeof(MyClass), "AA", null, mapdoc)).Should().Throw<ArgumentNullException>();
+ }
+
+ [Test]
+ public void WhenCreateThenSetDefaultTableName()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ new JoinMapper(typeof(MyClass), " AA ", hbmJoin, mapdoc);
+ hbmJoin.table.Should().Be("AA");
+ }
+
+ [Test]
+ public void CanSetTable()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Table(" Pizza ");
+ hbmJoin.table.Should().Be("Pizza");
+ }
+
+ [Test]
+ public void WhenSetTableNameEmptyThenThrows()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Executing(x => x.Table(null)).Throws<ArgumentNullException>();
+ mapper.Executing(x => x.Table("")).Throws<ArgumentOutOfRangeException>();
+ mapper.Executing(x => x.Table(" ")).Throws<ArgumentOutOfRangeException>();
+ }
+
+ [Test]
+ public void WhenTableNameChangesValueThenNotify()
+ {
+ bool eventCalled = false;
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.TableNameChanged += (m, x) =>
+ {
+ m.Should().Be.SameInstanceAs(mapper);
+ x.OldName.Should().Be("AA");
+ x.NewName.Should().Be("Pizza");
+ eventCalled = true;
+ };
+ mapper.Table(" Pizza ");
+ eventCalled.Should().Be.True();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-04 15:22:56 UTC (rev 5600)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-04-04 17:05:30 UTC (rev 5601)
@@ -522,6 +522,7 @@
<Compile Include="MappingByCode\ExpliticMappingTests\RootClassPropertiesSplitsTests.cs" />
<Compile Include="MappingByCode\ExpliticMappingTests\VersionTests.cs" />
<Compile Include="MappingByCode\For.cs" />
+ <Compile Include="MappingByCode\MappersTests\JoinMapperTests.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Address.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Animal.cs" />
<Compile Include="MappingByCode\NatureDemo\Naturalness\Classification.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 17:28:00
|
Revision: 5602
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5602&view=rev
Author: fabiomaulo
Date: 2011-04-04 17:27:54 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
JoinMapper more methods
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs 2011-04-04 17:05:30 UTC (rev 5601)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs 2011-04-04 17:27:54 UTC (rev 5602)
@@ -8,6 +8,7 @@
public static FetchMode Join = new JoinFetchMode();
public abstract HbmFetchMode ToHbm();
+ public abstract HbmJoinFetch ToHbmJoinFetch();
#region Nested type: JoinFetchMode
@@ -17,6 +18,11 @@
{
return HbmFetchMode.Join;
}
+
+ public override HbmJoinFetch ToHbmJoinFetch()
+ {
+ return HbmJoinFetch.Join;
+ }
}
#endregion
@@ -29,6 +35,11 @@
{
return HbmFetchMode.Select;
}
+
+ public override HbmJoinFetch ToHbmJoinFetch()
+ {
+ return HbmJoinFetch.Select;
+ }
}
#endregion
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:05:30 UTC (rev 5601)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:27:54 UTC (rev 5602)
@@ -39,7 +39,7 @@
public event TableNameChangedHandler TableNameChanged;
- public void InvokeTableNameChanged(TableNameChangedEventArgs e)
+ private void InvokeTableNameChanged(TableNameChangedEventArgs e)
{
TableNameChangedHandler handler = TableNameChanged;
if (handler != null)
@@ -59,18 +59,38 @@
public void SqlInsert(string sql)
{
+ if (hbmJoin.SqlInsert == null)
+ {
+ hbmJoin.sqlinsert = new HbmCustomSQL();
+ }
+ hbmJoin.sqlinsert.Text = new[] { sql };
}
public void SqlUpdate(string sql)
{
+ if (hbmJoin.SqlUpdate == null)
+ {
+ hbmJoin.sqlupdate = new HbmCustomSQL();
+ }
+ hbmJoin.sqlupdate.Text = new[] { sql };
}
public void SqlDelete(string sql)
{
+ if (hbmJoin.SqlDelete == null)
+ {
+ hbmJoin.sqldelete = new HbmCustomSQL();
+ }
+ hbmJoin.sqldelete.Text = new[] { sql };
}
public void Subselect(string sql)
{
+ if (hbmJoin.Subselect == null)
+ {
+ hbmJoin.subselect = new HbmSubselect();
+ }
+ hbmJoin.subselect.Text = new[] { sql };
}
public void Table(string tableName)
@@ -95,10 +115,12 @@
public void Catalog(string catalogName)
{
+ hbmJoin.catalog = catalogName;
}
public void Schema(string schemaName)
{
+ hbmJoin.schema = schemaName;
}
public void Key(Action<IKeyMapper> keyMapping)
@@ -107,14 +129,17 @@
public void Inverse(bool value)
{
+ hbmJoin.inverse = value;
}
public void Optional(bool isOptional)
{
+ hbmJoin.optional = isOptional;
}
public void Fetch(FetchMode fetchMode)
{
+ hbmJoin.fetch = fetchMode.ToHbmJoinFetch();
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:05:30 UTC (rev 5601)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:27:54 UTC (rev 5602)
@@ -77,5 +77,103 @@
mapper.Table(" Pizza ");
eventCalled.Should().Be.True();
}
+
+ [Test]
+ public void CanSetCatalog()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Catalog("pizza");
+ hbmJoin.catalog.Should().Be("pizza");
+ }
+
+ [Test]
+ public void CanSetSchema()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Schema("pizza");
+ hbmJoin.schema.Should().Be("pizza");
+ }
+
+ [Test]
+ public void CanSetSqlInsert()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.SqlInsert("blah");
+
+ hbmJoin.SqlInsert.Should().Not.Be.Null();
+ hbmJoin.SqlInsert.Text[0].Should().Be("blah");
+ }
+
+ [Test]
+ public void SetSqlUpdate()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.SqlUpdate("blah");
+
+ hbmJoin.SqlUpdate.Should().Not.Be.Null();
+ hbmJoin.SqlUpdate.Text[0].Should().Be("blah");
+ }
+
+ [Test]
+ public void SetSqlDelete()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.SqlDelete("blah");
+
+ hbmJoin.SqlDelete.Should().Not.Be.Null();
+ hbmJoin.SqlDelete.Text[0].Should().Be("blah");
+ }
+
+ [Test]
+ public void CanSetSqlSubselect()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Subselect("blah");
+
+ hbmJoin.Subselect.Should().Not.Be.Null();
+ hbmJoin.subselect.Text[0].Should().Be("blah");
+ }
+
+ [Test]
+ public void CanSetInverse()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Inverse(true);
+ hbmJoin.inverse.Should().Be.True();
+ }
+
+ [Test]
+ public void CanSetOptional()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Optional(true);
+ hbmJoin.optional.Should().Be.True();
+ }
+
+ [Test]
+ public void CanSetFetch()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ mapper.Fetch(Mapping.ByCode.FetchMode.Select);
+ hbmJoin.fetch.Should().Be(HbmJoinFetch.Select);
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 17:31:22
|
Revision: 5603
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5603&view=rev
Author: fabiomaulo
Date: 2011-04-04 17:31:15 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
Renamed class to avoid namespace conflicts
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToOneMapper.cs
trunk/nhibernate/src/NHibernate/NHibernate.csproj
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchKind.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs
Copied: trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchKind.cs (from rev 5602, trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchKind.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchKind.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -0,0 +1,47 @@
+using NHibernate.Cfg.MappingSchema;
+
+namespace NHibernate.Mapping.ByCode
+{
+ public abstract class FetchKind
+ {
+ public static FetchKind Select = new SelectFetchMode();
+ public static FetchKind Join = new JoinFetchMode();
+
+ public abstract HbmFetchMode ToHbm();
+ public abstract HbmJoinFetch ToHbmJoinFetch();
+
+ #region Nested type: JoinFetchMode
+
+ private class JoinFetchMode : FetchKind
+ {
+ public override HbmFetchMode ToHbm()
+ {
+ return HbmFetchMode.Join;
+ }
+
+ public override HbmJoinFetch ToHbmJoinFetch()
+ {
+ return HbmJoinFetch.Join;
+ }
+ }
+
+ #endregion
+
+ #region Nested type: SelectFetchMode
+
+ private class SelectFetchMode : FetchKind
+ {
+ public override HbmFetchMode ToHbm()
+ {
+ return HbmFetchMode.Select;
+ }
+
+ public override HbmJoinFetch ToHbmJoinFetch()
+ {
+ return HbmJoinFetch.Select;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/FetchMode.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -1,47 +0,0 @@
-using NHibernate.Cfg.MappingSchema;
-
-namespace NHibernate.Mapping.ByCode
-{
- public abstract class FetchMode
- {
- public static FetchMode Select = new SelectFetchMode();
- public static FetchMode Join = new JoinFetchMode();
-
- public abstract HbmFetchMode ToHbm();
- public abstract HbmJoinFetch ToHbmJoinFetch();
-
- #region Nested type: JoinFetchMode
-
- private class JoinFetchMode : FetchMode
- {
- public override HbmFetchMode ToHbm()
- {
- return HbmFetchMode.Join;
- }
-
- public override HbmJoinFetch ToHbmJoinFetch()
- {
- return HbmJoinFetch.Join;
- }
- }
-
- #endregion
-
- #region Nested type: SelectFetchMode
-
- private class SelectFetchMode : FetchMode
- {
- public override HbmFetchMode ToHbm()
- {
- return HbmFetchMode.Select;
- }
-
- public override HbmJoinFetch ToHbmJoinFetch()
- {
- return HbmJoinFetch.Select;
- }
- }
-
- #endregion
- }
-}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IJoinMapper.cs
===================================================================
(Binary files differ)
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToOneMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToOneMapper.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/IManyToOneMapper.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -16,7 +16,7 @@
void Unique(bool unique);
void UniqueKey(string uniquekeyName);
void Index(string indexName);
- void Fetch(FetchMode fetchMode);
+ void Fetch(FetchKind fetchMode);
void Formula(string formula);
void Lazy(LazyRelation lazyRelation);
void Update(bool consideredInUpdateQuery);
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -137,7 +137,7 @@
hbmJoin.optional = isOptional;
}
- public void Fetch(FetchMode fetchMode)
+ public void Fetch(FetchKind fetchMode)
{
hbmJoin.fetch = fetchMode.ToHbmJoinFetch();
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyManyToOneMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyManyToOneMapper.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/KeyManyToOneMapper.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -70,7 +70,7 @@
Column(x => x.Index(indexName));
}
- public void Fetch(FetchMode fetchMode)
+ public void Fetch(FetchKind fetchMode)
{
// not supported by HbmKeyManyToOne
}
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToOneMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToOneMapper.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/ManyToOneMapper.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -70,7 +70,7 @@
Column(x => x.Index(indexName));
}
- public void Fetch(FetchMode fetchMode)
+ public void Fetch(FetchKind fetchMode)
{
manyToOne.fetch = fetchMode.ToHbm();
manyToOne.fetchSpecified = manyToOne.fetch == HbmFetchMode.Join;
Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2011-04-04 17:31:15 UTC (rev 5603)
@@ -282,7 +282,7 @@
<Compile Include="Mapping\ByCode\CollectionLazy.cs" />
<Compile Include="Mapping\ByCode\ExplicitlyDeclaredModel.cs" />
<Compile Include="Mapping\ByCode\FakeModelExplicitDeclarationsHolder.cs" />
- <Compile Include="Mapping\ByCode\FetchMode.cs" />
+ <Compile Include="Mapping\ByCode\FetchKind.cs" />
<Compile Include="Mapping\ByCode\ForClass.cs" />
<Compile Include="Mapping\ByCode\IAccessorPropertyMapper.cs" />
<Compile Include="Mapping\ByCode\IAnyMapper.cs" />
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:27:54 UTC (rev 5602)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:31:15 UTC (rev 5603)
@@ -1,5 +1,6 @@
using System;
using NHibernate.Cfg.MappingSchema;
+using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Impl;
using NUnit.Framework;
using SharpTestsEx;
@@ -172,7 +173,7 @@
var mapdoc = new HbmMapping();
var hbmJoin = new HbmJoin();
var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
- mapper.Fetch(Mapping.ByCode.FetchMode.Select);
+ mapper.Fetch(FetchKind.Select);
hbmJoin.fetch.Should().Be(HbmJoinFetch.Select);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 17:49:32
|
Revision: 5604
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5604&view=rev
Author: fabiomaulo
Date: 2011-04-04 17:49:26 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
JoinMapper full attributes managed
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:31:15 UTC (rev 5603)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 17:49:26 UTC (rev 5604)
@@ -18,6 +18,7 @@
public class JoinMapper: AbstractPropertyContainerMapper,IJoinMapper
{
private readonly HbmJoin hbmJoin;
+ private readonly KeyMapper keyMapper;
public JoinMapper(System.Type container, string splitGroupId, HbmJoin hbmJoin, HbmMapping mapDoc) : base(container, mapDoc)
{
@@ -35,6 +36,11 @@
{
throw new ArgumentOutOfRangeException("splitGroupId", "The table-name cant be empty.");
}
+ if (hbmJoin.key == null)
+ {
+ hbmJoin.key = new HbmKey { column1 = container.Name.ToLowerInvariant() + "_key" };
+ }
+ keyMapper = new KeyMapper(container, hbmJoin.key);
}
public event TableNameChangedHandler TableNameChanged;
@@ -125,6 +131,7 @@
public void Key(Action<IKeyMapper> keyMapping)
{
+ keyMapping(keyMapper);
}
public void Inverse(bool value)
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:31:15 UTC (rev 5603)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 17:49:26 UTC (rev 5604)
@@ -176,5 +176,43 @@
mapper.Fetch(FetchKind.Select);
hbmJoin.fetch.Should().Be(HbmJoinFetch.Select);
}
+
+ [Test]
+ public void CallKeyMapper()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ var keyMapperCalled = false;
+
+ mapper.Key(km => keyMapperCalled = true);
+
+ keyMapperCalled.Should().Be.True();
+ }
+
+ [Test]
+ public void WhenCallKeyMapperThenKeyMapperIsNotNull()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+
+ mapper.Key(km => km.Should().Not.Be.Null());
+ }
+
+ [Test]
+ public void WhenCallKeyMapperMoreThanOnceThenKeyMapperIsTheSame()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+ IKeyMapper firstCallInstance = null;
+ IKeyMapper secondCallInstance= null;
+
+ mapper.Key(km => firstCallInstance = km);
+ mapper.Key(km => secondCallInstance = km);
+
+ firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance);
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2011-04-04 18:28:37
|
Revision: 5606
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5606&view=rev
Author: fabiomaulo
Date: 2011-04-04 18:28:31 +0000 (Mon, 04 Apr 2011)
Log Message:
-----------
JoinMapper done
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
Modified: trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 18:22:58 UTC (rev 5605)
+++ trunk/nhibernate/src/NHibernate/Mapping/ByCode/Impl/JoinMapper.cs 2011-04-04 18:28:31 UTC (rev 5606)
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using NHibernate.Cfg.MappingSchema;
namespace NHibernate.Mapping.ByCode.Impl
@@ -56,6 +57,12 @@
protected override void AddProperty(object property)
{
+ if (property == null)
+ {
+ throw new ArgumentNullException("property");
+ }
+ var toAdd = new[] { property };
+ hbmJoin.Items = hbmJoin.Items == null ? toAdd : hbmJoin.Items.Concat(toAdd).ToArray();
}
public void Loader(string namedQueryReference)
Modified: trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 18:22:58 UTC (rev 5605)
+++ trunk/nhibernate/src/NHibernate.Test/MappingByCode/MappersTests/JoinMapperTests.cs 2011-04-04 18:28:31 UTC (rev 5606)
@@ -214,5 +214,17 @@
firstCallInstance.Should().Be.SameInstanceAs(secondCallInstance);
}
+
+ [Test]
+ public void WhenAddPropertyThenAddItem()
+ {
+ var mapdoc = new HbmMapping();
+ var hbmJoin = new HbmJoin();
+ var mapper = new JoinMapper(typeof(MyClass), "AA", hbmJoin, mapdoc);
+
+ mapper.Property(For<MyClass>.Property(mc => mc.Something), x => { });
+
+ hbmJoin.Properties.Should().Have.Count.EqualTo(1);
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|