From 13081b244fbfb97b2c8690fb03585d29f9c72182 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Thu, 23 Mar 2017 20:22:51 +1300 Subject: [PATCH 1/8] NH-3722 - Remove entity mode switching capability * Ported from HHH-6330 https://github.com/hibernate/hibernate-orm/commit/4a4f636caf9ecc62fe0d230f422ad3eab2517db0 * ISession.GetSession is renamed to ISession.GetChildSession --- src/NHibernate.DomainModel/CustomPersister.cs | 90 ++-- src/NHibernate.Test/CacheTest/CacheFixture.cs | 2 +- .../CacheTest/FilterKeyFixture.cs | 12 +- .../CacheTest/QueryKeyFixture.cs | 16 +- .../Criteria/AddNumberProjection.cs | 2 +- .../Interceptor/ProxyInterceptor.cs | 19 +- .../EngineTest/TypedValueFixture.cs | 8 +- .../Map/Basic/DynamicClassFixture.cs | 18 +- .../Multi/MultiRepresentationFixture.cs | 188 -------- .../EntityModeTest/Multi/Stock.cs | 21 - .../EntityModeTest/Multi/Stock.hbm.xml | 22 - .../EntityModeTest/Multi/Valuation.cs | 15 - .../EntityModeTest/Multi/Valuation.hbm.xml | 20 - .../Xml/Accessors/XmlAccessorFixture.cs | 120 ----- .../EntityModeTest/Xml/Basic/AB.hbm.xml | 22 - .../EntityModeTest/Xml/Basic/Account.hbm.xml | 47 -- .../EntityModeTest/Xml/Basic/Employer.hbm.xml | 33 -- .../EntityModeTest/Xml/Basic/XmlFixture.cs | 337 -------------- .../EntityModeTest/Xml/Many2One/Car.cs | 21 - .../EntityModeTest/Xml/Many2One/Car.hbm.xml | 32 -- .../EntityModeTest/Xml/Many2One/CarPart.cs | 11 - .../EntityModeTest/Xml/Many2One/CarType.cs | 11 - .../Xml/Many2One/XmlManyToOneFixture.cs | 106 ----- .../ExpressionTest/JunctionFixture.cs | 4 +- .../FilterTest/DynamicFilterTest.cs | 2 +- .../Dates/DateTimeOffsetFixture.cs | 2 +- .../EntityModeToTuplizerPerf/Fixture.cs | 93 ---- .../NHSpecificTest/NH1677/Fixture.cs | 6 - .../NH1714/SimpleReproductionFixture.cs | 2 +- .../NH1714/UseCaseDemonstrationFixture.cs | 2 +- .../NHSpecificTest/NH2374/NH2374Fixture.cs | 2 +- src/NHibernate.Test/NHibernate.Test.csproj | 16 - .../TypesTest/DateTime2TypeFixture.cs | 4 +- .../TypesTest/DateTimeTypeFixture.cs | 4 +- .../TypesTest/EntityTypeFixture.cs | 22 +- .../TypesTest/PersistentEnumTypeFixture.cs | 6 +- .../Parameterized/DefaultableListType.cs | 9 +- src/NHibernate/Action/CollectionAction.cs | 4 +- src/NHibernate/Action/EntityAction.cs | 2 +- src/NHibernate/Action/EntityDeleteAction.cs | 2 +- .../Action/EntityIdentityInsertAction.cs | 2 +- src/NHibernate/Action/EntityInsertAction.cs | 2 +- src/NHibernate/Action/EntityUpdateAction.cs | 4 +- src/NHibernate/Cache/CacheKey.cs | 9 +- src/NHibernate/Cache/Entry/CacheEntry.cs | 2 +- src/NHibernate/Cache/FilterKey.cs | 8 +- src/NHibernate/Cfg/Environment.cs | 2 +- .../FluentSessionFactoryConfiguration.cs | 6 - .../IFluentSessionFactoryConfiguration.cs | 1 - .../Cfg/MappingSchema/MappingExtensions.cs | 2 - src/NHibernate/Cfg/Settings.cs | 2 - src/NHibernate/Cfg/SettingsFactory.cs | 9 +- .../Cfg/XmlHbmBinding/ClassBinder.cs | 7 - .../AbstractPersistentCollection.cs | 6 +- .../Generic/PersistentGenericBag.cs | 21 +- .../Generic/PersistentGenericIdentifierBag.cs | 4 +- .../Generic/PersistentGenericList.cs | 4 +- .../Generic/PersistentGenericMap.cs | 3 +- .../Generic/PersistentGenericSet.cs | 3 +- .../Collection/PersistentArrayHolder.cs | 4 +- .../Criterion/ConstantProjection.cs | 2 +- src/NHibernate/Criterion/CriterionUtil.cs | 2 +- src/NHibernate/Criterion/Example.cs | 23 +- src/NHibernate/Criterion/InExpression.cs | 6 +- src/NHibernate/Criterion/LikeExpression.cs | 4 +- src/NHibernate/Criterion/SQLCriterion.cs | 2 +- .../Criterion/SimpleSubqueryExpression.cs | 2 +- src/NHibernate/EmptyInterceptor.cs | 2 +- src/NHibernate/Engine/BatchFetchQueue.cs | 4 +- src/NHibernate/Engine/Cascade.cs | 15 +- src/NHibernate/Engine/CollectionKey.cs | 12 +- src/NHibernate/Engine/Collections.cs | 12 +- src/NHibernate/Engine/EntityEntry.cs | 13 +- src/NHibernate/Engine/EntityKey.cs | 14 +- src/NHibernate/Engine/EntityUniqueKey.cs | 8 +- src/NHibernate/Engine/ForeignKeys.cs | 8 +- src/NHibernate/Engine/ISessionImplementor.cs | 3 - .../Engine/Loading/CollectionLoadContext.cs | 11 +- src/NHibernate/Engine/Loading/LoadContexts.cs | 2 +- src/NHibernate/Engine/Nullability.cs | 2 +- .../Engine/StatefulPersistenceContext.cs | 12 +- src/NHibernate/Engine/TwoPhaseLoad.cs | 2 +- src/NHibernate/Engine/TypedValue.cs | 28 +- src/NHibernate/EntityMode.cs | 36 +- src/NHibernate/EntityModeEqualityComparer.cs | 19 - .../Default/AbstractFlushingEventListener.cs | 4 +- .../AbstractReassociateEventListener.cs | 2 +- .../Default/AbstractSaveEventListener.cs | 10 +- .../Event/Default/AbstractVisitor.cs | 2 +- .../Default/DefaultDeleteEventListener.cs | 12 +- .../DefaultFlushEntityEventListener.cs | 35 +- .../Event/Default/DefaultLoadEventListener.cs | 4 +- .../Event/Default/DefaultLockEventListener.cs | 2 +- .../Default/DefaultMergeEventListener.cs | 42 +- .../Default/DefaultPostLoadEventListener.cs | 2 +- .../Default/DefaultRefreshEventListener.cs | 2 +- .../Default/DefaultReplicateEventListener.cs | 4 +- .../DefaultSaveOrUpdateEventListener.cs | 13 +- .../Default/DefaultUpdateEventListener.cs | 6 +- src/NHibernate/Event/Default/EvictVisitor.cs | 2 +- .../Event/Default/ReattachVisitor.cs | 2 +- src/NHibernate/Event/Default/WrapVisitor.cs | 9 +- src/NHibernate/IInterceptor.cs | 3 +- src/NHibernate/ISession.cs | 17 +- src/NHibernate/Id/Assigned.cs | 2 +- src/NHibernate/Id/ForeignGenerator.cs | 2 +- src/NHibernate/Id/SelectGenerator.cs | 3 +- src/NHibernate/Impl/AbstractDetachedQuery.cs | 6 +- src/NHibernate/Impl/AbstractQueryImpl.cs | 6 +- src/NHibernate/Impl/AbstractSessionImpl.cs | 10 +- src/NHibernate/Impl/ExpressionQueryImpl.cs | 2 +- src/NHibernate/Impl/MultiCriteriaImpl.cs | 2 +- src/NHibernate/Impl/MultiQueryImpl.cs | 2 +- src/NHibernate/Impl/Printer.cs | 11 +- src/NHibernate/Impl/SessionFactoryImpl.cs | 14 +- src/NHibernate/Impl/SessionImpl.cs | 73 +-- src/NHibernate/Impl/StatelessSessionImpl.cs | 31 +- .../Loader/Collection/CollectionLoader.cs | 4 +- .../Criteria/CriteriaQueryTranslator.cs | 12 +- .../Loader/Entity/BatchingEntityLoader.cs | 2 +- src/NHibernate/Loader/Loader.cs | 9 +- src/NHibernate/Mapping/Component.cs | 12 +- src/NHibernate/Mapping/PersistentClass.cs | 6 +- src/NHibernate/Mapping/Property.cs | 5 - src/NHibernate/Metadata/IClassMetadata.cs | 23 +- src/NHibernate/NHibernate.csproj | 7 +- .../DynamicFilterParameterSpecification.cs | 14 +- .../Entity/AbstractEntityPersister.cs | 131 +++--- .../Persister/Entity/IEntityPersister.cs | 84 ++-- .../Entity/SingleTableEntityPersister.cs | 6 +- .../Properties/PropertyAccessorFactory.cs | 13 +- src/NHibernate/Properties/XmlAccessor.cs | 426 ------------------ .../ComponentEntityModeToTuplizerMapping.cs | 96 ---- .../Tuple/Component/ComponentMetamodel.cs | 19 +- .../Component/ComponentTuplizerFactory.cs | 40 ++ .../Tuple/Entity/AbstractEntityTuplizer.cs | 8 +- .../EntityEntityModeToTuplizerMapping.cs | 102 ----- .../Tuple/Entity/EntityMetamodel.cs | 26 +- .../Tuple/Entity/EntityTuplizerFactory.cs | 41 ++ .../Tuple/EntityModeToTuplizerMapping.cs | 99 ---- src/NHibernate/Type/AbstractBinaryType.cs | 21 +- .../Type/AbstractDateTimeSpecificKindType.cs | 4 +- src/NHibernate/Type/AbstractType.cs | 26 +- src/NHibernate/Type/AnyType.cs | 10 +- src/NHibernate/Type/ArrayType.cs | 4 +- src/NHibernate/Type/ClassMetaType.cs | 2 +- src/NHibernate/Type/CollectionType.cs | 28 +- src/NHibernate/Type/ComponentType.cs | 148 +++--- src/NHibernate/Type/CompositeCustomType.cs | 12 +- src/NHibernate/Type/CustomType.cs | 11 +- src/NHibernate/Type/DateTimeType.cs | 2 +- src/NHibernate/Type/DateType.cs | 2 +- src/NHibernate/Type/EntityType.cs | 92 ++-- src/NHibernate/Type/IAbstractComponentType.cs | 4 +- src/NHibernate/Type/IType.cs | 20 +- src/NHibernate/Type/IType.cs.xmldoc | 1 - src/NHibernate/Type/IVersionType.cs | 10 +- src/NHibernate/Type/ImmutableType.cs | 2 +- src/NHibernate/Type/ManyToOneType.cs | 4 +- src/NHibernate/Type/MetaType.cs | 2 +- src/NHibernate/Type/MutableType.cs | 6 +- src/NHibernate/Type/NullableType.cs | 7 +- src/NHibernate/Type/SerializableType.cs | 4 +- src/NHibernate/Type/TimeType.cs | 2 +- src/NHibernate/Type/TypeHelper.cs | 4 +- 165 files changed, 767 insertions(+), 2883 deletions(-) delete mode 100644 src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Multi/Stock.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Multi/Stock.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Multi/Valuation.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Multi/Valuation.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Basic/AB.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Basic/Account.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Basic/Employer.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.hbm.xml delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarPart.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarType.cs delete mode 100644 src/NHibernate.Test/EntityModeTest/Xml/Many2One/XmlManyToOneFixture.cs delete mode 100644 src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs delete mode 100644 src/NHibernate/EntityModeEqualityComparer.cs delete mode 100644 src/NHibernate/Properties/XmlAccessor.cs delete mode 100644 src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs create mode 100644 src/NHibernate/Tuple/Component/ComponentTuplizerFactory.cs delete mode 100644 src/NHibernate/Tuple/Entity/EntityEntityModeToTuplizerMapping.cs create mode 100644 src/NHibernate/Tuple/Entity/EntityTuplizerFactory.cs delete mode 100644 src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs diff --git a/src/NHibernate.DomainModel/CustomPersister.cs b/src/NHibernate.DomainModel/CustomPersister.cs index ee552dc0e33..ced287db77a 100644 --- a/src/NHibernate.DomainModel/CustomPersister.cs +++ b/src/NHibernate.DomainModel/CustomPersister.cs @@ -34,14 +34,6 @@ public CustomPersister(PersistentClass model, ICacheConcurrencyStrategy cache, I this.factory = factory; } - private static void CheckEntityMode(EntityMode entityMode) - { - if (EntityMode.Poco != entityMode) - { - throw new ArgumentOutOfRangeException("entityMode", "Unhandled EntityMode : " + entityMode); - } - } - #region IEntityPersister Members public ISessionFactoryImplementor Factory @@ -377,21 +369,11 @@ public object ForceVersionIncrement(object id, object currentVersion, ISessionIm return null; } - public EntityMode? GuessEntityMode(object obj) - { - if (!IsInstance(obj, EntityMode.Poco)) - { - return null; - } - else - { - return EntityMode.Poco; - } - } + public EntityMode EntityMode => EntityMode.Poco; - public bool IsInstrumented(EntityMode entityMode) + public bool IsInstrumented { - return false; + get { return false; } } public bool HasInsertGeneratedProperties @@ -424,7 +406,7 @@ public object CreateProxy(object id, ISessionImplementor session) public object[] GetPropertyValuesToInsert(object obj, IDictionary mergeMap, ISessionImplementor session) { - return GetPropertyValues(obj, session.EntityMode); + return GetPropertyValues(obj); } public void ProcessInsertGeneratedProperties(object id, object entity, object[] state, ISessionImplementor session) @@ -435,109 +417,91 @@ public void ProcessUpdateGeneratedProperties(object id, object entity, object[] { } - public System.Type GetMappedClass(EntityMode entityMode) + public System.Type MappedClass { - CheckEntityMode(entityMode); - return typeof(Custom); + get { return typeof(Custom); } } - public bool ImplementsLifecycle(EntityMode entityMode) + public bool ImplementsLifecycle { - CheckEntityMode(entityMode); - return false; + get { return false; } } - public bool ImplementsValidatable(EntityMode entityMode) + public bool ImplementsValidatable { - CheckEntityMode(entityMode); - return false; + get { return false; } } - public System.Type GetConcreteProxyClass(EntityMode entityMode) + public System.Type ConcreteProxyClass { - CheckEntityMode(entityMode); - return typeof (Custom); + get { return typeof(Custom); } } - public void SetPropertyValues(object obj, object[] values, EntityMode entityMode) + public void SetPropertyValues(object obj, object[] values) { - CheckEntityMode(entityMode); - SetPropertyValue(obj, 0, values[0], entityMode); + SetPropertyValue(obj, 0, values[0]); } - public void SetPropertyValue(object obj, int i, object value, EntityMode entityMode) + public void SetPropertyValue(object obj, int i, object value) { - CheckEntityMode(entityMode); ((Custom) obj).Name = (string) value; } - public object[] GetPropertyValues(object obj, EntityMode entityMode) + public object[] GetPropertyValues(object obj) { - CheckEntityMode(entityMode); Custom c = (Custom) obj; return new Object[] {c.Name}; } - public object GetPropertyValue(object obj, int i, EntityMode entityMode) + public object GetPropertyValue(object obj, int i) { - CheckEntityMode(entityMode); return ((Custom)obj).Name; } - public object GetPropertyValue(object obj, string name, EntityMode entityMode) + public object GetPropertyValue(object obj, string name) { - CheckEntityMode(entityMode); return ((Custom)obj).Name; } - public object GetIdentifier(object obj, EntityMode entityMode) + public object GetIdentifier(object obj) { - CheckEntityMode(entityMode); return ((Custom)obj).Id; } - public void SetIdentifier(object obj, object id, EntityMode entityMode) + public void SetIdentifier(object obj, object id) { - CheckEntityMode(entityMode); ((Custom) obj).Id = (string) id; } - public object GetVersion(object obj, EntityMode entityMode) + public object GetVersion(object obj) { - CheckEntityMode(entityMode); return null; } - public object Instantiate(object id, EntityMode entityMode) + public object Instantiate(object id) { - CheckEntityMode(entityMode); Custom c = new Custom(); c.Id = (string)id; return c; } - public bool IsInstance(object entity, EntityMode entityMode) + public bool IsInstance(object entity) { - CheckEntityMode(entityMode); return entity is Custom; } - public bool HasUninitializedLazyProperties(object obj, EntityMode entityMode) + public bool HasUninitializedLazyProperties(object obj) { - CheckEntityMode(entityMode); return false; } - public void ResetIdentifier(object entity, object currentId, object currentVersion, EntityMode entityMode) + public void ResetIdentifier(object entity, object currentId, object currentVersion) { - CheckEntityMode(entityMode); ((Custom)entity).Id = (string)currentId; } - public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory, - EntityMode entityMode) + public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory) { - CheckEntityMode(entityMode); return this; } @@ -553,6 +517,8 @@ public IComparer VersionComparator get { return null; } } + public IEntityTuplizer EntityTuplizer => null; + #endregion } } diff --git a/src/NHibernate.Test/CacheTest/CacheFixture.cs b/src/NHibernate.Test/CacheTest/CacheFixture.cs index 8c41063d7b9..d7ec22069cc 100644 --- a/src/NHibernate.Test/CacheTest/CacheFixture.cs +++ b/src/NHibernate.Test/CacheTest/CacheFixture.cs @@ -18,7 +18,7 @@ public void TestSimpleCache() private CacheKey CreateCacheKey(string text) { - return new CacheKey(text, NHibernateUtil.String, "Foo", EntityMode.Poco, null); + return new CacheKey(text, NHibernateUtil.String, "Foo", null); } public void DoTestCache(ICacheProvider cacheProvider) diff --git a/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs b/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs index 5f39a1d894f..0adb65e6b29 100644 --- a/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs +++ b/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs @@ -24,13 +24,13 @@ public void ToStringIncludeAll() string filterName = "DescriptionLike"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); - var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionLike{'pLike'='so%'}]")); filterName = "DescriptionEqualAndValueGT"; f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); - fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionEqualAndValueGT{'pDesc'='something', 'pValue'='10'}]")); } @@ -51,11 +51,11 @@ private void FilterDescLikeToCompare(out FilterKey fk, out FilterKey fk1) const string filterName = "DescriptionLike"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); - fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); f1.SetParameter("pLike", "%ing"); - fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); } private void FilterDescValueToCompare(out FilterKey fk, out FilterKey fk1) @@ -63,11 +63,11 @@ private void FilterDescValueToCompare(out FilterKey fk, out FilterKey fk1) const string filterName = "DescriptionEqualAndValueGT"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); - fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); - fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); } [Test] diff --git a/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs b/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs index 581031b0368..c6ea39b55f3 100644 --- a/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs +++ b/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs @@ -40,13 +40,13 @@ private void QueryKeyFilterDescLikeToCompare(out QueryKey qk, out QueryKey qk1) const string filterName = "DescriptionLike"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); - var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); f1.SetParameter("pLike", "%ing"); - var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk1 }; qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); } @@ -57,13 +57,13 @@ private void QueryKeyFilterDescValueToCompare(out QueryKey qk, out QueryKey qk1) var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); - var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); - var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk1 }; qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); } @@ -111,7 +111,7 @@ public void ToStringWithFilters() string filterName = "DescriptionLike"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); - var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk }; var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); Assert.That(qk.ToString(), Does.Contain(string.Format("filters: ['{0}']",fk))); @@ -119,7 +119,7 @@ public void ToStringWithFilters() filterName = "DescriptionEqualAndValueGT"; f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pDesc", "something").SetParameter("pValue", 10); - fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); fks = new HashSet { fk }; qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); Assert.That(qk.ToString(), Does.Contain(string.Format("filters: ['{0}']", fk))); @@ -131,12 +131,12 @@ public void ToStringWithMoreFilters() string filterName = "DescriptionLike"; var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); f.SetParameter("pLike", "so%"); - var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); filterName = "DescriptionEqualAndValueGT"; var fv = new FilterImpl(sessions.GetFilterDefinition(filterName)); fv.SetParameter("pDesc", "something").SetParameter("pValue", 10); - var fvk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + var fvk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes); ISet fks = new HashSet { fk, fvk }; var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), fks, null); diff --git a/src/NHibernate.Test/Criteria/AddNumberProjection.cs b/src/NHibernate.Test/Criteria/AddNumberProjection.cs index 929f81f3127..a2483507e1c 100644 --- a/src/NHibernate.Test/Criteria/AddNumberProjection.cs +++ b/src/NHibernate.Test/Criteria/AddNumberProjection.cs @@ -18,7 +18,7 @@ public AddNumberProjection(string propertyName, int numberToAdd) { this.propertyName = propertyName; this.numberToAdd = numberToAdd; - typedValue = new TypedValue(NHibernateUtil.Int32, this.numberToAdd, EntityMode.Poco); + typedValue = new TypedValue(NHibernateUtil.Int32, this.numberToAdd); } public override bool IsAggregate diff --git a/src/NHibernate.Test/DynamicEntity/Interceptor/ProxyInterceptor.cs b/src/NHibernate.Test/DynamicEntity/Interceptor/ProxyInterceptor.cs index 67fbcd67051..3fc1b3bba45 100644 --- a/src/NHibernate.Test/DynamicEntity/Interceptor/ProxyInterceptor.cs +++ b/src/NHibernate.Test/DynamicEntity/Interceptor/ProxyInterceptor.cs @@ -8,20 +8,17 @@ public override string GetEntityName(object entity) return entityName; } - public override object Instantiate(string entityName, EntityMode entityMode, object id) + public override object Instantiate(string entityName, object id) { - if (entityMode == EntityMode.Poco) + if (typeof(Customer).FullName.Equals(entityName)) { - if (typeof(Customer).FullName.Equals(entityName)) - { - return ProxyHelper.NewCustomerProxy(id); - } - else if (typeof(Company).FullName.Equals(entityName)) - { - return ProxyHelper.NewCompanyProxy(id); - } + return ProxyHelper.NewCustomerProxy(id); } - return base.Instantiate(entityName, entityMode, id); + else if (typeof(Company).FullName.Equals(entityName)) + { + return ProxyHelper.NewCompanyProxy(id); + } + return base.Instantiate(entityName, id); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/EngineTest/TypedValueFixture.cs b/src/NHibernate.Test/EngineTest/TypedValueFixture.cs index a21b5cb6ba0..8a8db910ffc 100644 --- a/src/NHibernate.Test/EngineTest/TypedValueFixture.cs +++ b/src/NHibernate.Test/EngineTest/TypedValueFixture.cs @@ -16,8 +16,8 @@ public void EqualsCollection() ArrayList value2 = (ArrayList) value1.Clone(); - TypedValue t1 = new TypedValue(NHibernateUtil.Int32, value1, EntityMode.Poco); - TypedValue t2 = new TypedValue(NHibernateUtil.Int32, value2, EntityMode.Poco); + TypedValue t1 = new TypedValue(NHibernateUtil.Int32, value1); + TypedValue t2 = new TypedValue(NHibernateUtil.Int32, value2); Assert.IsTrue(t1.Equals(t2)); } @@ -25,7 +25,7 @@ public void EqualsCollection() [Test] public void ToStringWithNullValue() { - Assert.AreEqual("null", new TypedValue(NHibernateUtil.Int32, null, EntityMode.Poco).ToString()); + Assert.AreEqual("null", new TypedValue(NHibernateUtil.Int32, null).ToString()); } [Test] @@ -34,7 +34,7 @@ public void WhenTheTypeIsAnArray_ChoseTheDefaultComparer() byte[] value = new byte[]{1,2,3}; - var tv = new TypedValue(NHibernateUtil.BinaryBlob, value, EntityMode.Poco); + var tv = new TypedValue(NHibernateUtil.BinaryBlob, value); Assert.That(tv.Comparer, Is.TypeOf()); } diff --git a/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs b/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs index 76c48a006ef..7d2185493a3 100644 --- a/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs +++ b/src/NHibernate.Test/EntityModeTest/Map/Basic/DynamicClassFixture.cs @@ -20,19 +20,15 @@ protected override IList Mappings get { return new string[] {"EntityModeTest.Map.Basic.ProductLine.hbm.xml"}; } } - protected override void Configure(Configuration configuration) - { - configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(EntityMode.Map)); - } - public delegate IDictionary SingleCarQueryDelegate(ISession session); public delegate IList AllModelQueryDelegate(ISession session); [Test] public void ShouldWorkWithHQL() { - TestLazyDynamicClass(s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(), - s => s.CreateQuery("from Model m").List()); + TestLazyDynamicClass( + s => (IDictionary) s.CreateQuery("from ProductLine pl order by pl.Description").UniqueResult(), + s => s.CreateQuery("from Model m").List()); } [Test] @@ -46,14 +42,6 @@ public void ShouldWorkWithCriteria() public void TestLazyDynamicClass(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler) { ITransaction t; - using (ISession s = OpenSession()) - { - var si = (ISessionImplementor)s; - Assert.IsTrue(si.EntityMode == EntityMode.Map, "Incorrectly handled default_entity_mode"); - ISession other = s.GetSession(EntityMode.Poco); - other.Close(); - Assert.IsFalse(other.IsOpen); - } IDictionary cars; IList models; using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs b/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs deleted file mode 100644 index c54201556c5..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Multi/MultiRepresentationFixture.cs +++ /dev/null @@ -1,188 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Xml; -using NUnit.Framework; - -namespace NHibernate.Test.EntityModeTest.Multi -{ - [TestFixture, Ignore("Not supported yet.")] - public class MultiRepresentationFixture : TestCase - { - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - protected override IList Mappings - { - get { return new[] {"EntityModeTest.Multi.Stock.hbm.xml", "EntityModeTest.Multi.Valuation.hbm.xml"}; } - } - - private class TestData - { - private readonly ISessionFactory sessions; - public long stockId; - - public TestData(ISessionFactory factory) - { - sessions = factory; - } - - public void Create() - { - ISession session = sessions.OpenSession(); - session.BeginTransaction(); - var stock = new Stock {TradeSymbol = "NHForge"}; - var valuation = new Valuation {Stock = stock, ValuationDate = DateTime.Now, Value = 200.0D}; - stock.CurrentValuation = valuation; - stock.Valuations.Add(valuation); - - session.Save(stock); - session.Save(valuation); - - session.Transaction.Commit(); - session.Close(); - - stockId = stock.Id; - } - - public void Destroy() - { - ISession session = sessions.OpenSession(); - session.BeginTransaction(); - IList stocks = session.CreateQuery("from Stock").List(); - foreach (Stock stock in stocks) - { - stock.CurrentValuation = null; - session.Flush(); - foreach (Valuation valuation in stock.Valuations) - { - session.Delete(valuation); - } - session.Delete(stock); - } - session.Transaction.Commit(); - session.Close(); - } - } - - [Test] - public void PocoRetreival() - { - var testData = new TestData(sessions); - testData.Create(); - - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); - - var stock = session.Get(1); - Assert.That(stock.Id, Is.EqualTo(1L)); - - txn.Commit(); - session.Close(); - - testData.Destroy(); - } - - [Test] - public void XmlHQL() - { - var testData = new TestData(sessions); - testData.Create(); - - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); - ISession xml = session.GetSession(EntityMode.Xml); - - IList result = xml.CreateQuery("from Stock").List(); - - Assert.That(result.Count, Is.EqualTo(1L)); - var element = (XmlElement) result[0]; - Assert.That(element.Attributes["id"], Is.EqualTo(testData.stockId)); - - Console.WriteLine("**** XML: ****************************************************"); - //prettyPrint( element ); - Console.WriteLine("**************************************************************"); - - txn.Rollback(); - session.Close(); - - testData.Destroy(); - } - - [Test] - public void XmlRetreival() - { - var testData = new TestData(sessions); - testData.Create(); - - ISession session = OpenSession(); - ITransaction txn = session.BeginTransaction(); - ISession xml = session.GetSession(EntityMode.Xml); - - object rtn = xml.Get(typeof (Stock).FullName, testData.stockId); - var element = (XmlElement) rtn; - - Assert.That(element.Attributes["id"], Is.EqualTo(testData.stockId)); - - Console.WriteLine("**** XML: ****************************************************"); - //prettyPrint( element ); - Console.WriteLine("**************************************************************"); - - XmlNode currVal = element.GetElementsByTagName("currentValuation")[0]; - - Console.WriteLine("**** XML: ****************************************************"); - //prettyPrint( currVal ); - Console.WriteLine("**************************************************************"); - - txn.Rollback(); - session.Close(); - - testData.Destroy(); - } - - [Test] - public void XmlSave() - { - var testData = new TestData(sessions); - testData.Create(); - - ISession pojos = OpenSession(); - ITransaction txn = pojos.BeginTransaction(); - ISession xml = pojos.GetSession(EntityMode.Xml); - - var domDoc = new XmlDocument(); - XmlElement stock = domDoc.CreateElement("stock"); - domDoc.AppendChild(stock); - XmlElement tradeSymbol = domDoc.CreateElement("tradeSymbol"); - tradeSymbol.InnerText = "Microsoft"; - stock.AppendChild(tradeSymbol); - - XmlElement cval = domDoc.CreateElement("currentValuation"); - XmlElement val = domDoc.CreateElement("valuation"); - stock.AppendChild(cval); - //val.appendContent(stock); TODO - XmlElement valuationDate = domDoc.CreateElement("valuationDate"); - tradeSymbol.InnerText = DateTime.Now.ToString(); - val.AppendChild(valuationDate); - - XmlElement value = domDoc.CreateElement("value"); - tradeSymbol.InnerText = "121.00"; - val.AppendChild(value); - - xml.Save(typeof (Stock).FullName, stock); - xml.Flush(); - - txn.Rollback(); - pojos.Close(); - - Assert.That(!pojos.IsOpen); - Assert.That(!xml.IsOpen); - - //prettyPrint( stock ); - - testData.Destroy(); - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Multi/Stock.cs b/src/NHibernate.Test/EntityModeTest/Multi/Stock.cs deleted file mode 100644 index c8037f3d33c..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Multi/Stock.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; - -namespace NHibernate.Test.EntityModeTest.Multi -{ - public class Stock - { - private ISet valuations = new HashSet(); - - public virtual long Id { get; set; } - - public virtual string TradeSymbol { get; set; } - - public virtual Valuation CurrentValuation { get; set; } - - public virtual ISet Valuations - { - get { return valuations; } - set { valuations = value; } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Multi/Stock.hbm.xml b/src/NHibernate.Test/EntityModeTest/Multi/Stock.hbm.xml deleted file mode 100644 index 8812e356eb4..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Multi/Stock.hbm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Multi/Valuation.cs b/src/NHibernate.Test/EntityModeTest/Multi/Valuation.cs deleted file mode 100644 index a47915a28aa..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Multi/Valuation.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace NHibernate.Test.EntityModeTest.Multi -{ - public class Valuation - { - public virtual long Id { get; set; } - - public virtual Stock Stock { get; set; } - - public virtual DateTime ValuationDate { get; set; } - - public virtual double Value { get; set; } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Multi/Valuation.hbm.xml b/src/NHibernate.Test/EntityModeTest/Multi/Valuation.hbm.xml deleted file mode 100644 index 7ef6afbe232..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Multi/Valuation.hbm.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs b/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs deleted file mode 100644 index 4f11b51a430..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Accessors/XmlAccessorFixture.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Xml; -using NHibernate.Mapping; -using NHibernate.Properties; -using NUnit.Framework; - -namespace NHibernate.Test.EntityModeTest.Xml.Accessors -{ - [TestFixture] - public class XmlAccessorFixture - { - public static XmlElement dom = GenerateTestElement(); - - private static XmlElement GenerateTestElement() - { - const string xml = -@" - description... - NHForge - -"; - - var baseXml = new XmlDocument(); - baseXml.LoadXml(xml); - return baseXml.DocumentElement; - } - - private static XmlElement GenerateRootTestElement() - { - return (new XmlDocument()).CreateElement("company"); - } - - private static Property GenerateAccountIdProperty() - { - var value = new SimpleValue {TypeName = "long"}; - - return new Property {Name = "number", NodeName = "account/@num", Value = value}; - } - - private static Property GenerateTextProperty() - { - var value = new SimpleValue {TypeName = "string"}; - - return new Property {Name = "text", NodeName = ".", Value = value}; - } - - private static Property GenerateNameProperty() - { - var value = new SimpleValue {TypeName = "string"}; - - return new Property {Name = "name", NodeName = "name", Value = value}; - } - - private static Property GenerateIdProperty() - { - var value = new SimpleValue {TypeName = "long"}; - - return new Property {Name = "id", NodeName = "@id", Value = value}; - } - - [Test] - public void CompanyElementGeneration() - { - ISetter idSetter = PropertyAccessorFactory.GetPropertyAccessor(GenerateIdProperty(), EntityMode.Xml).GetSetter(null, - null); - ISetter nameSetter = - PropertyAccessorFactory.GetPropertyAccessor(GenerateNameProperty(), EntityMode.Xml).GetSetter(null, null); - ISetter textSetter = - PropertyAccessorFactory.GetPropertyAccessor(GenerateTextProperty(), EntityMode.Xml).GetSetter(null, null); - ISetter accountIdSetter = - PropertyAccessorFactory.GetPropertyAccessor(GenerateAccountIdProperty(), EntityMode.Xml).GetSetter(null, null); - - XmlNode root = GenerateRootTestElement(); - - idSetter.Set(root, 123L); - textSetter.Set(root, "description..."); - nameSetter.Set(root, "NHForge"); - accountIdSetter.Set(root, 456L); - - Console.WriteLine(dom.OuterXml); - //Assert.That(new NodeComparator().Compare(dom, root) == 0); - } - - [Test] - public void LongAttributeExtraction() - { - Property property = GenerateIdProperty(); - IGetter getter = PropertyAccessorFactory.GetPropertyAccessor(property, EntityMode.Xml).GetGetter(null, null); - var id = (long) getter.Get(dom); - Assert.That(id, Is.EqualTo(123L)); - } - - [Test] - public void LongElementAttributeExtraction() - { - Property property = GenerateAccountIdProperty(); - IGetter getter = PropertyAccessorFactory.GetPropertyAccessor(property, EntityMode.Xml).GetGetter(null, null); - var id = (long) getter.Get(dom); - Assert.That(id, Is.EqualTo(456L)); - } - - [Test] - public void StringElementExtraction() - { - Property property = GenerateNameProperty(); - IGetter getter = PropertyAccessorFactory.GetPropertyAccessor(property, EntityMode.Xml).GetGetter(null, null); - var name = (string) getter.Get(dom); - Assert.That(name, Is.EqualTo("NHForge")); - } - - [Test, Ignore("Not supported yet.")] - public void StringTextExtraction() - { - Property property = GenerateTextProperty(); - IGetter getter = PropertyAccessorFactory.GetPropertyAccessor(property, EntityMode.Xml).GetGetter(null, null); - var name = (string) getter.Get(dom); - Assert.That(name, Is.EqualTo("description...")); - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Basic/AB.hbm.xml b/src/NHibernate.Test/EntityModeTest/Xml/Basic/AB.hbm.xml deleted file mode 100644 index 13e632304b0..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Basic/AB.hbm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Basic/Account.hbm.xml b/src/NHibernate.Test/EntityModeTest/Xml/Basic/Account.hbm.xml deleted file mode 100644 index 6b19e04c3c7..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Basic/Account.hbm.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Basic/Employer.hbm.xml b/src/NHibernate.Test/EntityModeTest/Xml/Basic/Employer.hbm.xml deleted file mode 100644 index a2c12fde8a4..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Basic/Employer.hbm.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs b/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs deleted file mode 100644 index de7795ba2e6..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Basic/XmlFixture.cs +++ /dev/null @@ -1,337 +0,0 @@ -using System; -using System.Collections; -using System.Xml; -using NHibernate.Cfg; -using NHibernate.Criterion; -using NHibernate.Transform; -using NUnit.Framework; -using Environment=NHibernate.Cfg.Environment; - -namespace NHibernate.Test.EntityModeTest.Xml.Basic -{ - [TestFixture, Ignore("Not supported yet.")] - public class XmlFixture : TestCase - { - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - protected override IList Mappings - { - get - { - return new[] - { - "EntityModeTest.Xml.Basic.Account.hbm.xml", "EntityModeTest.Xml.Basic.AB.hbm.xml", - "EntityModeTest.Xml.Basic.Employer.hbm.xml" - }; - } - } - - protected override void Configure(Configuration configuration) - { - cfg.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(EntityMode.Xml)); - } - - public void Xml() - { - string xml = - @" - 123.45 - - - foo - bar - - 45 - An example customer - - Fabio - Maulo - - -"; - var doc1 = new XmlDocument(); - doc1.LoadXml(xml); - XmlElement acct = doc1.DocumentElement; - var cust = (XmlElement) acct.SelectSingleNode("customer"); - - xml = @" -
Karbarook Avenue
-
"; - var doc2 = new XmlDocument(); - doc2.LoadXml(xml); - XmlElement loc = doc2.DocumentElement; - - Print(acct); - - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - s.Persist("Location", loc); - XmlElement eLocation = cust.OwnerDocument.CreateElement("location"); - eLocation.SetAttribute("id", "id"); - cust.AppendChild(eLocation); - s.Persist("Account", acct); - t.Commit(); - s.Close(); - - Print(loc); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.Get("Customer", "xyz123"); - Print(cust); - acct = (XmlElement) s.Get("Account", "abc123"); - Print(acct); - Assert.AreEqual(acct.SelectSingleNode("customer"), cust); - cust.SelectSingleNode("name").SelectSingleNode("first").InnerText = "Gavin A"; - - XmlElement foo3 = cust.OwnerDocument.CreateElement("foo"); - cust.SelectSingleNode("stuff").AppendChild(foo3); - foo3.InnerText = "baz"; - foo3.SetAttribute("bar", "z"); - cust.SelectSingleNode("amount").InnerText = "3"; - XmlElement eamount = cust.OwnerDocument.CreateElement("amount"); - eamount.InnerText = "56"; - cust.AppendChild(eamount); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - acct.SelectSingleNode("balance").InnerText = "3456.12"; - XmlElement eaddress = cust.OwnerDocument.CreateElement("address"); - eaddress.InnerText = "Karbarook Ave"; - cust.AppendChild(eaddress); - - Assert.AreEqual(acct.SelectSingleNode("customer"), cust); - - cust.InnerText = "Still the same example!"; - - s = OpenSession(); - t = s.BeginTransaction(); - s.SaveOrUpdate("Account", acct); - t.Commit(); - s.Close(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.Get("Customer", "xyz123"); - Print(cust); - acct = (XmlElement) s.Get("Account", "abc123"); - Print(acct); - Assert.AreEqual(acct.SelectSingleNode("customer"), cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateCriteria("Customer").Add(Example.Create(cust)).UniqueResult(); - Print(cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - acct = (XmlElement) s.CreateQuery("from Account a left join fetch a.customer").UniqueResult(); - Print(acct); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - var m = - (IDictionary) - s.CreateQuery("select a as acc from Account a left join fetch a.customer").SetResultTransformer( - Transformers.AliasToEntityMap).UniqueResult(); - acct = (XmlElement) m["acc"]; - Print(acct); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - acct = (XmlElement) s.CreateQuery("from Account").UniqueResult(); - Print(acct); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.stuff").UniqueResult(); - Print(cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.morestuff").UniqueResult(); - Print(cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.morestuff").UniqueResult(); - Print(cust); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.stuff").UniqueResult(); - Print(cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.accounts").UniqueResult(); - XmlElement a1 = cust.OwnerDocument.CreateElement("account"); - XmlElement b1 = a1.OwnerDocument.CreateElement("balance"); - b1.InnerText = "12.67"; - a1.AppendChild(b1); - a1.SetAttribute("id", "lkj345"); - a1.SetAttribute("acnum", "0"); - cust.SelectSingleNode("accounts").AppendChild(a1); - - XmlElement a2 = cust.OwnerDocument.CreateElement("account"); - XmlElement b2 = a1.OwnerDocument.CreateElement("balance"); - b2.InnerText = "10000.00"; - a2.AppendChild(b2); - a2.SetAttribute("id", "hsh987"); - a2.SetAttribute("acnum", "1"); - cust.SelectSingleNode("accounts").AppendChild(a2); - - Print(cust); - t.Commit(); - s.Close(); - - Console.WriteLine(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.CreateQuery("from Customer c left join fetch c.accounts").UniqueResult(); - Print(cust); - t.Commit(); - s.Close(); - - // clean up - s = OpenSession(); - t = s.BeginTransaction(); - s.Delete("Account", acct); - s.Delete("Location", loc); - s.Delete("from Account"); - t.Commit(); - s.Close(); - } - - public static void Print(XmlNode elt) - { - Console.WriteLine("============"); - Console.WriteLine(elt.OuterXml); - Console.WriteLine("============"); - } - - [Test] - public void CompositeId() - { - const string xml = - @" - foo bar - - 123.45 - - - foo - bar - - 45 - An example customer - - Fabio - Maulo - - -"; - var doc1 = new XmlDocument(); - doc1.LoadXml(xml); - XmlElement acct = doc1.DocumentElement; - var cust = (XmlElement) acct.SelectSingleNode("customer"); - Print(acct); - - xml = @" -
Karbarook Avenue
-
"; - var doc2 = new XmlDocument(); - doc2.LoadXml(xml); - XmlElement loc = doc2.DocumentElement; - - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - s.Persist("Location", loc); - XmlElement loc1 = cust.OwnerDocument.CreateElement("location"); - loc1.SetAttribute("id", "id"); - cust.AppendChild(loc1); - s.Persist("Account", acct); - t.Commit(); - s.Close(); - - s = OpenSession(); - t = s.BeginTransaction(); - cust = (XmlElement) s.Get("Customer", "xyz123"); - Print(cust); - Assert.AreEqual(2, cust.SelectSingleNode("stuff").SelectNodes("foo").Count, "Incorrect stuff-map size"); - var stuffElement = (XmlElement) cust.SelectSingleNode("stuff").SelectNodes("foo")[0]; - Assert.That(stuffElement.Attributes["bar"], Is.Not.Null, "No map-key value present"); - t.Commit(); - s.Close(); - - s = OpenSession(); - t = s.BeginTransaction(); - s.Delete("Account", acct); - s.Delete("Location", loc); - t.Commit(); - s.Close(); - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.cs b/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.cs deleted file mode 100644 index ce0f13fac16..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NHibernate.Test.EntityModeTest.Xml.Many2One -{ - [Serializable] - public class Car - { - private ISet carParts = new HashSet(); - - public virtual long Id { get; set; } - public virtual string Model { get; set; } - public virtual CarType CarType { get; set; } - - public ISet CarParts - { - get { return carParts; } - set { carParts = value; } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.hbm.xml b/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.hbm.xml deleted file mode 100644 index 08b6dc3ee44..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/Car.hbm.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarPart.cs b/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarPart.cs deleted file mode 100644 index dcc4e495742..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarPart.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace NHibernate.Test.EntityModeTest.Xml.Many2One -{ - [Serializable] - public class CarPart - { - public virtual long Id { get; set; } - public virtual string PartName { get; set; } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarType.cs b/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarType.cs deleted file mode 100644 index 64fd7944468..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/CarType.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace NHibernate.Test.EntityModeTest.Xml.Many2One -{ - [Serializable] - public class CarType - { - public virtual long Id { get; set; } - public virtual string TypeName { get; set; } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/XmlManyToOneFixture.cs b/src/NHibernate.Test/EntityModeTest/Xml/Many2One/XmlManyToOneFixture.cs deleted file mode 100644 index 37efde9adc8..00000000000 --- a/src/NHibernate.Test/EntityModeTest/Xml/Many2One/XmlManyToOneFixture.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System.Collections; -using System.Xml; -using NUnit.Framework; - -namespace NHibernate.Test.EntityModeTest.Xml.Many2One -{ - [TestFixture, Ignore("Not supported yet.")] - public class XmlManyToOneFixture : TestCase - { - protected override string MappingsAssembly - { - get { return "NHibernate.Test"; } - } - - protected override IList Mappings - { - get { return new[] {"EntityModeTest.Xml.Many2One.Car.hbm.xml"}; } - } - - [Test] - public void XmlManyToOne() - { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - - var carType = new CarType {TypeName = "Type 1"}; - s.Save(carType); - - var car1 = new Car {CarType = carType, Model = "Model 1"}; - s.Save(car1); - - var car2 = new Car {CarType = carType, Model = "Model 2"}; - s.Save(car2); - - t.Commit(); - s.Close(); - - s = OpenSession(); - ISession xmlSession = s.GetSession(EntityMode.Xml); - t = s.BeginTransaction(); - - IList list = xmlSession.CreateQuery("from Car c join fetch c.carType order by c.model asc").List(); - - var expectedResults = new[] - { - "Model 1Type 1", - "Model 2Type 1" - }; - - for (int i = 0; i < list.Count; i++) - { - var element = (XmlElement) list[i]; - - //print(element); - Assert.That(element.InnerXml.Equals(expectedResults[i])); - } - - s.Delete("from CarType"); - s.Delete("from Car"); - - t.Commit(); - s.Close(); - } - - [Test] - public void XmlOneToMany() - { - ISession s = OpenSession(); - ITransaction t = s.BeginTransaction(); - - var carType = new CarType {TypeName = "Type 1"}; - s.Save(carType); - - var car = new Car {CarType = carType, Model = "Model 1"}; - s.Save(car); - - var carPart1 = new CarPart {PartName = "chassis"}; - car.CarParts.Add(carPart1); - - t.Commit(); - s.Close(); - - s = OpenSession(); - ISession xmlSession = s.GetSession(EntityMode.Xml); - t = s.BeginTransaction(); - - var element = (XmlElement) xmlSession.CreateQuery("from Car c join fetch c.carParts").UniqueResult(); - - string expectedResult = "" + carPart1.Id - + "Model 1Type 1"; - - //print(element); - Assert.That(element.InnerXml.Equals(expectedResult)); - - s.Delete("from CarPart"); - s.Delete("from CarType"); - s.Delete("from Car"); - - t.Commit(); - s.Close(); - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/ExpressionTest/JunctionFixture.cs b/src/NHibernate.Test/ExpressionTest/JunctionFixture.cs index 1d6d7eeaa62..9ded78b86c6 100644 --- a/src/NHibernate.Test/ExpressionTest/JunctionFixture.cs +++ b/src/NHibernate.Test/ExpressionTest/JunctionFixture.cs @@ -54,8 +54,8 @@ public void GetTypedValues() } TypedValue[] expectedTV = new TypedValue[2]; - expectedTV[0] = new TypedValue(NHibernateUtil.Int32, 5, EntityMode.Poco); - expectedTV[1] = new TypedValue(NHibernateUtil.Int32, 10, EntityMode.Poco); + expectedTV[0] = new TypedValue(NHibernateUtil.Int32, 5); + expectedTV[1] = new TypedValue(NHibernateUtil.Int32, 10); Assert.AreEqual(2, typedValues.Length); diff --git a/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs b/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs index d11360e0d84..60e5370868a 100644 --- a/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs +++ b/src/NHibernate.Test/FilterTest/DynamicFilterTest.cs @@ -32,7 +32,7 @@ public void SecondLevelCachedCollectionsFiltering() .GetCollectionPersister(typeof(Salesperson).FullName + ".Orders"); Assert.IsTrue(persister.HasCache, "No cache for collection"); CacheKey cacheKey = - new CacheKey(testData.steveId, persister.KeyType, persister.Role, EntityMode.Poco, (ISessionFactoryImplementor) sessions); + new CacheKey(testData.steveId, persister.KeyType, persister.Role, (ISessionFactoryImplementor) sessions); CollectionCacheEntry cachedData = (CollectionCacheEntry)persister.Cache.Cache.Get(cacheKey); Assert.IsNotNull(cachedData, "collection was not in cache"); diff --git a/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs b/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs index 1efc88a1127..b4b80b3a979 100644 --- a/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffsetFixture.cs @@ -84,7 +84,7 @@ public void HashCodeShouldHaveSameBehaviorOfNetType() var type = new DateTimeOffsetType(); var now = DateTimeOffset.Now; var exactClone = new DateTimeOffset(now.Ticks, now.Offset); - Assert.That((now.GetHashCode() == exactClone.GetHashCode()), Is.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone, EntityMode.Poco))); + Assert.That((now.GetHashCode() == exactClone.GetHashCode()), Is.EqualTo(now.GetHashCode() == type.GetHashCode(exactClone))); } [Test] diff --git a/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs deleted file mode 100644 index 16eefcb6477..00000000000 --- a/src/NHibernate.Test/NHSpecificTest/EntityModeToTuplizerPerf/Fixture.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.Diagnostics; -using NHibernate.Tuple; -using NUnit.Framework; - -namespace NHibernate.Test.NHSpecificTest.EntityModeToTuplizerPerf -{ - [TestFixture] - public class Fixture - { - private TargetClazz target; - - [SetUp] - public void Setup() - { - target = new TargetClazz(); - } - - [Test] - public void VerifyEntityModeNotFound() - { - Assert.IsNull(target.GetTuplizerOrNull(EntityMode.Xml)); - } - - [Test] - public void VerifyEntityModeFound() - { - ITuplizer tuplizer = new TuplizerStub(); - target.Add(EntityMode.Map, tuplizer); - Assert.AreSame(tuplizer, target.GetTuplizerOrNull(EntityMode.Map)); - } - - [Test, Explicit("To the commiter - run before and after")] - public void RemoveThisTest_JustToShowPerfDifference() - { - const int loop = 1000000; - target.Add(EntityMode.Map, new TuplizerStub()); - target.Add(EntityMode.Poco, new TuplizerStub()); - target.Add(EntityMode.Xml, new TuplizerStub()); - - var watch = new Stopwatch(); - watch.Start(); - for (int i = 0; i < loop; i++) - { - target.GetTuplizerOrNull(EntityMode.Map); - target.GetTuplizerOrNull(EntityMode.Poco); - } - watch.Stop(); - Console.WriteLine(watch.ElapsedMilliseconds); - } - - private class TargetClazz : EntityModeToTuplizerMapping - { - public void Add(EntityMode eMode, ITuplizer tuplizer) - { - AddTuplizer(eMode, tuplizer); - } - } - - private class TuplizerStub : ITuplizer - { - public System.Type MappedClass - { - get { throw new NotImplementedException(); } - } - - public object[] GetPropertyValues(object entity) - { - throw new NotImplementedException(); - } - - public void SetPropertyValues(object entity, object[] values) - { - throw new NotImplementedException(); - } - - public object GetPropertyValue(object entity, int i) - { - throw new NotImplementedException(); - } - - public object Instantiate() - { - throw new NotImplementedException(); - } - - public bool IsInstance(object obj) - { - throw new NotImplementedException(); - } - } - } -} \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/NH1677/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1677/Fixture.cs index b337efeb1b6..46cc874ea48 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1677/Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1677/Fixture.cs @@ -15,12 +15,6 @@ public class EntityModeMapCriteria : BugTestCase private const string Entity2Property = "Entity2Property"; private const string EntityPropertyPrefix = "Record"; - protected override void Configure(Configuration configuration) - { - base.Configure(configuration); - configuration.SetProperty("default_entity_mode", EntityModeHelper.ToString(EntityMode.Map)); - } - protected override void OnSetUp() { using (ISession s = OpenSession()) diff --git a/src/NHibernate.Test/NHSpecificTest/NH1714/SimpleReproductionFixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1714/SimpleReproductionFixture.cs index 33fef736675..eb4f1298c93 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1714/SimpleReproductionFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1714/SimpleReproductionFixture.cs @@ -22,7 +22,7 @@ public void DbCommandsFromEventListenerShouldBeEnlistedInRunningTransaction() var entity = new DomainClass(); session.Save(entity); - using (var otherSession = session.GetSession(EntityMode.Poco)) + using (var otherSession = session.GetChildSession()) { otherSession.Save(new DomainClass()); otherSession.Flush(); diff --git a/src/NHibernate.Test/NHSpecificTest/NH1714/UseCaseDemonstrationFixture.cs b/src/NHibernate.Test/NHSpecificTest/NH1714/UseCaseDemonstrationFixture.cs index f25cef1a53d..cad60907646 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH1714/UseCaseDemonstrationFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH1714/UseCaseDemonstrationFixture.cs @@ -60,7 +60,7 @@ public bool OnPreInsert(PreInsertEvent e) return false; // this will join into the parent's transaction - using (var session = e.Session.GetSession(EntityMode.Poco)) + using (var session = e.Session.GetChildSession()) { //should insert log record here session.Save(new LogClass()); diff --git a/src/NHibernate.Test/NHSpecificTest/NH2374/NH2374Fixture.cs b/src/NHibernate.Test/NHSpecificTest/NH2374/NH2374Fixture.cs index 4d012150def..0df9cb2e5ca 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2374/NH2374Fixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2374/NH2374Fixture.cs @@ -13,7 +13,7 @@ public void OneToOne_with_EntityMode_Map() using (ISession sroot = OpenSession()) { - using (ISession s = sroot.GetSession(EntityMode.Map)) + using (ISession s = sroot.GetChildSession()) { using (ITransaction t = s.BeginTransaction()) { diff --git a/src/NHibernate.Test/NHibernate.Test.csproj b/src/NHibernate.Test/NHibernate.Test.csproj index da460c658d8..392cc02a2dc 100644 --- a/src/NHibernate.Test/NHibernate.Test.csproj +++ b/src/NHibernate.Test/NHibernate.Test.csproj @@ -308,15 +308,6 @@ - - - - - - - - - @@ -1877,7 +1868,6 @@ - @@ -3768,12 +3758,6 @@ - - - - - - diff --git a/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs b/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs index 350e1f1125f..250ace18a62 100644 --- a/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/DateTime2TypeFixture.cs @@ -33,7 +33,7 @@ public void DeepCopyNotNull() NullableType type = NHibernateUtil.DateTime; object value1 = DateTime.Now; - object value2 = type.DeepCopy(value1, EntityMode.Poco, null); + object value2 = type.DeepCopy(value1, null); Assert.AreEqual(value1, value2, "Copies should be the same."); @@ -49,7 +49,7 @@ public void EqualityShouldIgnoreKindAndNotIgnoreMillisecond() var localTime = DateTime.Now; var unspecifiedKid = new DateTime(localTime.Ticks, DateTimeKind.Unspecified); Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); - Assert.That(type.IsEqual(localTime, unspecifiedKid, EntityMode.Poco), Is.True); + Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs b/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs index 3b190e78ebd..bb8f3de44bc 100644 --- a/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs @@ -35,7 +35,7 @@ public void DeepCopyNotNull() NullableType type = NHibernateUtil.DateTime; object value1 = DateTime.Now; - object value2 = type.DeepCopy(value1, EntityMode.Poco, null); + object value2 = type.DeepCopy(value1, null); Assert.AreEqual(value1, value2, "Copies should be the same."); @@ -51,7 +51,7 @@ public void EqualityShouldIgnoreKindAndMillisecond() var localTime = DateTime.Now; var unspecifiedKid = new DateTime(localTime.Year, localTime.Month, localTime.Day, localTime.Hour, localTime.Minute, localTime.Second, 0, DateTimeKind.Unspecified); Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); - Assert.That(type.IsEqual(localTime, unspecifiedKid, EntityMode.Poco), Is.True); + Assert.That(type.IsEqual(localTime, unspecifiedKid), Is.True); } } } \ No newline at end of file diff --git a/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs b/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs index 144ad853742..1705f82e8c2 100644 --- a/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/EntityTypeFixture.cs @@ -24,16 +24,16 @@ public void Compare() EntityClass ca = new ComparableEntityClass(1); EntityClass cb = new ComparableEntityClass(2); - Assert.AreEqual(-1, type.Compare(a, cb, EntityMode.Poco)); - Assert.AreEqual(-1, type.Compare(ca, b, EntityMode.Poco)); - Assert.AreEqual(-1, type.Compare(ca, cb, EntityMode.Poco)); + Assert.AreEqual(-1, type.Compare(a, cb)); + Assert.AreEqual(-1, type.Compare(ca, b)); + Assert.AreEqual(-1, type.Compare(ca, cb)); - Assert.AreEqual(1, type.Compare(b, ca, EntityMode.Poco)); - Assert.AreEqual(1, type.Compare(cb, a, EntityMode.Poco)); - Assert.AreEqual(1, type.Compare(cb, ca, EntityMode.Poco)); + Assert.AreEqual(1, type.Compare(b, ca)); + Assert.AreEqual(1, type.Compare(cb, a)); + Assert.AreEqual(1, type.Compare(cb, ca)); - Assert.AreEqual(0, type.Compare(ca, a, EntityMode.Poco)); - Assert.AreEqual(0, type.Compare(a, ca, EntityMode.Poco)); + Assert.AreEqual(0, type.Compare(ca, a)); + Assert.AreEqual(0, type.Compare(a, ca)); } [Test] @@ -45,9 +45,9 @@ public void Equals() EntityClass b = new EntityClass(2); EntityClass c = new EntityClass(1); - Assert.IsTrue(type.IsEqual(a, a, EntityMode.Poco, (ISessionFactoryImplementor) sessions)); - Assert.IsFalse(type.IsEqual(a, b, EntityMode.Poco, (ISessionFactoryImplementor) sessions)); - Assert.IsTrue(type.IsEqual(a, c, EntityMode.Poco, (ISessionFactoryImplementor) sessions)); + Assert.IsTrue(type.IsEqual(a, a, (ISessionFactoryImplementor) sessions)); + Assert.IsFalse(type.IsEqual(a, b, (ISessionFactoryImplementor) sessions)); + Assert.IsTrue(type.IsEqual(a, c, (ISessionFactoryImplementor) sessions)); } } } diff --git a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs index 6d0b9bbe342..b068f6dfebd 100644 --- a/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs +++ b/src/NHibernate.Test/TypesTest/PersistentEnumTypeFixture.cs @@ -46,7 +46,7 @@ public void EqualsTrue() A lhs = A.One; A rhs = A.One; - Assert.IsTrue(type.IsEqual(lhs, rhs, EntityMode.Poco)); + Assert.IsTrue(type.IsEqual(lhs, rhs)); } /// @@ -61,7 +61,7 @@ public void EqualsFalseSameUnderlyingValue() A lhs = A.One; B rhs = B.One; - Assert.IsFalse(type.IsEqual(lhs, rhs, EntityMode.Poco)); + Assert.IsFalse(type.IsEqual(lhs, rhs)); } [Test] @@ -72,7 +72,7 @@ public void EqualsFalse() A lhs = A.One; A rhs = A.Two; - Assert.IsFalse(type.IsEqual(lhs, rhs, EntityMode.Poco)); + Assert.IsFalse(type.IsEqual(lhs, rhs)); } [Test] diff --git a/src/NHibernate.Test/UserCollection/Parameterized/DefaultableListType.cs b/src/NHibernate.Test/UserCollection/Parameterized/DefaultableListType.cs index b6c8db07277..09802a39db1 100644 --- a/src/NHibernate.Test/UserCollection/Parameterized/DefaultableListType.cs +++ b/src/NHibernate.Test/UserCollection/Parameterized/DefaultableListType.cs @@ -21,14 +21,7 @@ public IPersistentCollection Instantiate(ISessionImplementor session, ICollectio public IPersistentCollection Wrap(ISessionImplementor session, object collection) { - if (session.EntityMode == EntityMode.Xml) - { - throw new NotSupportedException("XML not supported"); - } - else - { - return new PersistentDefaultableList(session, (IList)collection); - } + return new PersistentDefaultableList(session, (IList) collection); } public IEnumerable GetElements(object collection) diff --git a/src/NHibernate/Action/CollectionAction.cs b/src/NHibernate/Action/CollectionAction.cs index cfdedcb23e0..f30dffc0c79 100644 --- a/src/NHibernate/Action/CollectionAction.cs +++ b/src/NHibernate/Action/CollectionAction.cs @@ -122,7 +122,7 @@ public virtual AfterTransactionCompletionProcessDelegate AfterTransactionComplet { return new AfterTransactionCompletionProcessDelegate((success) => { - CacheKey ck = new CacheKey(key, persister.KeyType, persister.Role, Session.EntityMode, Session.Factory); + CacheKey ck = new CacheKey(key, persister.KeyType, persister.Role, Session.Factory); persister.Cache.Release(ck, softLock); }); } @@ -164,7 +164,7 @@ public virtual int CompareTo(CollectionAction other) return roleComparison; } //then by fk - return persister.KeyType.Compare(key, other.key, session.EntityMode); + return persister.KeyType.Compare(key, other.key); } #endregion diff --git a/src/NHibernate/Action/EntityAction.cs b/src/NHibernate/Action/EntityAction.cs index 7ec15006c81..bc597ba95c6 100644 --- a/src/NHibernate/Action/EntityAction.cs +++ b/src/NHibernate/Action/EntityAction.cs @@ -155,7 +155,7 @@ public virtual int CompareTo(EntityAction other) return roleComparison; } //then by id - return persister.IdentifierType.Compare(id, other.id, session.EntityMode); + return persister.IdentifierType.Compare(id, other.id); } #endregion diff --git a/src/NHibernate/Action/EntityDeleteAction.cs b/src/NHibernate/Action/EntityDeleteAction.cs index 11200044bd1..deff5cb4287 100644 --- a/src/NHibernate/Action/EntityDeleteAction.cs +++ b/src/NHibernate/Action/EntityDeleteAction.cs @@ -51,7 +51,7 @@ public override void Execute() // we need to grab the version value from the entity, otherwise // we have issues with generated-version entities that may have // multiple actions queued during the same flush - tmpVersion = persister.GetVersion(instance, session.EntityMode); + tmpVersion = persister.GetVersion(instance); } CacheKey ck; diff --git a/src/NHibernate/Action/EntityIdentityInsertAction.cs b/src/NHibernate/Action/EntityIdentityInsertAction.cs index 7f4a29f6f49..150ea2f9f0a 100644 --- a/src/NHibernate/Action/EntityIdentityInsertAction.cs +++ b/src/NHibernate/Action/EntityIdentityInsertAction.cs @@ -79,7 +79,7 @@ public override void Execute() } //need to do that here rather than in the save event listener to let //the post insert events to have a id-filled entity when IDENTITY is used (EJB3) - persister.SetIdentifier(instance, generatedId, Session.EntityMode); + persister.SetIdentifier(instance, generatedId); } //TODO from H3.2 : this bit actually has to be called after all cascades! diff --git a/src/NHibernate/Action/EntityInsertAction.cs b/src/NHibernate/Action/EntityInsertAction.cs index f1a3f0d616f..dddb0f3cd9d 100644 --- a/src/NHibernate/Action/EntityInsertAction.cs +++ b/src/NHibernate/Action/EntityInsertAction.cs @@ -81,7 +81,7 @@ public override void Execute() if (IsCachePutEnabled(persister)) { - CacheEntry ce = new CacheEntry(state, persister, persister.HasUninitializedLazyProperties(instance, session.EntityMode), version, session, instance); + CacheEntry ce = new CacheEntry(state, persister, persister.HasUninitializedLazyProperties(instance), version, session, instance); cacheEntry = persister.CacheEntryStructure.Structure(ce); CacheKey ck = Session.GenerateCacheKey(id, persister.IdentifierType, persister.RootEntityName); diff --git a/src/NHibernate/Action/EntityUpdateAction.cs b/src/NHibernate/Action/EntityUpdateAction.cs index daaebf72817..39888fa26d6 100644 --- a/src/NHibernate/Action/EntityUpdateAction.cs +++ b/src/NHibernate/Action/EntityUpdateAction.cs @@ -64,7 +64,7 @@ public override void Execute() // we need to grab the version value from the entity, otherwise // we have issues with generated-version entities that may have // multiple actions queued during the same flush - previousVersion = persister.GetVersion(instance, session.EntityMode); + previousVersion = persister.GetVersion(instance); } CacheKey ck = null; @@ -114,7 +114,7 @@ public override void Execute() } else { - CacheEntry ce = new CacheEntry(state, persister, persister.HasUninitializedLazyProperties(instance, session.EntityMode), nextVersion, Session, instance); + CacheEntry ce = new CacheEntry(state, persister, persister.HasUninitializedLazyProperties(instance), nextVersion, Session, instance); cacheEntry = persister.CacheEntryStructure.Structure(ce); bool put = persister.Cache.Update(ck, cacheEntry, nextVersion, previousVersion); diff --git a/src/NHibernate/Cache/CacheKey.cs b/src/NHibernate/Cache/CacheKey.cs index 59f7ff7f015..87bc96402e5 100644 --- a/src/NHibernate/Cache/CacheKey.cs +++ b/src/NHibernate/Cache/CacheKey.cs @@ -16,7 +16,6 @@ public class CacheKey private readonly IType type; private readonly string entityOrRoleName; private readonly int hashCode; - private readonly EntityMode entityMode; /// /// Construct a new key for a collection or entity instance. @@ -26,15 +25,13 @@ public class CacheKey /// The identifier associated with the cached data /// The Hibernate type mapping /// The entity or collection-role name. - /// The entity mode of the originating session /// The session factory for which we are caching - public CacheKey(object id, IType type, string entityOrRoleName, EntityMode entityMode, ISessionFactoryImplementor factory) + public CacheKey(object id, IType type, string entityOrRoleName, ISessionFactoryImplementor factory) { key = id; this.type = type; this.entityOrRoleName = entityOrRoleName; - this.entityMode = entityMode; - hashCode = type.GetHashCode(key, entityMode, factory); + hashCode = type.GetHashCode(key, factory); } //Mainly for SysCache and Memcache @@ -48,7 +45,7 @@ public override bool Equals(object obj) { CacheKey that = obj as CacheKey; if (that == null) return false; - return entityOrRoleName.Equals(that.entityOrRoleName) && type.IsEqual(key, that.key, entityMode); + return entityOrRoleName.Equals(that.entityOrRoleName) && type.IsEqual(key, that.key); } public override int GetHashCode() diff --git a/src/NHibernate/Cache/Entry/CacheEntry.cs b/src/NHibernate/Cache/Entry/CacheEntry.cs index e412be5d484..6e78f59cd61 100644 --- a/src/NHibernate/Cache/Entry/CacheEntry.cs +++ b/src/NHibernate/Cache/Entry/CacheEntry.cs @@ -91,7 +91,7 @@ private static object[] Assemble(object[] values, object result, object id, IEnt listeners[i].OnPreLoad(preLoadEvent); } - persister.SetPropertyValues(result, assembledProps, session.EntityMode); + persister.SetPropertyValues(result, assembledProps); return assembledProps; } diff --git a/src/NHibernate/Cache/FilterKey.cs b/src/NHibernate/Cache/FilterKey.cs index a56f9bf9df9..938be457deb 100644 --- a/src/NHibernate/Cache/FilterKey.cs +++ b/src/NHibernate/Cache/FilterKey.cs @@ -13,13 +13,13 @@ public class FilterKey private readonly string _filterName; private readonly Dictionary _filterParameters = new Dictionary(); - public FilterKey(string name, IEnumerable> @params, IDictionary types, EntityMode entityMode) + public FilterKey(string name, IEnumerable> @params, IDictionary types) { _filterName = name; foreach (KeyValuePair me in @params) { IType type = types[me.Key]; - _filterParameters[me.Key] = new TypedValue(type, me.Value, entityMode); + _filterParameters[me.Key] = new TypedValue(type, me.Value); } } @@ -50,7 +50,7 @@ public override string ToString() return string.Format("FilterKey[{0}{1}]", _filterName, CollectionPrinter.ToString(_filterParameters)); } - public static ISet CreateFilterKeys(IDictionary enabledFilters, EntityMode entityMode) + public static ISet CreateFilterKeys(IDictionary enabledFilters) { if (enabledFilters.Count == 0) return null; @@ -58,7 +58,7 @@ public static ISet CreateFilterKeys(IDictionary enab var result = new HashSet(); foreach (FilterImpl filter in enabledFilters.Values) { - FilterKey key = new FilterKey(filter.Name, filter.Parameters, filter.FilterDefinition.ParameterTypes, entityMode); + FilterKey key = new FilterKey(filter.Name, filter.Parameters, filter.FilterDefinition.ParameterTypes); result.Add(key); } return result; diff --git a/src/NHibernate/Cfg/Environment.cs b/src/NHibernate/Cfg/Environment.cs index 9893ebab2d1..268bca8a09a 100644 --- a/src/NHibernate/Cfg/Environment.cs +++ b/src/NHibernate/Cfg/Environment.cs @@ -87,7 +87,7 @@ public static string Version /// A default database catalog name to use for unqualified tablenames public const string DefaultCatalog = "default_catalog"; - /// The EntityMode in which set the Session opened from the SessionFactory. + [Obsolete("DefaultEntityMode is deprecated.")] public const string DefaultEntityMode = "default_entity_mode"; /// Implementation of NH-3619 - Make default value of FlushMode configurable diff --git a/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs b/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs index d53ad96226c..e9ecf07d823 100644 --- a/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs +++ b/src/NHibernate/Cfg/Loquacious/FluentSessionFactoryConfiguration.cs @@ -41,12 +41,6 @@ public IFluentSessionFactoryConfiguration GenerateStatistics() return this; } - public IFluentSessionFactoryConfiguration Using(EntityMode entityMode) - { - configuration.SetProperty(Environment.DefaultEntityMode, EntityModeHelper.ToString(entityMode)); - return this; - } - public IFluentSessionFactoryConfiguration DefaultFlushMode(FlushMode flushMode) { configuration.SetProperty(Environment.DefaultFlushMode, flushMode.ToString()); diff --git a/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs b/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs index c16897b84a5..08f682e1b2c 100644 --- a/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs +++ b/src/NHibernate/Cfg/Loquacious/IFluentSessionFactoryConfiguration.cs @@ -25,7 +25,6 @@ public interface IFluentSessionFactoryConfiguration ICacheConfiguration Caching { get; } IFluentSessionFactoryConfiguration GenerateStatistics(); - IFluentSessionFactoryConfiguration Using(EntityMode entityMode); IFluentSessionFactoryConfiguration DefaultFlushMode(FlushMode flushMode); IFluentSessionFactoryConfiguration ParsingHqlThrough() where TQueryTranslator : IQueryTranslatorFactory; diff --git a/src/NHibernate/Cfg/MappingSchema/MappingExtensions.cs b/src/NHibernate/Cfg/MappingSchema/MappingExtensions.cs index 73efcc81d48..0c9eb4419f1 100644 --- a/src/NHibernate/Cfg/MappingSchema/MappingExtensions.cs +++ b/src/NHibernate/Cfg/MappingSchema/MappingExtensions.cs @@ -10,8 +10,6 @@ public static EntityMode ToEntityMode(this HbmTuplizerEntitymode source) { case HbmTuplizerEntitymode.Poco: return EntityMode.Poco; - case HbmTuplizerEntitymode.Xml: - return EntityMode.Xml; case HbmTuplizerEntitymode.DynamicMap: return EntityMode.Map; default: diff --git a/src/NHibernate/Cfg/Settings.cs b/src/NHibernate/Cfg/Settings.cs index f2057651d34..661aee632be 100644 --- a/src/NHibernate/Cfg/Settings.cs +++ b/src/NHibernate/Cfg/Settings.cs @@ -112,8 +112,6 @@ public Settings() public FlushMode DefaultFlushMode { get; internal set; } - public EntityMode DefaultEntityMode { get; internal set; } - public bool IsDataDefinitionImplicitCommit { get; internal set; } public bool IsDataDefinitionInTransactionSupported { get; internal set; } diff --git a/src/NHibernate/Cfg/SettingsFactory.cs b/src/NHibernate/Cfg/SettingsFactory.cs index 502a0dc4e4d..2660e33fb55 100644 --- a/src/NHibernate/Cfg/SettingsFactory.cs +++ b/src/NHibernate/Cfg/SettingsFactory.cs @@ -268,10 +268,11 @@ public Settings BuildSettings(IDictionary properties) log.Info("Default flush mode: " + defaultFlushMode); settings.DefaultFlushMode = defaultFlushMode; - EntityMode defaultEntityMode = - EntityModeHelper.Parse(PropertiesHelper.GetString(Environment.DefaultEntityMode, properties, "poco")); - log.Info("Default entity-mode: " + defaultEntityMode); - settings.DefaultEntityMode = defaultEntityMode; +#pragma warning disable CS0618 // Type or member is obsolete + var defaultEntityMode = PropertiesHelper.GetString(Environment.DefaultEntityMode, properties, null); + if (!string.IsNullOrEmpty(defaultEntityMode)) + log.Warn("Default entity-mode setting is deprecated."); +#pragma warning restore CS0618 // Type or member is obsolete bool namedQueryChecking = PropertiesHelper.GetBoolean(Environment.QueryStartupChecking, properties, true); log.Info("Named query checking : " + EnabledDisabled(namedQueryChecking)); diff --git a/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs index 8e3237858b6..de8fa8d2716 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs @@ -131,13 +131,6 @@ private void BindMapRepresentation(IEntityMapping classMapping, PersistentClass private void BindXmlRepresentation(IEntityMapping classMapping, PersistentClass entity) { entity.NodeName = string.IsNullOrEmpty(classMapping.Node) ? StringHelper.Unqualify(entity.EntityName): classMapping.Node; - - HbmTuplizer tuplizer = classMapping.Tuplizers.FirstOrDefault(tp => tp.entitymode == HbmTuplizerEntitymode.Xml); - if (tuplizer != null) - { - string tupClassName = FullQualifiedClassName(tuplizer.@class, mappings); - entity.AddTuplizer(EntityMode.Xml, tupClassName); - } } private void BindPocoRepresentation(IEntityMapping classMapping, PersistentClass entity) diff --git a/src/NHibernate/Collection/AbstractPersistentCollection.cs b/src/NHibernate/Collection/AbstractPersistentCollection.cs index 241a240c06b..a1804ed76c0 100644 --- a/src/NHibernate/Collection/AbstractPersistentCollection.cs +++ b/src/NHibernate/Collection/AbstractPersistentCollection.cs @@ -717,7 +717,7 @@ protected virtual ICollection GetOrphans(ICollection oldElements, ICollection cu if (current != null && ForeignKeys.IsNotTransient(entityName, current, null, session)) { object currentId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, current, session); - currentIds.Add(new TypedValue(idType, currentId, session.EntityMode)); + currentIds.Add(new TypedValue(idType, currentId)); } } @@ -725,7 +725,7 @@ protected virtual ICollection GetOrphans(ICollection oldElements, ICollection cu foreach (object old in oldElements) { object oldId = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, old, session); - if (!currentIds.Contains(new TypedValue(idType, oldId, session.EntityMode))) + if (!currentIds.Contains(new TypedValue(idType, oldId))) { res.Add(old); } @@ -749,7 +749,7 @@ public void IdentityRemove(IList list, object obj, string entityName, ISessionIm continue; } object idOfOld = ForeignKeys.GetEntityIdentifierIfNotUnsaved(entityName, current, session); - if (idType.IsEqual(idOfCurrent, idOfOld, session.EntityMode, session.Factory)) + if (idType.IsEqual(idOfCurrent, idOfOld, session.Factory)) { toRemove.Add(current); } diff --git a/src/NHibernate/Collection/Generic/PersistentGenericBag.cs b/src/NHibernate/Collection/Generic/PersistentGenericBag.cs index 2c5ff104a72..a76a4561fb0 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericBag.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericBag.cs @@ -330,7 +330,6 @@ public override bool EntryExists(object entry, int i) public override bool EqualsSnapshot(ICollectionPersister persister) { var elementType = persister.ElementType; - var entityMode = Session.EntityMode; var sn = (IList) GetSnapshot(); if (sn.Count != _gbag.Count) @@ -340,7 +339,7 @@ public override bool EqualsSnapshot(ICollectionPersister persister) foreach (var elt in _gbag) { - if (CountOccurrences(elt, _gbag, elementType, entityMode) != CountOccurrences(elt, sn, elementType, entityMode)) + if (CountOccurrences(elt, _gbag, elementType) != CountOccurrences(elt, sn, elementType)) { return false; } @@ -352,14 +351,13 @@ public override bool EqualsSnapshot(ICollectionPersister persister) public override IEnumerable GetDeletes(ICollectionPersister persister, bool indexIsFormula) { var elementType = persister.ElementType; - var entityMode = Session.EntityMode; var deletes = new List(); var sn = (IList) GetSnapshot(); var i = 0; foreach (var old in sn) { var found = false; - if (_gbag.Count > i && elementType.IsSame(old, _gbag[i++], entityMode)) + if (_gbag.Count > i && elementType.IsSame(old, _gbag[i++])) { //a shortcut if its location didn't change! found = true; @@ -368,7 +366,7 @@ public override IEnumerable GetDeletes(ICollectionPersister persister, bool inde { foreach (object newObject in _gbag) { - if (elementType.IsSame(old, newObject, entityMode)) + if (elementType.IsSame(old, newObject)) { found = true; break; @@ -401,11 +399,10 @@ public override ICollection GetOrphans(object snapshot, string entityName) public override object GetSnapshot(ICollectionPersister persister) { - var entityMode = Session.EntityMode; var clonedList = new List(_gbag.Count); foreach (object current in _gbag) { - clonedList.Add(persister.ElementType.DeepCopy(current, entityMode, persister.Factory)); + clonedList.Add(persister.ElementType.DeepCopy(current, persister.Factory)); } return clonedList; } @@ -450,9 +447,8 @@ public override bool IsWrapper(object collection) public override bool NeedsInserting(object entry, int i, IType elemType) { var sn = (IList) GetSnapshot(); - var entityMode = Session.EntityMode; - if (sn.Count > i && elemType.IsSame(sn[i], entry, entityMode)) + if (sn.Count > i && elemType.IsSame(sn[i], entry)) { // a shortcut if its location didn't change return false; @@ -460,7 +456,7 @@ public override bool NeedsInserting(object entry, int i, IType elemType) //search for it foreach (var old in sn) { - if (elemType.IsEqual(old, entry, entityMode)) + if (elemType.IsEqual(old, entry)) { return false; } @@ -515,16 +511,15 @@ public override string ToString() /// The element to find in the list. /// The to search. /// The that can determine equality. - /// The entity mode. /// /// The number of occurrences of the element in the list. /// - private static int CountOccurrences(object element, IEnumerable list, IType elementType, EntityMode entityMode) + private static int CountOccurrences(object element, IEnumerable list, IType elementType) { var result = 0; foreach (var obj in list) { - if (elementType.IsSame(element, obj, entityMode)) + if (elementType.IsSame(element, obj)) { result++; } diff --git a/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs b/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs index 21147b24f56..d59bd17c60d 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericIdentifierBag.cs @@ -228,15 +228,13 @@ public override object ReadFrom(DbDataReader reader, ICollectionPersister persis public override object GetSnapshot(ICollectionPersister persister) { - EntityMode entityMode = Session.EntityMode; - var map = new HashSet(); int i = 0; foreach (object value in _values) { object id; _identifiers.TryGetValue(i++, out id); - var valueCopy = persister.ElementType.DeepCopy(value, entityMode, persister.Factory); + var valueCopy = persister.ElementType.DeepCopy(value, persister.Factory); map.Add(new SnapshotElement { Id = id, Value = valueCopy }); } return map; diff --git a/src/NHibernate/Collection/Generic/PersistentGenericList.cs b/src/NHibernate/Collection/Generic/PersistentGenericList.cs index 089c912d26b..be462c8a88f 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericList.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericList.cs @@ -53,12 +53,10 @@ public PersistentGenericList(ISessionImplementor session, IList list) : base( public override object GetSnapshot(ICollectionPersister persister) { - EntityMode entityMode = Session.EntityMode; - var clonedList = new List(WrappedList.Count); foreach (T current in WrappedList) { - var deepCopy = (T)persister.ElementType.DeepCopy(current, entityMode, persister.Factory); + var deepCopy = (T)persister.ElementType.DeepCopy(current, persister.Factory); clonedList.Add(deepCopy); } diff --git a/src/NHibernate/Collection/Generic/PersistentGenericMap.cs b/src/NHibernate/Collection/Generic/PersistentGenericMap.cs index ad175aaff79..0573a4b9ed8 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericMap.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericMap.cs @@ -47,11 +47,10 @@ public PersistentGenericMap(ISessionImplementor session, IDictionary clonedMap = new Dictionary(WrappedMap.Count); foreach (KeyValuePair e in WrappedMap) { - object copy = persister.ElementType.DeepCopy(e.Value, entityMode, persister.Factory); + object copy = persister.ElementType.DeepCopy(e.Value, persister.Factory); clonedMap[e.Key] = (TValue)copy; } return clonedMap; diff --git a/src/NHibernate/Collection/Generic/PersistentGenericSet.cs b/src/NHibernate/Collection/Generic/PersistentGenericSet.cs index b334ad1a8a7..402f32b0e54 100644 --- a/src/NHibernate/Collection/Generic/PersistentGenericSet.cs +++ b/src/NHibernate/Collection/Generic/PersistentGenericSet.cs @@ -79,10 +79,9 @@ public override bool RowUpdatePossible public override object GetSnapshot(ICollectionPersister persister) { - var entityMode = Session.EntityMode; var clonedSet = new SetSnapShot(WrappedSet.Count); var enumerable = from object current in WrappedSet - select persister.ElementType.DeepCopy(current, entityMode, persister.Factory); + select persister.ElementType.DeepCopy(current, persister.Factory); foreach (var copied in enumerable) { clonedSet.Add((T)copied); diff --git a/src/NHibernate/Collection/PersistentArrayHolder.cs b/src/NHibernate/Collection/PersistentArrayHolder.cs index c274ce7f419..31544513fe9 100644 --- a/src/NHibernate/Collection/PersistentArrayHolder.cs +++ b/src/NHibernate/Collection/PersistentArrayHolder.cs @@ -69,8 +69,6 @@ public override object GetValue() public override object GetSnapshot(ICollectionPersister persister) { - EntityMode entityMode = Session.EntityMode; - int length = array.Length; Array result = System.Array.CreateInstance(persister.ElementClass, length); for (int i = 0; i < length; i++) @@ -78,7 +76,7 @@ public override object GetSnapshot(ICollectionPersister persister) object elt = array.GetValue(i); try { - result.SetValue(persister.ElementType.DeepCopy(elt, entityMode, persister.Factory), i); + result.SetValue(persister.ElementType.DeepCopy(elt, persister.Factory), i); } catch (Exception e) { diff --git a/src/NHibernate/Criterion/ConstantProjection.cs b/src/NHibernate/Criterion/ConstantProjection.cs index b2d6b841e7e..481cd6b6820 100644 --- a/src/NHibernate/Criterion/ConstantProjection.cs +++ b/src/NHibernate/Criterion/ConstantProjection.cs @@ -23,7 +23,7 @@ public ConstantProjection(object value) : this(value, NHibernateUtil.GuessType(v public ConstantProjection(object value, IType type) { this.value = value; - typedValue = new TypedValue(type, this.value, EntityMode.Poco); + typedValue = new TypedValue(type, this.value); } public override bool IsAggregate diff --git a/src/NHibernate/Criterion/CriterionUtil.cs b/src/NHibernate/Criterion/CriterionUtil.cs index 3ec77b24cca..b03b42d8245 100644 --- a/src/NHibernate/Criterion/CriterionUtil.cs +++ b/src/NHibernate/Criterion/CriterionUtil.cs @@ -115,7 +115,7 @@ public static TypedValue[] GetTypedValues(ICriteriaQuery criteriaQuery, ICriteri { foreach (object value in values) { - types.Add(new TypedValue(NHibernateUtil.GuessType((object)value), value, EntityMode.Poco)); + types.Add(new TypedValue(NHibernateUtil.GuessType((object)value), value)); } } return types.ToArray(); diff --git a/src/NHibernate/Criterion/Example.cs b/src/NHibernate/Criterion/Example.cs index 1db82db965b..af0dc6362f8 100644 --- a/src/NHibernate/Criterion/Example.cs +++ b/src/NHibernate/Criterion/Example.cs @@ -274,9 +274,9 @@ private bool IsPropertyIncluded(object value, String name, IType type) private object[] GetPropertyValues(IEntityPersister persister, ICriteria criteria, ICriteriaQuery criteriaQuery) { System.Type type = _entity.GetType(); - if(type == persister.GetMappedClass(GetEntityMode(criteria, criteriaQuery))) //not using anon object + if(type == persister.MappedClass) //not using anon object { - return persister.GetPropertyValues(_entity, GetEntityMode(criteria, criteriaQuery)); + return persister.GetPropertyValues(_entity); } var list = new List(); for(int i = 0; i < persister.PropertyNames.Length; i++) @@ -386,18 +386,6 @@ public override IProjection[] GetProjections() return null; } - private EntityMode GetEntityMode(ICriteria criteria, ICriteriaQuery criteriaQuery) - { - IEntityPersister meta = criteriaQuery.Factory.GetEntityPersister(criteriaQuery.GetEntityName(criteria)); - EntityMode? result = meta.GuessEntityMode(_entity); - if (!result.HasValue) - { - return EntityMode.Poco; //this occurs for anon objects - //throw new InvalidCastException(_entity.GetType().FullName); - } - return result.Value; - } - /// /// Adds a based on the value /// and type parameters to the in the @@ -429,8 +417,7 @@ protected void AddPropertyTypedValue(object value, IType type, IList list) } value = stringValue; } - list.Add(new TypedValue(type, value, EntityMode.Poco)); - // TODO NH Different behavior: In H3.2 EntityMode is nullable + list.Add(new TypedValue(type, value)); } } @@ -440,7 +427,7 @@ protected void AddComponentTypedValues(string path, object component, IAbstractC { string[] propertyNames = type.PropertyNames; IType[] subtypes = type.Subtypes; - object[] values = type.GetPropertyValues(component, GetEntityMode(criteria, criteriaQuery)); + object[] values = type.GetPropertyValues(component); for (int i = 0; i < propertyNames.Length; i++) { @@ -503,7 +490,7 @@ protected void AppendComponentCondition( if (component != null) { String[] propertyNames = type.PropertyNames; - object[] values = type.GetPropertyValues(component, GetEntityMode(criteria, criteriaQuery)); + object[] values = type.GetPropertyValues(component); IType[] subtypes = type.Subtypes; for (int i = 0; i < propertyNames.Length; i++) { diff --git a/src/NHibernate/Criterion/InExpression.cs b/src/NHibernate/Criterion/InExpression.cs index 37f2e7bfb49..8707c2872f4 100644 --- a/src/NHibernate/Criterion/InExpression.cs +++ b/src/NHibernate/Criterion/InExpression.cs @@ -134,8 +134,8 @@ private List GetParameterTypedValues(ICriteria criteria, ICriteriaQu { object subval = _values[j] == null ? null - : actype.GetPropertyValues(_values[j], EntityMode.Poco)[i]; - list.Add(new TypedValue(types[i], subval, EntityMode.Poco)); + : actype.GetPropertyValues(_values[j])[i]; + list.Add(new TypedValue(types[i], subval)); } } @@ -143,7 +143,7 @@ private List GetParameterTypedValues(ICriteria criteria, ICriteriaQu } else { - return _values.Select(v => new TypedValue(type, v, EntityMode.Poco)).ToList(); + return _values.Select(v => new TypedValue(type, v)).ToList(); } } diff --git a/src/NHibernate/Criterion/LikeExpression.cs b/src/NHibernate/Criterion/LikeExpression.cs index ef7387c5de6..dd3f598f885 100644 --- a/src/NHibernate/Criterion/LikeExpression.cs +++ b/src/NHibernate/Criterion/LikeExpression.cs @@ -28,7 +28,7 @@ public LikeExpression(string propertyName, string value, char? escapeChar, bool { this.projection = Projections.Property(propertyName); this.value = value; - typedValue = new TypedValue(NHibernateUtil.String, this.value, EntityMode.Poco); + typedValue = new TypedValue(NHibernateUtil.String, this.value); this.escapeChar = escapeChar; this.ignoreCase = ignoreCase; @@ -38,7 +38,7 @@ public LikeExpression(IProjection projection, string value, MatchMode matchMode) { this.projection = projection; this.value = matchMode.ToMatchString(value); - typedValue = new TypedValue(NHibernateUtil.String, this.value, EntityMode.Poco); + typedValue = new TypedValue(NHibernateUtil.String, this.value); } diff --git a/src/NHibernate/Criterion/SQLCriterion.cs b/src/NHibernate/Criterion/SQLCriterion.cs index 63863d63735..ff8ab44e660 100644 --- a/src/NHibernate/Criterion/SQLCriterion.cs +++ b/src/NHibernate/Criterion/SQLCriterion.cs @@ -27,7 +27,7 @@ public SQLCriterion(SqlString sql, object[] values, IType[] types) _typedValues = new TypedValue[values.Length]; for (int i = 0; i < _typedValues.Length; i++) { - _typedValues[i] = new TypedValue(types[i], values[i], EntityMode.Poco); + _typedValues[i] = new TypedValue(types[i], values[i]); } } diff --git a/src/NHibernate/Criterion/SimpleSubqueryExpression.cs b/src/NHibernate/Criterion/SimpleSubqueryExpression.cs index 354dec43a25..d66b8504209 100644 --- a/src/NHibernate/Criterion/SimpleSubqueryExpression.cs +++ b/src/NHibernate/Criterion/SimpleSubqueryExpression.cs @@ -31,7 +31,7 @@ public override TypedValue[] GetTypedValues(ICriteria criteria, ICriteriaQuery c private TypedValue FirstTypedValue() { - return new TypedValue(GetTypes()[0], value, EntityMode.Poco); + return new TypedValue(GetTypes()[0], value); } protected override SqlString ToLeftSqlString(ICriteria criteria, ICriteriaQuery criteriaQuery) diff --git a/src/NHibernate/EmptyInterceptor.cs b/src/NHibernate/EmptyInterceptor.cs index 5c1cb0a6305..e7d41890f34 100644 --- a/src/NHibernate/EmptyInterceptor.cs +++ b/src/NHibernate/EmptyInterceptor.cs @@ -53,7 +53,7 @@ public virtual void PreFlush(ICollection entitites) return null; } - public virtual object Instantiate(string clazz, EntityMode entityMode, object id) + public virtual object Instantiate(string clazz, object id) { return null; } diff --git a/src/NHibernate/Engine/BatchFetchQueue.cs b/src/NHibernate/Engine/BatchFetchQueue.cs index bd6d65fb655..4154d333c51 100644 --- a/src/NHibernate/Engine/BatchFetchQueue.cs +++ b/src/NHibernate/Engine/BatchFetchQueue.cs @@ -159,7 +159,7 @@ public object[] GetCollectionBatch(ICollectionPersister collectionPersister, obj //if ( end == -1 && count > batchSize*10 ) return keys; //try out ten batches, max - bool isEqual = collectionPersister.KeyType.IsEqual(id, ce.LoadedKey, context.Session.EntityMode, collectionPersister.Factory); + bool isEqual = collectionPersister.KeyType.IsEqual(id, ce.LoadedKey, collectionPersister.Factory); if (isEqual) { @@ -212,7 +212,7 @@ public object[] GetEntityBatch(IEntityPersister persister,object id,int batchSiz //the first id found after the given id return ids; } - if (persister.IdentifierType.IsEqual(id, key.Identifier, context.Session.EntityMode)) + if (persister.IdentifierType.IsEqual(id, key.Identifier)) { end = i; } diff --git a/src/NHibernate/Engine/Cascade.cs b/src/NHibernate/Engine/Cascade.cs index d0c7ed99c59..f69f7964f5f 100644 --- a/src/NHibernate/Engine/Cascade.cs +++ b/src/NHibernate/Engine/Cascade.cs @@ -112,8 +112,7 @@ public void CascadeOn(IEntityPersister persister, object parent, object anything IType[] types = persister.PropertyTypes; CascadeStyle[] cascadeStyles = persister.PropertyCascadeStyles; - EntityMode entityMode = eventSource.EntityMode; - bool hasUninitializedLazyProperties = persister.HasUninitializedLazyProperties(parent, entityMode); + bool hasUninitializedLazyProperties = persister.HasUninitializedLazyProperties(parent); for (int i = 0; i < types.Length; i++) { CascadeStyle style = cascadeStyles[i]; @@ -126,11 +125,11 @@ public void CascadeOn(IEntityPersister persister, object parent, object anything if (style.DoCascade(action)) { - CascadeProperty(parent, persister.GetPropertyValue(parent, i, entityMode), types[i], style, propertyName, anything, false); + CascadeProperty(parent, persister.GetPropertyValue(parent, i), types[i], style, propertyName, anything, false); } else if (action.RequiresNoCascadeChecking) { - action.NoCascade(eventSource, persister.GetPropertyValue(parent, i, entityMode), parent, persister, i); + action.NoCascade(eventSource, persister.GetPropertyValue(parent, i), parent, persister, i); } } @@ -207,7 +206,7 @@ private void CascadeProperty(object parent, object child, IType type, CascadeSty private bool CascadeAssociationNow(IAssociationType associationType) { - return associationType.ForeignKeyDirection.CascadeNow(point) && (eventSource.EntityMode != EntityMode.Xml || associationType.IsEmbeddedInXML); + return associationType.ForeignKeyDirection.CascadeNow(point); } private void CascadeComponent(object parent, object child, IAbstractComponentType componentType, string componentPropertyName, object anything) @@ -278,11 +277,7 @@ private void CascadeToOne(object parent, object child, IType type, CascadeStyle /// Cascade to the collection elements private void CascadeCollectionElements(object parent, object child, CollectionType collectionType, CascadeStyle style, IType elemType, object anything, bool isCascadeDeleteEnabled) { - // we can't cascade to non-embedded elements - bool embeddedElements = eventSource.EntityMode != EntityMode.Xml - || ((EntityType) collectionType.GetElementType(eventSource.Factory)).IsEmbeddedInXML; - - bool reallyDoCascade = style.ReallyDoCascade(action) && embeddedElements + bool reallyDoCascade = style.ReallyDoCascade(action) && child != CollectionType.UnfetchedCollection; if (reallyDoCascade) diff --git a/src/NHibernate/Engine/CollectionKey.cs b/src/NHibernate/Engine/CollectionKey.cs index 4bb9e3eb359..28a33c2d379 100644 --- a/src/NHibernate/Engine/CollectionKey.cs +++ b/src/NHibernate/Engine/CollectionKey.cs @@ -17,19 +17,17 @@ public sealed class CollectionKey private readonly IType keyType; [NonSerialized] private readonly ISessionFactoryImplementor factory; private readonly int hashCode; - private readonly EntityMode entityMode; - public CollectionKey(ICollectionPersister persister, object key, EntityMode entityMode) - : this(persister.Role, key, persister.KeyType, entityMode, persister.Factory) + public CollectionKey(ICollectionPersister persister, object key) + : this(persister.Role, key, persister.KeyType, persister.Factory) { } - private CollectionKey(string role, object key, IType keyType, EntityMode entityMode, ISessionFactoryImplementor factory) + private CollectionKey(string role, object key, IType keyType, ISessionFactoryImplementor factory) { this.role = role; this.key = key; this.keyType = keyType; - this.entityMode = entityMode; this.factory = factory; hashCode = GenerateHashCode(); //cache the hashcode } @@ -37,7 +35,7 @@ private CollectionKey(string role, object key, IType keyType, EntityMode entityM public override bool Equals(object obj) { CollectionKey that = (CollectionKey)obj; - return that.role.Equals(role) && keyType.IsEqual(that.key, key, entityMode, factory); + return that.role.Equals(role) && keyType.IsEqual(that.key, key, factory); } public override int GetHashCode() @@ -51,7 +49,7 @@ private int GenerateHashCode() unchecked { result = 37 * result + role.GetHashCode(); - result = 37 * result + keyType.GetHashCode(key, entityMode, factory); + result = 37 * result + keyType.GetHashCode(key, factory); } return result; } diff --git a/src/NHibernate/Engine/Collections.cs b/src/NHibernate/Engine/Collections.cs index 80c069d0ac5..347d5fc9ddd 100644 --- a/src/NHibernate/Engine/Collections.cs +++ b/src/NHibernate/Engine/Collections.cs @@ -40,7 +40,7 @@ private static void ProcessDereferencedCollection(IPersistentCollection coll, IS bool hasOrphanDelete = loadedPersister != null && loadedPersister.HasOrphanDelete; if (hasOrphanDelete) { - object ownerId = loadedPersister.OwnerEntityPersister.GetIdentifier(coll.Owner, session.EntityMode); + object ownerId = loadedPersister.OwnerEntityPersister.GetIdentifier(coll.Owner); // TODO NH Different behavior //if (ownerId == null) //{ @@ -77,7 +77,7 @@ private static void ProcessDereferencedCollection(IPersistentCollection coll, IS // do the work entry.CurrentPersister = null; entry.CurrentKey = null; - PrepareCollectionForUpdate(coll, entry, session.EntityMode, session.Factory); + PrepareCollectionForUpdate(coll, entry, session.Factory); } private static void ProcessNeverReferencedCollection(IPersistentCollection coll, ISessionImplementor session) @@ -89,7 +89,7 @@ private static void ProcessNeverReferencedCollection(IPersistentCollection coll, entry.CurrentPersister = entry.LoadedPersister; entry.CurrentKey = entry.LoadedKey; - PrepareCollectionForUpdate(coll, entry, session.EntityMode, session.Factory); + PrepareCollectionForUpdate(coll, entry, session.Factory); } /// @@ -132,10 +132,10 @@ public static void ProcessReachableCollection(IPersistentCollection collection, (collection.WasInitialized ? " (initialized)" : " (uninitialized)")); } - PrepareCollectionForUpdate(collection, ce, session.EntityMode, factory); + PrepareCollectionForUpdate(collection, ce, factory); } - private static void PrepareCollectionForUpdate(IPersistentCollection collection, CollectionEntry entry, EntityMode entityMode, ISessionFactoryImplementor factory) + private static void PrepareCollectionForUpdate(IPersistentCollection collection, CollectionEntry entry, ISessionFactoryImplementor factory) { //1. record the collection role that this collection is referenced by //2. decide if the collection needs deleting/creating/updating (but don't actually schedule the action yet) @@ -151,7 +151,7 @@ private static void PrepareCollectionForUpdate(IPersistentCollection collection, { // it is or was referenced _somewhere_ bool ownerChanged = loadedPersister != currentPersister || - !currentPersister.KeyType.IsEqual(entry.LoadedKey, entry.CurrentKey, entityMode, factory); + !currentPersister.KeyType.IsEqual(entry.LoadedKey, entry.CurrentKey, factory); if (ownerChanged) { diff --git a/src/NHibernate/Engine/EntityEntry.cs b/src/NHibernate/Engine/EntityEntry.cs index 876dcad56a8..aceb9894457 100644 --- a/src/NHibernate/Engine/EntityEntry.cs +++ b/src/NHibernate/Engine/EntityEntry.cs @@ -24,7 +24,6 @@ public sealed class EntityEntry [NonSerialized] private IEntityPersister persister; // for convenience to save some lookups - private readonly EntityMode entityMode; private readonly string entityName; private EntityKey cachedEntityKey; private readonly bool isBeingReplicated; @@ -44,11 +43,10 @@ public sealed class EntityEntry /// The for the Entity. /// A boolean indicating if the Entity exists in the database. /// The that is responsible for this Entity. - /// /// /// internal EntityEntry(Status status, object[] loadedState, object rowId, object id, object version, LockMode lockMode, - bool existsInDatabase, IEntityPersister persister, EntityMode entityMode, + bool existsInDatabase, IEntityPersister persister, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched) { this.status = status; @@ -63,7 +61,6 @@ internal EntityEntry(Status status, object[] loadedState, object rowId, object i isBeingReplicated = disableVersionIncrement; loadedWithLazyPropertiesUnfetched = lazyPropertiesAreUnfetched; this.persister = persister; - this.entityMode = entityMode; entityName = persister == null ? null : persister.EntityName; } @@ -200,7 +197,7 @@ public EntityKey EntityKey if (id == null) throw new InvalidOperationException("cannot generate an EntityKey when id is null."); - cachedEntityKey = new EntityKey(id, persister, entityMode); + cachedEntityKey = new EntityKey(id, persister); } return cachedEntityKey; } @@ -234,7 +231,7 @@ public void PostUpdate(object entity, object[] updatedState, object nextVersion) if (Persister.IsVersioned) { version = nextVersion; - Persister.SetPropertyValue(entity, Persister.VersionProperty, nextVersion, entityMode); + Persister.SetPropertyValue(entity, Persister.VersionProperty, nextVersion); } FieldInterceptionHelper.ClearDirty(entity); } @@ -255,7 +252,7 @@ public void ForceLocked(object entity, object nextVersion) version = nextVersion; loadedState[persister.VersionProperty] = version; LockMode = LockMode.Force; - persister.SetPropertyValue(entity, Persister.VersionProperty, nextVersion, entityMode); + persister.SetPropertyValue(entity, Persister.VersionProperty, nextVersion); } public bool IsNullifiable(bool earlyInsert, ISessionImplementor session) @@ -312,7 +309,7 @@ public void SetReadOnly(bool readOnly, object entity) throw new InvalidOperationException("Cannot make an immutable entity modifiable."); Status = Status.Loaded; - loadedState = Persister.GetPropertyValues(entity, entityMode); + loadedState = Persister.GetPropertyValues(entity); } } diff --git a/src/NHibernate/Engine/EntityKey.cs b/src/NHibernate/Engine/EntityKey.cs index bc8a4682df3..0db22d945cf 100644 --- a/src/NHibernate/Engine/EntityKey.cs +++ b/src/NHibernate/Engine/EntityKey.cs @@ -22,11 +22,9 @@ public sealed class EntityKey private ISessionFactoryImplementor factory; private int hashCode; - private readonly EntityMode entityMode; - /// Construct a unique identifier for an entity class instance - public EntityKey(object id, IEntityPersister persister, EntityMode entityMode) - : this(id, persister.RootEntityName, persister.EntityName, persister.IdentifierType, persister.IsBatchLoadable, persister.Factory, entityMode) {} + public EntityKey(object id, IEntityPersister persister) + : this(id, persister.RootEntityName, persister.EntityName, persister.IdentifierType, persister.IsBatchLoadable, persister.Factory) {} /// Used to reconstruct an EntityKey during deserialization. /// The identifier value @@ -35,8 +33,7 @@ public EntityKey(object id, IEntityPersister persister, EntityMode entityMode) /// The type of the identifier value /// Whether represented entity is eligible for batch loading /// The session factory - /// The entity's entity mode - private EntityKey(object identifier, string rootEntityName, string entityName, IType identifierType, bool batchLoadable, ISessionFactoryImplementor factory, EntityMode entityMode) + private EntityKey(object identifier, string rootEntityName, string entityName, IType identifierType, bool batchLoadable, ISessionFactoryImplementor factory) { if (identifier == null) throw new AssertionFailure("null identifier"); @@ -47,7 +44,6 @@ private EntityKey(object identifier, string rootEntityName, string entityName, I this.identifierType = identifierType; isBatchLoadable = batchLoadable; this.factory = factory; - this.entityMode = entityMode; hashCode = GenerateHashCode(); } @@ -73,7 +69,7 @@ public override bool Equals(object other) return otherKey.rootEntityName.Equals(rootEntityName) - && identifierType.IsEqual(otherKey.Identifier, Identifier, entityMode, factory); + && identifierType.IsEqual(otherKey.Identifier, Identifier, factory); } private int GenerateHashCode() @@ -82,7 +78,7 @@ private int GenerateHashCode() unchecked { result = 37 * result + rootEntityName.GetHashCode(); - result = 37 * result + identifierType.GetHashCode(identifier, entityMode, factory); + result = 37 * result + identifierType.GetHashCode(identifier, factory); } return result; } diff --git a/src/NHibernate/Engine/EntityUniqueKey.cs b/src/NHibernate/Engine/EntityUniqueKey.cs index d3b704db38b..8646295e02d 100644 --- a/src/NHibernate/Engine/EntityUniqueKey.cs +++ b/src/NHibernate/Engine/EntityUniqueKey.cs @@ -19,9 +19,8 @@ public class EntityUniqueKey private readonly object key; private readonly IType keyType; private readonly int hashCode; - private readonly EntityMode entityMode; - public EntityUniqueKey(string entityName, string uniqueKeyName, object semiResolvedKey, IType keyType, EntityMode entityMode, ISessionFactoryImplementor factory) + public EntityUniqueKey(string entityName, string uniqueKeyName, object semiResolvedKey, IType keyType, ISessionFactoryImplementor factory) { if (string.IsNullOrEmpty(entityName)) throw new ArgumentNullException("entityName"); @@ -36,7 +35,6 @@ public EntityUniqueKey(string entityName, string uniqueKeyName, object semiResol this.uniqueKeyName = uniqueKeyName; key = semiResolvedKey; this.keyType = keyType.GetSemiResolvedType(factory); - this.entityMode = entityMode; hashCode = GenerateHashCode(factory); } @@ -47,7 +45,7 @@ public int GenerateHashCode(ISessionFactoryImplementor factory) { result = 37 * result + entityName.GetHashCode(); result = 37 * result + uniqueKeyName.GetHashCode(); - result = 37 * result + keyType.GetHashCode(key, entityMode, factory); + result = 37 * result + keyType.GetHashCode(key, factory); } return result; } @@ -81,7 +79,7 @@ public override bool Equals(object obj) public bool Equals(EntityUniqueKey that) { return that == null ? false : - that.EntityName.Equals(entityName) && that.UniqueKeyName.Equals(uniqueKeyName) && keyType.IsEqual(that.key, key, entityMode); + that.EntityName.Equals(entityName) && that.UniqueKeyName.Equals(uniqueKeyName) && keyType.IsEqual(that.key, key); } public override string ToString() diff --git a/src/NHibernate/Engine/ForeignKeys.cs b/src/NHibernate/Engine/ForeignKeys.cs index aa1e870c91a..4ffe34e06a3 100644 --- a/src/NHibernate/Engine/ForeignKeys.cs +++ b/src/NHibernate/Engine/ForeignKeys.cs @@ -84,7 +84,7 @@ private object NullifyTransientReferences(object value, IType type) } } if (substitute) - actype.SetPropertyValues(value, subvalues, session.EntityMode); + actype.SetPropertyValues(value, subvalues); return value; } else @@ -206,14 +206,14 @@ public static bool IsTransient(string entityName, object entity, bool? assumed, // is transient or detached without querying the database. // This could potentially cause Select N+1 in cascaded saves, so warn the user. log.Warn("Unable to determine if " + entity.ToString() - + " with assigned identifier " + persister.GetIdentifier(entity, session.EntityMode) + + " with assigned identifier " + persister.GetIdentifier(entity) + " is transient or detached; querying the database." + " Use explicit Save() or Update() in session to prevent this."); } // hit the database, after checking the session cache for a snapshot System.Object[] snapshot = - session.PersistenceContext.GetDatabaseSnapshot(persister.GetIdentifier(entity, session.EntityMode), persister); + session.PersistenceContext.GetDatabaseSnapshot(persister.GetIdentifier(entity), persister); return snapshot == null; } @@ -265,7 +265,7 @@ public static object GetEntityIdentifierIfNotUnsaved(string entityName, object e string.Format("object references an unsaved transient instance - save the transient instance before flushing or set cascade action for the property to something that would make it autosave. Type: {0}, Entity: {1}", entityName, entityString)); } - id = session.GetEntityPersister(entityName, entity).GetIdentifier(entity, session.EntityMode); + id = session.GetEntityPersister(entityName, entity).GetIdentifier(entity); } return id; } diff --git a/src/NHibernate/Engine/ISessionImplementor.cs b/src/NHibernate/Engine/ISessionImplementor.cs index bc31bf37ff7..e93c9082035 100644 --- a/src/NHibernate/Engine/ISessionImplementor.cs +++ b/src/NHibernate/Engine/ISessionImplementor.cs @@ -314,9 +314,6 @@ public interface ISessionImplementor /// bool TransactionInProgress { get; } - /// Retrieve the entity mode in effect for this session. - EntityMode EntityMode { get; } - /// Execute a native SQL update or delete query int ExecuteNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters); diff --git a/src/NHibernate/Engine/Loading/CollectionLoadContext.cs b/src/NHibernate/Engine/Loading/CollectionLoadContext.cs index 8d4738311e4..9e57b7e9efc 100644 --- a/src/NHibernate/Engine/Loading/CollectionLoadContext.cs +++ b/src/NHibernate/Engine/Loading/CollectionLoadContext.cs @@ -69,9 +69,7 @@ public DbDataReader ResultSet /// public IPersistentCollection GetLoadingCollection(ICollectionPersister persister, object key) { - EntityMode em = loadContexts.PersistenceContext.Session.EntityMode; - - CollectionKey collectionKey = new CollectionKey(persister, key, em); + CollectionKey collectionKey = new CollectionKey(persister, key); if (log.IsDebugEnabled) { log.Debug("starting attempt to find loading collection [" + MessageHelper.InfoString(persister.Role, key) + "]"); @@ -97,7 +95,7 @@ public IPersistentCollection GetLoadingCollection(ICollectionPersister persister else { object owner = loadContexts.PersistenceContext.GetCollectionOwner(key, persister); - bool newlySavedEntity = owner != null && loadContexts.PersistenceContext.GetEntry(owner).Status != Status.Loading && em != EntityMode.Xml; + bool newlySavedEntity = owner != null && loadContexts.PersistenceContext.GetEntry(owner).Status != Status.Loading; if (newlySavedEntity) { // important, to account for newly saved entities in query @@ -173,7 +171,7 @@ public void EndLoadingCollections(ICollectionPersister persister) matches.Add(lce); if (lce.Collection.Owner == null) { - session.PersistenceContext.AddUnownedCollection(new CollectionKey(persister, lce.Key, session.EntityMode), + session.PersistenceContext.AddUnownedCollection(new CollectionKey(persister, lce.Key), lce.Collection); } if (log.IsDebugEnabled) @@ -236,7 +234,6 @@ private void EndLoadingCollection(LoadingCollectionEntry lce, ICollectionPersist log.Debug("ending loading collection [" + lce + "]"); } ISessionImplementor session = LoadContext.PersistenceContext.Session; - EntityMode em = session.EntityMode; bool statsEnabled = session.Factory.Statistics.IsStatisticsEnabled; var stopWath = new Stopwatch(); @@ -247,7 +244,7 @@ private void EndLoadingCollection(LoadingCollectionEntry lce, ICollectionPersist bool hasNoQueuedAdds = lce.Collection.EndRead(persister); // warning: can cause a recursive calls! (proxy initialization) - if (persister.CollectionType.HasHolder(em)) + if (persister.CollectionType.HasHolder()) { LoadContext.PersistenceContext.AddCollectionHolder(lce.Collection); } diff --git a/src/NHibernate/Engine/Loading/LoadContexts.cs b/src/NHibernate/Engine/Loading/LoadContexts.cs index da771380eeb..5182c71e284 100644 --- a/src/NHibernate/Engine/Loading/LoadContexts.cs +++ b/src/NHibernate/Engine/Loading/LoadContexts.cs @@ -153,7 +153,7 @@ public CollectionLoadContext GetCollectionLoadContext(DbDataReader resultSet) /// The loading collection, or null if not found. public IPersistentCollection LocateLoadingCollection(ICollectionPersister persister, object ownerKey) { - LoadingCollectionEntry lce = LocateLoadingCollectionEntry(new CollectionKey(persister, ownerKey, Session.EntityMode)); + LoadingCollectionEntry lce = LocateLoadingCollectionEntry(new CollectionKey(persister, ownerKey)); if (lce != null) { if (log.IsDebugEnabled) diff --git a/src/NHibernate/Engine/Nullability.cs b/src/NHibernate/Engine/Nullability.cs index e34b21b12f1..b84896617d0 100644 --- a/src/NHibernate/Engine/Nullability.cs +++ b/src/NHibernate/Engine/Nullability.cs @@ -119,7 +119,7 @@ private string CheckComponentNullability(object value, IAbstractComponentType co if (nullability != null) { //do the test - object[] values = compType.GetPropertyValues(value, session.EntityMode); + object[] values = compType.GetPropertyValues(value); IType[] propertyTypes = compType.Subtypes; for (int i = 0; i < values.Length; i++) { diff --git a/src/NHibernate/Engine/StatefulPersistenceContext.cs b/src/NHibernate/Engine/StatefulPersistenceContext.cs index e303f1d9676..9adce8da2fe 100644 --- a/src/NHibernate/Engine/StatefulPersistenceContext.cs +++ b/src/NHibernate/Engine/StatefulPersistenceContext.cs @@ -530,7 +530,7 @@ public EntityEntry AddEntry(object entity, Status status, object[] loadedState, bool disableVersionIncrement, bool lazyPropertiesAreUnfetched) { EntityEntry e = - new EntityEntry(status, loadedState, rowId, id, version, lockMode, existsInDatabase, persister, session.EntityMode, + new EntityEntry(status, loadedState, rowId, id, version, lockMode, existsInDatabase, persister, disableVersionIncrement, lazyPropertiesAreUnfetched); entityEntries[entity] = e; @@ -708,13 +708,13 @@ public void CheckUniqueness(EntityKey key, object obj) /// An appropriately narrowed instance. public object NarrowProxy(INHibernateProxy proxy, IEntityPersister persister, EntityKey key, object obj) { - bool alreadyNarrow = persister.GetConcreteProxyClass(session.EntityMode).IsInstanceOfType(proxy); + bool alreadyNarrow = persister.ConcreteProxyClass.IsInstanceOfType(proxy); if (!alreadyNarrow) { if (ProxyWarnLog.IsWarnEnabled) { - ProxyWarnLog.Warn("Narrowing proxy to " + persister.GetConcreteProxyClass(session.EntityMode) + " - this operation breaks =="); + ProxyWarnLog.Warn("Narrowing proxy to " + persister.ConcreteProxyClass + " - this operation breaks =="); } if (obj != null) @@ -862,7 +862,7 @@ public void AddNewCollection(ICollectionPersister persister, IPersistentCollecti private void AddCollection(IPersistentCollection coll, CollectionEntry entry, object key) { collectionEntries[coll] = entry; - CollectionKey collectionKey = new CollectionKey(entry.LoadedPersister, key, session.EntityMode); + CollectionKey collectionKey = new CollectionKey(entry.LoadedPersister, key); IPersistentCollection tempObject; collectionsByKey.TryGetValue(collectionKey, out tempObject); collectionsByKey[collectionKey] = coll; @@ -1169,7 +1169,7 @@ public object GetOwnerId(string entityName, string propertyName, object childEnt private bool IsFoundInParent(string property, object childEntity, IEntityPersister persister, ICollectionPersister collectionPersister, object potentialParent) { - object collection = persister.GetPropertyValue(potentialParent, property, session.EntityMode); + object collection = persister.GetPropertyValue(potentialParent, property); return collection != null && NHibernateUtil.IsInitialized(collection) && collectionPersister.CollectionType.Contains(collection, childEntity, session); } @@ -1241,7 +1241,7 @@ public object GetIndexInOwner(string entity, string property, object childEntity private object GetIndexInParent(string property, object childEntity, IEntityPersister persister, ICollectionPersister collectionPersister, object potentialParent) { - object collection = persister.GetPropertyValue(potentialParent, property, session.EntityMode); + object collection = persister.GetPropertyValue(potentialParent, property); if (collection != null && NHibernateUtil.IsInitialized(collection)) { return collectionPersister.CollectionType.IndexOf(collection, childEntity); diff --git a/src/NHibernate/Engine/TwoPhaseLoad.cs b/src/NHibernate/Engine/TwoPhaseLoad.cs index 79f28759a0e..dfc06c443f6 100644 --- a/src/NHibernate/Engine/TwoPhaseLoad.cs +++ b/src/NHibernate/Engine/TwoPhaseLoad.cs @@ -94,7 +94,7 @@ public static void InitializeEntity(object entity, bool readOnly, ISessionImplem } } - persister.SetPropertyValues(entity, hydratedState, session.EntityMode); + persister.SetPropertyValues(entity, hydratedState); ISessionFactoryImplementor factory = session.Factory; diff --git a/src/NHibernate/Engine/TypedValue.cs b/src/NHibernate/Engine/TypedValue.cs index ccd47f376f2..0d97a270d37 100644 --- a/src/NHibernate/Engine/TypedValue.cs +++ b/src/NHibernate/Engine/TypedValue.cs @@ -17,15 +17,15 @@ public sealed class TypedValue private readonly object value; private readonly IEqualityComparer comparer; - public TypedValue(IType type, object value, EntityMode entityMode) + public TypedValue(IType type, object value) { this.type = type; this.value = value; var values = value as ICollection; if (!type.IsCollectionType && values != null && !type.ReturnedClass.IsArray) - comparer = new ParameterListComparer(entityMode); + comparer = new ParameterListComparer(); else - comparer = new DefaultComparer(entityMode); + comparer = new DefaultComparer(); } public object Value @@ -61,13 +61,6 @@ public override string ToString() [Serializable] public class ParameterListComparer : IEqualityComparer { - private readonly EntityMode entityMode; - - public ParameterListComparer(EntityMode entityMode) - { - this.entityMode = entityMode; - } - public bool Equals(TypedValue x, TypedValue y) { if (y == null) return false; @@ -91,7 +84,7 @@ private int GetHashCode(IType type, ICollection values) int result = 0; foreach (object obj in values) - result += obj == null ? 0 : type.GetHashCode(obj, entityMode); + result += obj == null ? 0 : type.GetHashCode(obj); return result; } @@ -114,7 +107,7 @@ private bool IsEquals(IType type, ICollection x, ICollection y) while (xe.MoveNext()) { ye.MoveNext(); - if (!type.IsEqual(xe.Current, ye.Current, entityMode)) + if (!type.IsEqual(xe.Current, ye.Current)) return false; } @@ -125,24 +118,17 @@ private bool IsEquals(IType type, ICollection x, ICollection y) [Serializable] public class DefaultComparer : IEqualityComparer { - private readonly EntityMode entityMode; - - public DefaultComparer(EntityMode entityMode) - { - this.entityMode = entityMode; - } - public bool Equals(TypedValue x, TypedValue y) { if (y == null) return false; if (x.type.ReturnedClass != y.type.ReturnedClass) return false; - return x.type.IsEqual(y.value, x.value, entityMode); + return x.type.IsEqual(y.value, x.value); } public int GetHashCode(TypedValue obj) { - return obj.value == null ? 0 : obj.type.GetHashCode(obj.value, entityMode); + return obj.value == null ? 0 : obj.type.GetHashCode(obj.value); } } } diff --git a/src/NHibernate/EntityMode.cs b/src/NHibernate/EntityMode.cs index 27d615aff3e..3885b4247e4 100644 --- a/src/NHibernate/EntityMode.cs +++ b/src/NHibernate/EntityMode.cs @@ -4,40 +4,6 @@ namespace NHibernate public enum EntityMode { Poco, - Map, - Xml - } - - public static class EntityModeHelper - { - public static string ToString(EntityMode entityMode) - { - switch (entityMode) - { - case EntityMode.Poco: - return "poco"; - case EntityMode.Map: - return "dynamic-map"; - case EntityMode.Xml: - return "xml"; - } - return null; - } - - public static EntityMode Parse(string name) - { - string n = name.ToLowerInvariant(); - switch (n) - { - case "poco": - return EntityMode.Poco; - case "dynamic-map": - return EntityMode.Map; - case "xml": - return EntityMode.Xml; - default: - return EntityMode.Poco; - } - } + Map } } \ No newline at end of file diff --git a/src/NHibernate/EntityModeEqualityComparer.cs b/src/NHibernate/EntityModeEqualityComparer.cs deleted file mode 100644 index a57533d5519..00000000000 --- a/src/NHibernate/EntityModeEqualityComparer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -using System; - -namespace NHibernate -{ - [Serializable] - public class EntityModeEqualityComparer : IEqualityComparer - { - public bool Equals(EntityMode x, EntityMode y) - { - return x == y; - } - - public int GetHashCode(EntityMode obj) - { - return (int) obj; - } - } -} \ No newline at end of file diff --git a/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs b/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs index 734515fb65e..a6c26377e15 100644 --- a/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs +++ b/src/NHibernate/Event/Default/AbstractFlushingEventListener.cs @@ -81,7 +81,7 @@ protected virtual void FlushEverythingToExecutions(FlushEvent @event) .Append(" removals to ").Append(persistenceContext.CollectionEntries.Count).Append(" collections"); log.Debug(sb.ToString()); - new Printer(session.Factory).ToString(persistenceContext.EntitiesByKey.Values.ToArray().GetEnumerator(), session.EntityMode); + new Printer(session.Factory).ToString(persistenceContext.EntitiesByKey.Values.ToArray().GetEnumerator()); } } @@ -296,7 +296,7 @@ protected virtual void PostFlush(ISessionImplementor session) { //otherwise recreate the mapping between the collection and its key CollectionKey collectionKey = - new CollectionKey(collectionEntry.LoadedPersister, collectionEntry.LoadedKey, session.EntityMode); + new CollectionKey(collectionEntry.LoadedPersister, collectionEntry.LoadedKey); persistenceContext.CollectionsByKey[collectionKey] = persistentCollection; } } diff --git a/src/NHibernate/Event/Default/AbstractReassociateEventListener.cs b/src/NHibernate/Event/Default/AbstractReassociateEventListener.cs index d22a3e6aeca..430c50a0135 100644 --- a/src/NHibernate/Event/Default/AbstractReassociateEventListener.cs +++ b/src/NHibernate/Event/Default/AbstractReassociateEventListener.cs @@ -38,7 +38,7 @@ protected EntityEntry Reassociate(AbstractEvent @event, object entity, object id source.PersistenceContext.CheckUniqueness(key, entity); //get a snapshot - object[] values = persister.GetPropertyValues(entity, source.EntityMode); + object[] values = persister.GetPropertyValues(entity); TypeHelper.DeepCopy(values, persister.PropertyTypes, persister.PropertyUpdateability, values, source); object version = Versioning.GetVersion(values, persister); diff --git a/src/NHibernate/Event/Default/AbstractSaveEventListener.cs b/src/NHibernate/Event/Default/AbstractSaveEventListener.cs index 5f8e0b53e9d..70e5691d748 100644 --- a/src/NHibernate/Event/Default/AbstractSaveEventListener.cs +++ b/src/NHibernate/Event/Default/AbstractSaveEventListener.cs @@ -51,7 +51,7 @@ protected virtual bool InvokeSaveLifecycle(object entity, IEntityPersister persi { // Sub-insertions should occur before containing insertion so // Try to do the callback now - if (persister.ImplementsLifecycle(source.EntityMode)) + if (persister.ImplementsLifecycle) { log.Debug("calling OnSave()"); if (((ILifecycle)entity).OnSave(source) == LifecycleVeto.Veto) @@ -65,7 +65,7 @@ protected virtual bool InvokeSaveLifecycle(object entity, IEntityPersister persi protected virtual void Validate(object entity, IEntityPersister persister, IEventSource source) { - if (persister.ImplementsValidatable(source.EntityMode)) + if (persister.ImplementsValidatable) { ((IValidatable)entity).Validate(); } @@ -173,7 +173,7 @@ protected virtual object PerformSave(object entity, object id, IEntityPersister throw new NonUniqueObjectException(id, persister.EntityName); } } - persister.SetIdentifier(entity, id, source.EntityMode); + persister.SetIdentifier(entity, id); } else { @@ -242,7 +242,7 @@ protected virtual object PerformSaveOrReplicate(object entity, EntityKey key, IE if (substitute) { - persister.SetPropertyValues(entity, values, source.EntityMode); + persister.SetPropertyValues(entity, values); } TypeHelper.DeepCopy(values, types, persister.PropertyUpdateability, values, source); @@ -301,7 +301,7 @@ private void MarkInterceptorDirty(object entity, IEntityPersister persister, IEv { if (FieldInterceptionHelper.IsInstrumented(entity)) { - IFieldInterceptor interceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, persister.EntityName, persister.GetMappedClass(source.EntityMode), null, null, source); + IFieldInterceptor interceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, persister.EntityName, persister.MappedClass, null, null, source); interceptor.MarkDirty(); } } diff --git a/src/NHibernate/Event/Default/AbstractVisitor.cs b/src/NHibernate/Event/Default/AbstractVisitor.cs index b76868469c4..8d8f21d9816 100644 --- a/src/NHibernate/Event/Default/AbstractVisitor.cs +++ b/src/NHibernate/Event/Default/AbstractVisitor.cs @@ -108,7 +108,7 @@ internal virtual object ProcessCollection(object value, CollectionType collectio /// internal virtual void Process(object obj, IEntityPersister persister) { - ProcessEntityPropertyValues(persister.GetPropertyValues(obj, Session.EntityMode), persister.PropertyTypes); + ProcessEntityPropertyValues(persister.GetPropertyValues(obj), persister.PropertyTypes); } public void ProcessEntityPropertyValues(object[] values, IType[] types) diff --git a/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs b/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs index da5aa8112bc..1a39b53d22f 100644 --- a/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultDeleteEventListener.cs @@ -57,7 +57,7 @@ public virtual void OnDelete(DeleteEvent @event, ISet transientEntities) PerformDetachedEntityDeletionCheck(@event); } - id = persister.GetIdentifier(entity, source.EntityMode); + id = persister.GetIdentifier(entity); if (id == null) { @@ -70,12 +70,12 @@ public virtual void OnDelete(DeleteEvent @event, ISet transientEntities) new OnUpdateVisitor(source, id, entity).Process(entity, persister); - version = persister.GetVersion(entity, source.EntityMode); + version = persister.GetVersion(entity); entityEntry = persistenceContext.AddEntity( entity, persister.IsMutable ? Status.Loaded : Status.ReadOnly, - persister.GetPropertyValues(entity, source.EntityMode), + persister.GetPropertyValues(entity), key, version, LockMode.None, @@ -105,7 +105,7 @@ public virtual void OnDelete(DeleteEvent @event, ISet transientEntities) if (source.Factory.Settings.IsIdentifierRollbackEnabled) { - persister.ResetIdentifier(entity, id, version, source.EntityMode); + persister.ResetIdentifier(entity, id, version); } } @@ -182,7 +182,7 @@ protected virtual void DeleteEntity(IEventSource session, object entity, EntityE if (entityEntry.LoadedState == null) { //ie. the entity came in from update() - currentState = persister.GetPropertyValues(entity, session.EntityMode); + currentState = persister.GetPropertyValues(entity); } else { @@ -228,7 +228,7 @@ private object[] CreateDeletedState(IEntityPersister persister, object[] current protected virtual bool InvokeDeleteLifecycle(IEventSource session, object entity, IEntityPersister persister) { - if (persister.ImplementsLifecycle(session.EntityMode)) + if (persister.ImplementsLifecycle) { log.Debug("calling onDelete()"); if (((ILifecycle)entity).OnDelete(session) == LifecycleVeto.Veto) diff --git a/src/NHibernate/Event/Default/DefaultFlushEntityEventListener.cs b/src/NHibernate/Event/Default/DefaultFlushEntityEventListener.cs index ab60c16f104..20a46b08691 100644 --- a/src/NHibernate/Event/Default/DefaultFlushEntityEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultFlushEntityEventListener.cs @@ -28,12 +28,11 @@ public virtual void OnFlushEntity(FlushEntityEvent @event) IEventSource session = @event.Session; IEntityPersister persister = entry.Persister; Status status = entry.Status; - EntityMode entityMode = session.EntityMode; IType[] types = persister.PropertyTypes; bool mightBeDirty = entry.RequiresDirtyCheck(entity); - object[] values = GetValues(entity, entry, entityMode, mightBeDirty, session); + object[] values = GetValues(entity, entry, mightBeDirty, session); @event.PropertyValues = values; @@ -49,7 +48,7 @@ public virtual void OnFlushEntity(FlushEntityEvent @event) { // now update the object .. has to be outside the main if block above (because of collections) if (substitute) - persister.SetPropertyValues(entity, values, entityMode); + persister.SetPropertyValues(entity, values); // Search for collections by reachability, updating their role. // We don't want to touch collections reachable from a deleted object @@ -60,7 +59,7 @@ public virtual void OnFlushEntity(FlushEntityEvent @event) } } - private object[] GetValues(object entity, EntityEntry entry, EntityMode entityMode, bool mightBeDirty, ISessionImplementor session) + private object[] GetValues(object entity, EntityEntry entry, bool mightBeDirty, ISessionImplementor session) { object[] loadedState = entry.LoadedState; Status status = entry.Status; @@ -78,12 +77,12 @@ private object[] GetValues(object entity, EntityEntry entry, EntityMode entityMo } else { - CheckId(entity, persister, entry.Id, entityMode); + CheckId(entity, persister, entry.Id); // grab its current state - values = persister.GetPropertyValues(entity, entityMode); + values = persister.GetPropertyValues(entity); - CheckNaturalId(persister, entry, values, loadedState, entityMode, session); + CheckNaturalId(persister, entry, values, loadedState, session); } return values; } @@ -94,8 +93,7 @@ private object[] GetValues(object entity, EntityEntry entry, EntityMode entityMo /// The obj. /// The persister. /// The id. - /// The entity mode. - public virtual void CheckId(object obj, IEntityPersister persister, object id, EntityMode entityMode) + public virtual void CheckId(object obj, IEntityPersister persister, object id) { if (id != null && id is DelayedPostInsertIdentifier) { @@ -111,15 +109,15 @@ public virtual void CheckId(object obj, IEntityPersister persister, object id, E throw new AssertionFailure("null id in " + persister.EntityName + " entry (don't flush the Session after an exception occurs)"); } - object oid = persister.GetIdentifier(obj, entityMode); - if (!persister.IdentifierType.IsEqual(id, oid, EntityMode.Poco)) + object oid = persister.GetIdentifier(obj); + if (!persister.IdentifierType.IsEqual(id, oid)) { throw new HibernateException("identifier of an instance of " + persister.EntityName + " was altered from " + id + " to " + oid); } } } - private void CheckNaturalId(IEntityPersister persister, EntityEntry entry, object[] current, object[] loaded, EntityMode entityMode, ISessionImplementor session) + private void CheckNaturalId(IEntityPersister persister, EntityEntry entry, object[] current, object[] loaded, ISessionImplementor session) { if (persister.HasNaturalIdentifier && entry.Status != Status.ReadOnly) { @@ -145,7 +143,7 @@ private void CheckNaturalId(IEntityPersister persister, EntityEntry entry, objec { loadedVal = loaded[prop]; } - if (!types[prop].IsEqual(current[prop], loadedVal, entityMode)) + if (!types[prop].IsEqual(current[prop], loadedVal)) { throw new HibernateException("immutable natural identifier of an instance of " + persister.EntityName + " was altered"); @@ -206,7 +204,6 @@ private bool ScheduleUpdate(FlushEntityEvent @event) { EntityEntry entry = @event.EntityEntry; IEventSource session = @event.Session; - EntityMode entityMode = session.EntityMode; object entity = @event.Entity; Status status = entry.Status; IEntityPersister persister = entry.Persister; @@ -248,7 +245,7 @@ private bool ScheduleUpdate(FlushEntityEvent @event) intercepted = false; } - Validate(entity, persister, status, entityMode); + Validate(entity, persister, status); // increment the version number (if necessary) object nextVersion = GetNextVersion(@event); @@ -276,7 +273,7 @@ private bool ScheduleUpdate(FlushEntityEvent @event) values, dirtyProperties, @event.HasDirtyCollection, - status == Status.Deleted && !entry.IsModifiableEntity() ? persister.GetPropertyValues(entity, entityMode) : entry.LoadedState, + status == Status.Deleted && !entry.IsModifiableEntity() ? persister.GetPropertyValues(entity) : entry.LoadedState, entry.Version, nextVersion, entity, @@ -286,10 +283,10 @@ private bool ScheduleUpdate(FlushEntityEvent @event) return intercepted; } - protected virtual void Validate(object entity, IEntityPersister persister, Status status, EntityMode entityMode) + protected virtual void Validate(object entity, IEntityPersister persister, Status status) { // validate() instances of Validatable - if (status == Status.Loaded && persister.ImplementsValidatable(entityMode)) + if (status == Status.Loaded && persister.ImplementsValidatable) { ((IValidatable)entity).Validate(); } @@ -471,7 +468,7 @@ protected virtual void DirtyCheck(FlushEntityEvent @event) // - entry.getDeletedState() contains the entity's current property values with // references to transient entities set to null. // - dirtyProperties will only contain properties that refer to transient entities - object[] currentState = persister.GetPropertyValues(@event.Entity, @event.Session.EntityMode); + object[] currentState = persister.GetPropertyValues(@event.Entity); dirtyProperties = persister.FindDirty(entry.DeletedState, currentState, entity, session); cannotDirtyCheck = false; } diff --git a/src/NHibernate/Event/Default/DefaultLoadEventListener.cs b/src/NHibernate/Event/Default/DefaultLoadEventListener.cs index 349644dfe67..e1d8fda4132 100644 --- a/src/NHibernate/Event/Default/DefaultLoadEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultLoadEventListener.cs @@ -104,7 +104,7 @@ protected virtual object Load(LoadEvent @event, IEntityPersister persister, Enti { throw new PersistentObjectException("attempted to load into an instance that was already associated with the session: " + MessageHelper.InfoString(persister, @event.EntityId, @event.Session.Factory)); } - persister.SetIdentifier(@event.InstanceToLoad, @event.EntityId, @event.Session.EntityMode); + persister.SetIdentifier(@event.InstanceToLoad, @event.EntityId); } object entity = DoLoad(@event, persister, keyToLoad, options); @@ -394,7 +394,7 @@ protected virtual object LoadFromSessionCache(LoadEvent @event, EntityKey keyToL if (options.IsAllowNulls) { IEntityPersister persister = GetEntityPersister(@event.Session.Factory, @event.EntityClassName); - if (!persister.IsInstance(old, @event.Session.EntityMode)) + if (!persister.IsInstance(old)) { return InconsistentRTNClassMarker; } diff --git a/src/NHibernate/Event/Default/DefaultLockEventListener.cs b/src/NHibernate/Event/Default/DefaultLockEventListener.cs index 74629cbd322..2ab6f9d7782 100644 --- a/src/NHibernate/Event/Default/DefaultLockEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultLockEventListener.cs @@ -41,7 +41,7 @@ public virtual void OnLock(LockEvent @event) if (entry == null) { IEntityPersister persister = source.GetEntityPersister(@event.EntityName, entity); - object id = persister.GetIdentifier(entity, source.EntityMode); + object id = persister.GetIdentifier(entity); if (!ForeignKeys.IsNotTransient(@event.EntityName, entity, false, source)) { throw new TransientObjectException("cannot lock an unsaved transient instance: " + persister.EntityName); diff --git a/src/NHibernate/Event/Default/DefaultMergeEventListener.cs b/src/NHibernate/Event/Default/DefaultMergeEventListener.cs index 1178c50d26e..7a2df7b21ff 100644 --- a/src/NHibernate/Event/Default/DefaultMergeEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultMergeEventListener.cs @@ -143,7 +143,7 @@ public virtual void OnMerge(MergeEvent @event, IDictionary copiedAlready) if (entry == null) { IEntityPersister persister = source.GetEntityPersister(@event.EntityName, entity); - object id = persister.GetIdentifier(entity, source.EntityMode); + object id = persister.GetIdentifier(entity); if (id != null) { EntityKey key = source.GenerateEntityKey(id, persister); @@ -219,13 +219,13 @@ private object MergeTransientEntity(object entity, string entityName, object req { IEntityPersister persister = source.GetEntityPersister(entityName, entity); - object id = persister.HasIdentifierProperty ? persister.GetIdentifier(entity, source.EntityMode) : null; + object id = persister.HasIdentifierProperty ? persister.GetIdentifier(entity) : null; object copy = null; if (copyCache.Contains(entity)) { copy = copyCache[entity]; - persister.SetIdentifier(copy, id, source.EntityMode); + persister.SetIdentifier(copy, id); } else { @@ -247,8 +247,8 @@ private object MergeTransientEntity(object entity, string entityName, object req catch (PropertyValueException ex) { string propertyName = ex.PropertyName; - object propertyFromCopy = persister.GetPropertyValue(copy, propertyName, source.EntityMode); - object propertyFromEntity = persister.GetPropertyValue(entity, propertyName, source.EntityMode); + object propertyFromCopy = persister.GetPropertyValue(copy, propertyName); + object propertyFromEntity = persister.GetPropertyValue(entity, propertyName); IType propertyType = persister.GetPropertyType(propertyName); EntityEntry copyEntry = source.PersistenceContext.GetEntry(copy); @@ -312,13 +312,13 @@ protected virtual void EntityIsDetached(MergeEvent @event, IDictionary copyCache object id = @event.RequestedId; if (id == null) { - id = persister.GetIdentifier(entity, source.EntityMode); + id = persister.GetIdentifier(entity); } else { // check that entity id = requestedId - object entityId = persister.GetIdentifier(entity, source.EntityMode); - if (!persister.IdentifierType.IsEqual(id, entityId, source.EntityMode, source.Factory)) + object entityId = persister.GetIdentifier(entity); + if (!persister.IdentifierType.IsEqual(id, entityId, source.Factory)) { throw new HibernateException("merge requested with id not matching id of passed entity"); } @@ -329,7 +329,7 @@ protected virtual void EntityIsDetached(MergeEvent @event, IDictionary copyCache //we must clone embedded composite identifiers, or //we will get back the same instance that we pass in - object clonedIdentifier = persister.IdentifierType.DeepCopy(id, source.EntityMode, source.Factory); + object clonedIdentifier = persister.IdentifierType.DeepCopy(id, source.Factory); object result = source.Get(persister.EntityName, clonedIdentifier); source.FetchProfile = previousFetchProfile; @@ -388,7 +388,7 @@ protected virtual void EntityIsDetached(MergeEvent @event, IDictionary copyCache protected virtual bool InvokeUpdateLifecycle(object entity, IEntityPersister persister, IEventSource source) { - if (persister.ImplementsLifecycle(source.EntityMode)) + if (persister.ImplementsLifecycle) { log.Debug("calling onUpdate()"); if (((ILifecycle)entity).OnUpdate(source) == LifecycleVeto.Veto) @@ -429,8 +429,8 @@ private static bool IsVersionChanged(object entity, IEventSource source, IEntity // (though during a separate operation) in which it was // originally persisted/saved bool changed = - !persister.VersionType.IsSame(persister.GetVersion(target, source.EntityMode), - persister.GetVersion(entity, source.EntityMode), source.EntityMode); + !persister.VersionType.IsSame(persister.GetVersion(target), + persister.GetVersion(entity)); // TODO : perhaps we should additionally require that the incoming entity // version be equivalent to the defined unsaved-value? @@ -442,7 +442,7 @@ private static bool ExistsInDatabase(object entity, IEventSource source, IEntity EntityEntry entry = source.PersistenceContext.GetEntry(entity); if (entry == null) { - object id = persister.GetIdentifier(entity, source.EntityMode); + object id = persister.GetIdentifier(entity); if (id != null) { EntityKey key = source.GenerateEntityKey(id, persister); @@ -466,11 +466,11 @@ private static bool ExistsInDatabase(object entity, IEventSource source, IEntity protected virtual void CopyValues(IEntityPersister persister, object entity, object target, ISessionImplementor source, IDictionary copyCache) { object[] copiedValues = - TypeHelper.Replace(persister.GetPropertyValues(entity, source.EntityMode), - persister.GetPropertyValues(target, source.EntityMode), persister.PropertyTypes, source, target, + TypeHelper.Replace(persister.GetPropertyValues(entity), + persister.GetPropertyValues(target), persister.PropertyTypes, source, target, copyCache); - persister.SetPropertyValues(target, copiedValues, source.EntityMode); + persister.SetPropertyValues(target, copiedValues); } protected virtual void CopyValues(IEntityPersister persister, object entity, object target, ISessionImplementor source, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection) @@ -483,19 +483,19 @@ protected virtual void CopyValues(IEntityPersister persister, object entity, obj // replacement to associations types (value types were already replaced // during the first pass) copiedValues = - TypeHelper.ReplaceAssociations(persister.GetPropertyValues(entity, source.EntityMode), - persister.GetPropertyValues(target, source.EntityMode), persister.PropertyTypes, + TypeHelper.ReplaceAssociations(persister.GetPropertyValues(entity), + persister.GetPropertyValues(target), persister.PropertyTypes, source, target, copyCache, foreignKeyDirection); } else { copiedValues = - TypeHelper.Replace(persister.GetPropertyValues(entity, source.EntityMode), - persister.GetPropertyValues(target, source.EntityMode), persister.PropertyTypes, source, target, + TypeHelper.Replace(persister.GetPropertyValues(entity), + persister.GetPropertyValues(target), persister.PropertyTypes, source, target, copyCache, foreignKeyDirection); } - persister.SetPropertyValues(target, copiedValues, source.EntityMode); + persister.SetPropertyValues(target, copiedValues); } /// diff --git a/src/NHibernate/Event/Default/DefaultPostLoadEventListener.cs b/src/NHibernate/Event/Default/DefaultPostLoadEventListener.cs index fa41258ba85..4da31d933ac 100644 --- a/src/NHibernate/Event/Default/DefaultPostLoadEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultPostLoadEventListener.cs @@ -9,7 +9,7 @@ public class DefaultPostLoadEventListener : IPostLoadEventListener { public virtual void OnPostLoad(PostLoadEvent @event) { - if (@event.Persister.ImplementsLifecycle(@event.Session.EntityMode)) + if (@event.Persister.ImplementsLifecycle) { //log.debug( "calling onLoad()" ); ((ILifecycle)@event.Entity).OnLoad(@event.Session, @event.Id); diff --git a/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs b/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs index c1d3fdfa0dc..669bf9345f9 100644 --- a/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultRefreshEventListener.cs @@ -51,7 +51,7 @@ public virtual void OnRefresh(RefreshEvent @event, IDictionary refreshedAlready) if (e == null) { persister = source.GetEntityPersister(null, obj); //refresh() does not pass an entityName - id = persister.GetIdentifier(obj, source.EntityMode); + id = persister.GetIdentifier(obj); if (log.IsDebugEnabled) { log.Debug("refreshing transient " + MessageHelper.InfoString(persister, id, source.Factory)); diff --git a/src/NHibernate/Event/Default/DefaultReplicateEventListener.cs b/src/NHibernate/Event/Default/DefaultReplicateEventListener.cs index 70b531a3c6e..33e7bc635b4 100644 --- a/src/NHibernate/Event/Default/DefaultReplicateEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultReplicateEventListener.cs @@ -39,7 +39,7 @@ public virtual void OnReplicate(ReplicateEvent @event) /*if ( persister.isUnsaved(entity, source) ) { throw new TransientObjectException("transient instance passed to replicate()"); }*/ - object id = persister.GetIdentifier(entity, source.EntityMode); + object id = persister.GetIdentifier(entity); if (id == null) { throw new TransientObjectException("instance with null id passed to replicate()"); @@ -70,7 +70,7 @@ public virtual void OnReplicate(ReplicateEvent @event) bool canReplicate = replicationMode.ShouldOverwriteCurrentVersion(entity, realOldVersion, - persister.GetVersion(entity, source.EntityMode), + persister.GetVersion(entity), persister.VersionType); if (canReplicate) diff --git a/src/NHibernate/Event/Default/DefaultSaveOrUpdateEventListener.cs b/src/NHibernate/Event/Default/DefaultSaveOrUpdateEventListener.cs index c7e8fc778f7..174fe8ec9f7 100644 --- a/src/NHibernate/Event/Default/DefaultSaveOrUpdateEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultSaveOrUpdateEventListener.cs @@ -103,7 +103,7 @@ protected virtual object EntityIsPersistent(SaveOrUpdateEvent @event) } else { - if (!entityEntry.Persister.IdentifierType.IsEqual(requestedId, entityEntry.Id, EntityMode.Poco)) + if (!entityEntry.Persister.IdentifierType.IsEqual(requestedId, entityEntry.Id)) { throw new PersistentObjectException("object passed to save() was already persistent: " + MessageHelper.InfoString(entityEntry.Persister, requestedId, factory)); @@ -188,7 +188,7 @@ protected virtual void EntityIsDetached(SaveOrUpdateEvent @event) IEntityPersister persister = @event.Session.GetEntityPersister(@event.EntityName, entity); - @event.RequestedId = GetUpdateId(entity, persister, @event.RequestedId, @event.Session.EntityMode); + @event.RequestedId = GetUpdateId(entity, persister, @event.RequestedId); PerformUpdate(@event, entity, persister); } @@ -197,12 +197,11 @@ protected virtual void EntityIsDetached(SaveOrUpdateEvent @event) /// The entity. /// The entity persister /// The requested identifier - /// The entity mode. /// The id. - protected virtual object GetUpdateId(object entity, IEntityPersister persister, object requestedId, EntityMode entityMode) + protected virtual object GetUpdateId(object entity, IEntityPersister persister, object requestedId) { // use the id assigned to the instance - object id = persister.GetIdentifier(entity, entityMode); + object id = persister.GetIdentifier(entity); if (id == null) { // assume this is a newly instantiated transient object @@ -259,7 +258,7 @@ protected virtual void PerformUpdate(SaveOrUpdateEvent @event, object entity, IE persister.IsMutable ? Status.Loaded : Status.ReadOnly, null, key, - persister.GetVersion(entity, source.EntityMode), + persister.GetVersion(entity), LockMode.None, true, persister, @@ -278,7 +277,7 @@ protected virtual void PerformUpdate(SaveOrUpdateEvent @event, object entity, IE protected virtual bool InvokeUpdateLifecycle(object entity, IEntityPersister persister, IEventSource source) { - if (persister.ImplementsLifecycle(source.EntityMode)) + if (persister.ImplementsLifecycle) { log.Debug("calling onUpdate()"); if (((ILifecycle)entity).OnUpdate(source) == LifecycleVeto.Veto) diff --git a/src/NHibernate/Event/Default/DefaultUpdateEventListener.cs b/src/NHibernate/Event/Default/DefaultUpdateEventListener.cs index d63e617ede7..dd7d5e547a6 100644 --- a/src/NHibernate/Event/Default/DefaultUpdateEventListener.cs +++ b/src/NHibernate/Event/Default/DefaultUpdateEventListener.cs @@ -40,15 +40,15 @@ protected override object SaveWithGeneratedOrRequestedId(SaveOrUpdateEvent @even /// If the user specified an id, assign it to the instance and use that, /// otherwise use the id already assigned to the instance /// - protected override object GetUpdateId(object entity, IEntityPersister persister, object requestedId, EntityMode entityMode) + protected override object GetUpdateId(object entity, IEntityPersister persister, object requestedId) { if (requestedId == null) { - return base.GetUpdateId(entity, persister, requestedId, entityMode); + return base.GetUpdateId(entity, persister, requestedId); } else { - persister.SetIdentifier(entity, requestedId, entityMode); + persister.SetIdentifier(entity, requestedId); return requestedId; } } diff --git a/src/NHibernate/Event/Default/EvictVisitor.cs b/src/NHibernate/Event/Default/EvictVisitor.cs index a0d734991fd..19d2442a684 100644 --- a/src/NHibernate/Event/Default/EvictVisitor.cs +++ b/src/NHibernate/Event/Default/EvictVisitor.cs @@ -56,7 +56,7 @@ private void EvictCollection(IPersistentCollection collection) if (ce.LoadedPersister != null && ce.LoadedKey != null) { //TODO: is this 100% correct? - Session.PersistenceContext.CollectionsByKey.Remove(new CollectionKey(ce.LoadedPersister, ce.LoadedKey, Session.EntityMode)); + Session.PersistenceContext.CollectionsByKey.Remove(new CollectionKey(ce.LoadedPersister, ce.LoadedKey)); } } } diff --git a/src/NHibernate/Event/Default/ReattachVisitor.cs b/src/NHibernate/Event/Default/ReattachVisitor.cs index e862496edc7..7204b8d42ef 100644 --- a/src/NHibernate/Event/Default/ReattachVisitor.cs +++ b/src/NHibernate/Event/Default/ReattachVisitor.cs @@ -78,7 +78,7 @@ internal object ExtractCollectionKeyFromOwner(ICollectionPersister role) } else { - return role.OwnerEntityPersister.GetPropertyValue(owner, role.CollectionType.LHSPropertyName, Session.EntityMode); + return role.OwnerEntityPersister.GetPropertyValue(owner, role.CollectionType.LHSPropertyName); } } } diff --git a/src/NHibernate/Event/Default/WrapVisitor.cs b/src/NHibernate/Event/Default/WrapVisitor.cs index bf910facf47..59b56664c6c 100644 --- a/src/NHibernate/Event/Default/WrapVisitor.cs +++ b/src/NHibernate/Event/Default/WrapVisitor.cs @@ -24,13 +24,12 @@ internal bool SubstitutionRequired internal override void Process(object obj, IEntityPersister persister) { - EntityMode entityMode = Session.EntityMode; - object[] values = persister.GetPropertyValues(obj, entityMode); + object[] values = persister.GetPropertyValues(obj); IType[] types = persister.PropertyTypes; ProcessEntityPropertyValues(values, types); if (SubstitutionRequired) { - persister.SetPropertyValues(obj, values, entityMode); + persister.SetPropertyValues(obj, values); } } @@ -67,7 +66,7 @@ private object ProcessArrayOrNewCollection(object collection, CollectionType col IPersistenceContext persistenceContext = session.PersistenceContext; //TODO: move into collection type, so we can use polymorphism! - if (collectionType.HasHolder(session.EntityMode)) + if (collectionType.HasHolder()) { if (collection == CollectionType.UnfetchedCollection) return null; @@ -121,7 +120,7 @@ internal override object ProcessComponent(object component, IAbstractComponentTy } if (substituteComponent) { - componentType.SetPropertyValues(component, values, Session.EntityMode); + componentType.SetPropertyValues(component, values); } } diff --git a/src/NHibernate/IInterceptor.cs b/src/NHibernate/IInterceptor.cs index 26f6969427d..90b99df8799 100644 --- a/src/NHibernate/IInterceptor.cs +++ b/src/NHibernate/IInterceptor.cs @@ -144,14 +144,13 @@ int[] FindDirty(object entity, object id, object[] currentState, object[] previo /// constructor of the class /// /// the name of the entity - /// The type of entity instance to be returned. /// the identifier of the new instance /// An instance of the class, or to choose default behaviour /// /// The identifier property of the returned instance /// should be initialized with the given identifier. /// - object Instantiate(System.String entityName, EntityMode entityMode, object id); + object Instantiate(System.String entityName, object id); /// Get the entity name for a persistent or transient instance /// an entity instance diff --git a/src/NHibernate/ISession.cs b/src/NHibernate/ISession.cs index 55dcffe5700..7924d37c389 100644 --- a/src/NHibernate/ISession.cs +++ b/src/NHibernate/ISession.cs @@ -73,9 +73,6 @@ namespace NHibernate /// public interface ISession : IDisposable { - /// The entity mode in effect for this session. - EntityMode ActiveEntityMode { get; } // NH different implementation: changed name to avoid conflicts - /// /// Force the ISession to flush. /// @@ -932,14 +929,12 @@ public interface ISession : IDisposable /// Get the statistics for this session. ISessionStatistics Statistics { get; } - /// - /// Starts a new Session with the given entity mode in effect. This secondary - /// Session inherits the connection, transaction, and other context - /// information from the primary Session. It doesn't need to be flushed - /// or closed by the developer. - /// - /// The entity mode to use for the new session. + /// + /// Starts a new Session. This secondary Session inherits the connection, transaction, + /// and other context information from the primary Session. It doesn't need to be flushed + /// or closed by the developer. + /// /// The new session - ISession GetSession(EntityMode entityMode); + ISession GetChildSession(); } } diff --git a/src/NHibernate/Id/Assigned.cs b/src/NHibernate/Id/Assigned.cs index 3ddf42d1320..cfd9d6919c5 100644 --- a/src/NHibernate/Id/Assigned.cs +++ b/src/NHibernate/Id/Assigned.cs @@ -39,7 +39,7 @@ public object Generate(ISessionImplementor session, object obj) throw new IdentifierGenerationException("Illegal use of assigned id generation for a toplevel collection"); } - object id = session.GetEntityPersister(entityName, obj).GetIdentifier(obj, session.EntityMode); + object id = session.GetEntityPersister(entityName, obj).GetIdentifier(obj); if (id == null) { throw new IdentifierGenerationException("ids for this class must be manually assigned before calling save(): " diff --git a/src/NHibernate/Id/ForeignGenerator.cs b/src/NHibernate/Id/ForeignGenerator.cs index 4795fd963fc..1201e137532 100644 --- a/src/NHibernate/Id/ForeignGenerator.cs +++ b/src/NHibernate/Id/ForeignGenerator.cs @@ -42,7 +42,7 @@ public object Generate(ISessionImplementor sessionImplementor, object obj) ISession session = (ISession) sessionImplementor; var persister = sessionImplementor.Factory.GetEntityPersister(entityName); - object associatedObject = persister.GetPropertyValue(obj, propertyName, sessionImplementor.EntityMode); + object associatedObject = persister.GetPropertyValue(obj, propertyName); if (associatedObject == null) { diff --git a/src/NHibernate/Id/SelectGenerator.cs b/src/NHibernate/Id/SelectGenerator.cs index 717959d469f..6c9a406b9db 100644 --- a/src/NHibernate/Id/SelectGenerator.cs +++ b/src/NHibernate/Id/SelectGenerator.cs @@ -105,8 +105,7 @@ public override IdentifierGeneratingInsert PrepareIdentifierGeneratingInsert() protected internal override void BindParameters(ISessionImplementor session, DbCommand ps, object entity) { - object uniqueKeyValue = ((IEntityPersister) persister).GetPropertyValue(entity, uniqueKeyPropertyName, - session.EntityMode); + object uniqueKeyValue = ((IEntityPersister) persister).GetPropertyValue(entity, uniqueKeyPropertyName); uniqueKeyType.NullSafeSet(ps, uniqueKeyValue, 0, session); } diff --git a/src/NHibernate/Impl/AbstractDetachedQuery.cs b/src/NHibernate/Impl/AbstractDetachedQuery.cs index 803f08c4268..3418f4d5952 100644 --- a/src/NHibernate/Impl/AbstractDetachedQuery.cs +++ b/src/NHibernate/Impl/AbstractDetachedQuery.cs @@ -115,7 +115,7 @@ public void SetLockMode(string alias, LockMode lockMode) public IDetachedQuery SetParameter(int position, object val, IType type) { - posParams[position] = new TypedValue(type, val, EntityMode.Poco); + posParams[position] = new TypedValue(type, val); return this; } @@ -123,7 +123,7 @@ public IDetachedQuery SetParameter(string name, object val, IType type) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "Is null or empty."); - namedParams[name] = new TypedValue(type, val, EntityMode.Poco); + namedParams[name] = new TypedValue(type, val); return this; } @@ -145,7 +145,7 @@ public IDetachedQuery SetParameterList(string name, IEnumerable vals, IType type { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "Is null or empty."); - namedListParams[name] = new TypedValue(type, vals, EntityMode.Poco); + namedListParams[name] = new TypedValue(type, vals); return this; } diff --git a/src/NHibernate/Impl/AbstractQueryImpl.cs b/src/NHibernate/Impl/AbstractQueryImpl.cs index 729334b5c50..7679573040e 100644 --- a/src/NHibernate/Impl/AbstractQueryImpl.cs +++ b/src/NHibernate/Impl/AbstractQueryImpl.cs @@ -242,7 +242,7 @@ private string ExpandParameterList(string query, string name, TypedValue typedLi var type = typedList.Type; var typedValues = (from object value in vals - select new TypedValue(type, value, session.EntityMode)) + select new TypedValue(type, value)) .ToList(); if (typedValues.Count == 1) @@ -301,7 +301,7 @@ public IQuery SetParameter(string name, object val, IType type) } else { - namedParameters[name] = new TypedValue(type, val, session.EntityMode); + namedParameters[name] = new TypedValue(type, val); return this; } } @@ -704,7 +704,7 @@ public IQuery SetParameterList(string name, IEnumerable vals, IType type) { throw new QueryException(string.Format("An empty parameter-list generates wrong SQL; parameter name '{0}'", name)); } - namedParameterLists[name] = new TypedValue(type, vals, session.EntityMode); + namedParameterLists[name] = new TypedValue(type, vals); return this; } diff --git a/src/NHibernate/Impl/AbstractSessionImpl.cs b/src/NHibernate/Impl/AbstractSessionImpl.cs index aaa6ad229a9..3cd45907640 100644 --- a/src/NHibernate/Impl/AbstractSessionImpl.cs +++ b/src/NHibernate/Impl/AbstractSessionImpl.cs @@ -75,17 +75,12 @@ public void Initialize() public EntityKey GenerateEntityKey(object id, IEntityPersister persister) { - return GenerateEntityKey(id, persister, EntityMode); - } - - protected EntityKey GenerateEntityKey(object id, IEntityPersister persister, EntityMode entityMode) - { - return new EntityKey(id, persister, entityMode); + return new EntityKey(id, persister); } public CacheKey GenerateCacheKey(object id, IType type, string entityOrRoleName) { - return new CacheKey(id, type, entityOrRoleName, EntityMode, Factory); + return new CacheKey(id, type, entityOrRoleName, Factory); } public ISessionFactoryImplementor Factory @@ -93,7 +88,6 @@ public ISessionFactoryImplementor Factory get { return factory; } protected set { factory = value; } } - public abstract EntityMode EntityMode { get; } public abstract IBatcher Batcher { get; } public abstract void CloseSessionFromDistributedTransaction(); diff --git a/src/NHibernate/Impl/ExpressionQueryImpl.cs b/src/NHibernate/Impl/ExpressionQueryImpl.cs index 12e495d51a4..41ee788d6ae 100644 --- a/src/NHibernate/Impl/ExpressionQueryImpl.cs +++ b/src/NHibernate/Impl/ExpressionQueryImpl.cs @@ -43,7 +43,7 @@ protected override IQueryExpression ExpandParameters(IDictionary filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters, session.EntityMode); + ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters); ISet querySpaces = new HashSet(); List resultTypesList = new List(); diff --git a/src/NHibernate/Impl/MultiQueryImpl.cs b/src/NHibernate/Impl/MultiQueryImpl.cs index a142d29a3ab..895bb42388c 100644 --- a/src/NHibernate/Impl/MultiQueryImpl.cs +++ b/src/NHibernate/Impl/MultiQueryImpl.cs @@ -681,7 +681,7 @@ private IList ListUsingQueryCache() { IQueryCache queryCache = session.Factory.GetQueryCache(cacheRegion); - ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters, session.EntityMode); + ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters); ISet querySpaces = new HashSet(); List resultTypesList = new List(Translators.Count); diff --git a/src/NHibernate/Impl/Printer.cs b/src/NHibernate/Impl/Printer.cs index 093d9626349..0ab4255b84e 100644 --- a/src/NHibernate/Impl/Printer.cs +++ b/src/NHibernate/Impl/Printer.cs @@ -19,9 +19,8 @@ public sealed class Printer /// /// /// an actual entity object, not a proxy! - /// /// - public string ToString(object entity, EntityMode entityMode) + public string ToString(object entity) { IClassMetadata cm = _factory.GetClassMetadata(entity.GetType()); if (cm == null) @@ -34,12 +33,12 @@ public string ToString(object entity, EntityMode entityMode) if (cm.HasIdentifierProperty) { result[cm.IdentifierPropertyName] = - cm.IdentifierType.ToLoggableString(cm.GetIdentifier(entity, entityMode), _factory); + cm.IdentifierType.ToLoggableString(cm.GetIdentifier(entity), _factory); } IType[] types = cm.PropertyTypes; string[] names = cm.PropertyNames; - object[] values = cm.GetPropertyValues(entity, entityMode); + object[] values = cm.GetPropertyValues(entity); for (int i = 0; i < types.Length; i++) { @@ -84,7 +83,7 @@ public string ToString(IDictionary namedTypedValues) return CollectionPrinter.ToString(result); } - public void ToString(IEnumerator enumerator, EntityMode entityMode) + public void ToString(IEnumerator enumerator) { if (!log.IsDebugEnabled || !enumerator.MoveNext()) { @@ -101,7 +100,7 @@ public void ToString(IEnumerator enumerator, EntityMode entityMode) log.Debug("more......"); break; } - log.Debug(ToString(enumerator.Current, entityMode)); + log.Debug(ToString(enumerator.Current)); } while (enumerator.MoveNext()); } diff --git a/src/NHibernate/Impl/SessionFactoryImpl.cs b/src/NHibernate/Impl/SessionFactoryImpl.cs index 32d4ef09edb..daf3c1c6cbb 100644 --- a/src/NHibernate/Impl/SessionFactoryImpl.cs +++ b/src/NHibernate/Impl/SessionFactoryImpl.cs @@ -497,8 +497,7 @@ public ISession OpenSession(DbConnection connection, bool flushBeforeCompletionE #pragma warning restore 618 return - new SessionImpl(connection, this, true, settings.CacheProvider.NextTimestamp(), interceptor, - settings.DefaultEntityMode, flushBeforeCompletionEnabled, autoCloseSessionEnabled, + new SessionImpl(connection, this, true, settings.CacheProvider.NextTimestamp(), interceptor, flushBeforeCompletionEnabled, autoCloseSessionEnabled, isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled, connectionReleaseMode, settings.DefaultFlushMode); } @@ -652,7 +651,7 @@ public string[] GetImplementors(string entityOrClassName) return knownMap; } // NH : take care with this because we are forcing the Poco EntityMode - clazz = checkPersister.GetMappedClass(EntityMode.Poco); + clazz = checkPersister.MappedClass; } if (clazz == null) @@ -713,7 +712,7 @@ public string[] GetImplementors(string entityOrClassName) bool assignableSuperclass; if (q.IsInherited) { - System.Type mappedSuperclass = GetEntityPersister(q.MappedSuperclass).GetMappedClass(EntityMode.Poco); + System.Type mappedSuperclass = GetEntityPersister(q.MappedSuperclass).MappedClass; assignableSuperclass = clazz.IsAssignableFrom(mappedSuperclass); } else @@ -735,7 +734,7 @@ public string[] GetImplementors(string entityOrClassName) private static bool IsMatchingImplementor(string entityOrClassName, System.Type entityClass, IQueryable implementor) { - var implementorClass = implementor.GetMappedClass(EntityMode.Poco); + var implementorClass = implementor.MappedClass; if (implementorClass == null) { return false; @@ -926,7 +925,7 @@ private CacheKey GenerateCacheKeyForEvict(object id, IType type, string entityOr .GenerateCacheKey(id, type, entityOrRoleName); } - return new CacheKey(id, type, entityOrRoleName, EntityMode.Poco, this); + return new CacheKey(id, type, entityOrRoleName, this); } public void EvictCollection(string roleName) @@ -1208,8 +1207,7 @@ private SessionImpl OpenSession(DbConnection connection, bool autoClose, long ti var isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled = settings.IsInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled; #pragma warning restore 618 - SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor, - settings.DefaultEntityMode, settings.IsFlushBeforeCompletionEnabled, + SessionImpl session = new SessionImpl(connection, this, autoClose, timestamp, sessionLocalInterceptor ?? interceptor, settings.IsFlushBeforeCompletionEnabled, settings.IsAutoCloseSessionEnabled, isInterceptorsBeforeTransactionCompletionIgnoreExceptionsEnabled, settings.ConnectionReleaseMode, settings.DefaultFlushMode); diff --git a/src/NHibernate/Impl/SessionImpl.cs b/src/NHibernate/Impl/SessionImpl.cs index 4cef69ec6d8..27a127fd3e1 100644 --- a/src/NHibernate/Impl/SessionImpl.cs +++ b/src/NHibernate/Impl/SessionImpl.cs @@ -47,9 +47,6 @@ public sealed class SessionImpl : AbstractSessionImpl, IEventSource, ISerializab private readonly IInterceptor interceptor; - [NonSerialized] - private readonly EntityMode entityMode = EntityMode.Poco; - [NonSerialized] private FutureCriteriaBatch futureCriteriaBatch; [NonSerialized] @@ -79,7 +76,7 @@ public sealed class SessionImpl : AbstractSessionImpl, IEventSource, ISerializab private readonly ISession rootSession; [NonSerialized] - private IDictionary childSessionsByEntityMode; + ISession _childSession; [NonSerialized] private readonly bool flushBeforeCompletionEnabled; @@ -197,7 +194,6 @@ void IDeserializationCallback.OnDeserialization(object sender) /// NOT USED /// The timestamp for this session /// The interceptor to be applied to this session - /// The entity-mode for this session /// Should we auto flush before completion of transaction /// Should we auto close after completion of transaction /// Should we ignore exceptions in IInterceptor.BeforeTransactionCompletion @@ -209,7 +205,6 @@ internal SessionImpl( bool autoclose, long timestamp, IInterceptor interceptor, - EntityMode entityMode, bool flushBeforeCompletionEnabled, bool autoCloseSessionEnabled, bool ignoreExceptionBeforeTransactionCompletion, @@ -224,7 +219,6 @@ internal SessionImpl( rootSession = null; this.timestamp = timestamp; - this.entityMode = entityMode; this.interceptor = interceptor; listeners = factory.EventListeners; actionQueue = new ActionQueue(this); @@ -255,8 +249,7 @@ internal SessionImpl( /// Constructor used in building "child sessions". /// /// The parent Session - /// The entity mode - private SessionImpl(SessionImpl parent, EntityMode entityMode) + private SessionImpl(SessionImpl parent) : base(parent.Factory, parent.SessionId) { using (new SessionIdLoggingContext(SessionId)) @@ -267,7 +260,6 @@ private SessionImpl(SessionImpl parent, EntityMode entityMode) interceptor = parent.interceptor; listeners = parent.listeners; actionQueue = new ActionQueue(this); - this.entityMode = entityMode; persistenceContext = new StatefulPersistenceContext(this); flushBeforeCompletionEnabled = false; autoCloseSessionEnabled = false; @@ -276,7 +268,7 @@ private SessionImpl(SessionImpl parent, EntityMode entityMode) if (Factory.Statistics.IsStatisticsEnabled) Factory.StatisticsImplementor.OpenSession(); - log.Debug("opened session [" + entityMode + "]"); + log.Debug("Opened session"); CheckAndUpdateSessionStatus(); } @@ -367,14 +359,11 @@ public DbConnection Close() { try { - if (childSessionsByEntityMode != null) + if (_childSession != null) { - foreach (KeyValuePair pair in childSessionsByEntityMode) + if (_childSession.IsOpen) { - if (pair.Value.IsOpen) - { - pair.Value.Close(); - } + _childSession.Close(); } } } @@ -871,10 +860,10 @@ public object Instantiate(IEntityPersister persister, object id) using (new SessionIdLoggingContext(SessionId)) { ErrorIfClosed(); - object result = interceptor.Instantiate(persister.EntityName, entityMode, id); + object result = interceptor.Instantiate(persister.EntityName, id); if (result == null) { - result = persister.Instantiate(id, entityMode); + result = persister.Instantiate(id); } return result; } @@ -2221,45 +2210,24 @@ public ISessionImplementor GetSessionImplementation() return this; } - public ISession GetSession(EntityMode entityMode) + public ISession GetChildSession() { using (new SessionIdLoggingContext(SessionId)) { - // This is explicitly removed to allow support - // for child sessions that want to flush during - // the parent session lifecycle. See NH-1714, - // and the suggested audit examples. - // - //if (this.entityMode.Equals(entityMode)) - //{ - // return this; - //} - if (rootSession != null) { - return rootSession.GetSession(entityMode); + return rootSession.GetChildSession(); } CheckAndUpdateSessionStatus(); - ISession rtn = null; - if (childSessionsByEntityMode == null) - { - childSessionsByEntityMode = new Dictionary(); - } - else + if (_childSession == null) { - childSessionsByEntityMode.TryGetValue(entityMode, out rtn); + log.Debug("Creating child session."); + _childSession = new SessionImpl(this); } - if (rtn == null) - { - log.DebugFormat("Creating child session with {0}", entityMode); - rtn = new SessionImpl(this, entityMode); - childSessionsByEntityMode.Add(entityMode, rtn); - } - - return rtn; + return _childSession; } } @@ -2293,16 +2261,6 @@ public override CacheMode CacheMode } } - public override EntityMode EntityMode - { - get { return entityMode; } - } - - public EntityMode ActiveEntityMode - { - get { return entityMode; } - } - public override string FetchProfile { get { return fetchProfile; } @@ -2628,8 +2586,7 @@ public override IEntityPersister GetEntityPersister(string entityName, object ob // given entityName try { - return Factory.GetEntityPersister(entityName).GetSubclassEntityPersister(obj, Factory, - entityMode); + return Factory.GetEntityPersister(entityName).GetSubclassEntityPersister(obj, Factory); } catch (HibernateException) { diff --git a/src/NHibernate/Impl/StatelessSessionImpl.cs b/src/NHibernate/Impl/StatelessSessionImpl.cs index 4deb6cf6717..0ac8c8cfa0a 100644 --- a/src/NHibernate/Impl/StatelessSessionImpl.cs +++ b/src/NHibernate/Impl/StatelessSessionImpl.cs @@ -71,7 +71,7 @@ public override object InternalLoad(string entityName, object id, bool eager, bo { CheckAndUpdateSessionStatus(); IEntityPersister persister = Factory.GetEntityPersister(entityName); - object loaded = temporaryPersistenceContext.GetEntity(GenerateEntityKey(id, persister, EntityMode.Poco)); + object loaded = temporaryPersistenceContext.GetEntity(GenerateEntityKey(id, persister)); if (loaded != null) { return loaded; @@ -238,7 +238,7 @@ public override object Instantiate(string clazz, object id) using (new SessionIdLoggingContext(SessionId)) { CheckAndUpdateSessionStatus(); - return Factory.GetEntityPersister(clazz).Instantiate(id, EntityMode.Poco); + return Factory.GetEntityPersister(clazz).Instantiate(id); } } @@ -413,11 +413,6 @@ public override CacheMode CacheMode set { throw new NotSupportedException(); } } - public override EntityMode EntityMode - { - get { return NHibernate.EntityMode.Poco; } - } - public override string FetchProfile { get { return null; } @@ -484,7 +479,7 @@ public object Insert(string entityName, object entity) CheckAndUpdateSessionStatus(); IEntityPersister persister = GetEntityPersister(entityName, entity); object id = persister.IdentifierGenerator.Generate(this, entity); - object[] state = persister.GetPropertyValues(entity, EntityMode.Poco); + object[] state = persister.GetPropertyValues(entity); if (persister.IsVersioned) { object versionValue = state[persister.VersionProperty]; @@ -492,7 +487,7 @@ public object Insert(string entityName, object entity) persister.IsUnsavedVersion(versionValue), this); if (substitute) { - persister.SetPropertyValues(entity, state, EntityMode.Poco); + persister.SetPropertyValues(entity, state); } } if (id == IdentifierGeneratorFactory.PostInsertIndicator) @@ -503,7 +498,7 @@ public object Insert(string entityName, object entity) { persister.Insert(id, state, entity, this); } - persister.SetIdentifier(entity, id, EntityMode.Poco); + persister.SetIdentifier(entity, id); return id; } } @@ -528,15 +523,15 @@ public void Update(string entityName, object entity) { CheckAndUpdateSessionStatus(); IEntityPersister persister = GetEntityPersister(entityName, entity); - object id = persister.GetIdentifier(entity, EntityMode.Poco); - object[] state = persister.GetPropertyValues(entity, EntityMode.Poco); + object id = persister.GetIdentifier(entity); + object[] state = persister.GetPropertyValues(entity); object oldVersion; if (persister.IsVersioned) { - oldVersion = persister.GetVersion(entity, EntityMode.Poco); + oldVersion = persister.GetVersion(entity); object newVersion = Versioning.Increment(oldVersion, persister.VersionType, this); Versioning.SetVersion(state, newVersion, persister); - persister.SetPropertyValues(entity, state, EntityMode.Poco); + persister.SetPropertyValues(entity, state); } else { @@ -566,8 +561,8 @@ public void Delete(string entityName, object entity) { CheckAndUpdateSessionStatus(); IEntityPersister persister = GetEntityPersister(entityName, entity); - object id = persister.GetIdentifier(entity, EntityMode.Poco); - object version = persister.GetVersion(entity, EntityMode.Poco); + object id = persister.GetIdentifier(entity); + object version = persister.GetVersion(entity); persister.Delete(id, version, entity, this); } } @@ -682,7 +677,7 @@ public void Refresh(string entityName, object entity, LockMode lockMode) using (new SessionIdLoggingContext(SessionId)) { IEntityPersister persister = GetEntityPersister(entityName, entity); - object id = persister.GetIdentifier(entity, EntityMode); + object id = persister.GetIdentifier(entity); if (log.IsDebugEnabled) { log.Debug("refreshing transient " + MessageHelper.InfoString(persister, id, Factory)); @@ -969,7 +964,7 @@ public override IEntityPersister GetEntityPersister(string entityName, object ob } else { - return Factory.GetEntityPersister(entityName).GetSubclassEntityPersister(obj, Factory, EntityMode.Poco); + return Factory.GetEntityPersister(entityName).GetSubclassEntityPersister(obj, Factory); } } } diff --git a/src/NHibernate/Loader/Collection/CollectionLoader.cs b/src/NHibernate/Loader/Collection/CollectionLoader.cs index 19f433edac3..ca940ea5ba3 100644 --- a/src/NHibernate/Loader/Collection/CollectionLoader.cs +++ b/src/NHibernate/Loader/Collection/CollectionLoader.cs @@ -92,7 +92,7 @@ protected SqlString GetSubSelectWithLimits(SqlString subquery, ICollection queryNamedParameters = CollectedParameters.ToDictionary(np => np.Name, np => new TypedValue(np.Type, np.Value, EntityMode.Poco)); + IDictionary queryNamedParameters = CollectedParameters.ToDictionary(np => np.Name, np => new TypedValue(np.Type, np.Value)); return new QueryParameters( @@ -581,7 +581,7 @@ public IType GetIdentifierType(ICriteria subcriteria) public TypedValue GetTypedIdentifierValue(ICriteria subcriteria, object value) { NHibernate_Persister_Entity.ILoadable loadable = (NHibernate_Persister_Entity.ILoadable)GetPropertyMapping(GetEntityName(subcriteria)); - return new TypedValue(loadable.IdentifierType, value, EntityMode.Poco); + return new TypedValue(loadable.IdentifierType, value); } public string[] GetColumns(ICriteria subcriteria, string propertyName) @@ -651,11 +651,11 @@ public TypedValue GetTypedValue(ICriteria subcriteria, string propertyName, obje if (q != null && q.DiscriminatorValue != null) { // NH Different implementation : We are using strongly typed parameter for SQL query (see DiscriminatorValue comment) - return new TypedValue(q.DiscriminatorType, q.DiscriminatorValue, EntityMode.Poco); + return new TypedValue(q.DiscriminatorType, q.DiscriminatorValue); } } // Otherwise, this is an ordinary value. - return new TypedValue(GetTypeUsingProjection(subcriteria, propertyName), value, EntityMode.Poco); + return new TypedValue(GetTypeUsingProjection(subcriteria, propertyName), value); } private Persister.Entity.IPropertyMapping GetPropertyMapping(string entityName) @@ -764,13 +764,13 @@ public ICollection CollectedParameters public Parameter CreateSkipParameter(int value) { - var typedValue = new TypedValue(NHibernateUtil.Int32, value, EntityMode.Poco); + var typedValue = new TypedValue(NHibernateUtil.Int32, value); return NewQueryParameter("skip_", typedValue).Single(); } public Parameter CreateTakeParameter(int value) { - var typedValue = new TypedValue(NHibernateUtil.Int32, value, EntityMode.Poco); + var typedValue = new TypedValue(NHibernateUtil.Int32, value); return NewQueryParameter("take_",typedValue).Single(); } diff --git a/src/NHibernate/Loader/Entity/BatchingEntityLoader.cs b/src/NHibernate/Loader/Entity/BatchingEntityLoader.cs index 7c93a769e97..1bd11b8faa7 100644 --- a/src/NHibernate/Loader/Entity/BatchingEntityLoader.cs +++ b/src/NHibernate/Loader/Entity/BatchingEntityLoader.cs @@ -33,7 +33,7 @@ private object GetObjectFromList(IList results, object id, ISessionImplementor s // get the right object from the list ... would it be easier to just call getEntity() ?? foreach (object obj in results) { - bool equal = idType.IsEqual(id, session.GetContextEntityIdentifier(obj), session.EntityMode, session.Factory); + bool equal = idType.IsEqual(id, session.GetContextEntityIdentifier(obj), session.Factory); if (equal) { diff --git a/src/NHibernate/Loader/Loader.cs b/src/NHibernate/Loader/Loader.cs index 5baefdf843e..f5ddeb2834a 100644 --- a/src/NHibernate/Loader/Loader.cs +++ b/src/NHibernate/Loader/Loader.cs @@ -851,7 +851,7 @@ private EntityKey GetKeyFromResultSet(int i, IEntityPersister persister, object IType idType = persister.IdentifierType; resultId = idType.NullSafeGet(rs, EntityAliases[i].SuffixedKeyAliases, session, null); - bool idIsResultId = id != null && resultId != null && idType.IsEqual(id, resultId, session.EntityMode, _factory); + bool idIsResultId = id != null && resultId != null && idType.IsEqual(id, resultId, _factory); if (idIsResultId) { @@ -950,7 +950,7 @@ private object[] GetRow(DbDataReader rs, ILoadable[] persisters, EntityKey[] key private void InstanceAlreadyLoaded(DbDataReader rs, int i, IEntityPersister persister, EntityKey key, object obj, LockMode lockMode, ISessionImplementor session) { - if (!persister.IsInstance(obj, session.EntityMode)) + if (!persister.IsInstance(obj)) { string errorMsg = string.Format("loading object was of wrong class [{0}]", obj.GetType().FullName); throw new WrongClassException(errorMsg, key.Identifier, persister.EntityName); @@ -1065,8 +1065,7 @@ private void LoadFromResultSet(DbDataReader rs, int i, object obj, string instan // the one used here, which it will be EntityUniqueKey euk = - new EntityUniqueKey(rootPersister.EntityName, ukName, type.SemiResolve(values[index], session, obj), type, - session.EntityMode, session.Factory); + new EntityUniqueKey(rootPersister.EntityName, ukName, type.SemiResolve(values[index], session, obj), type, session.Factory); session.PersistenceContext.AddEntity(euk, obj); } } @@ -1566,7 +1565,7 @@ private IList ListUsingQueryCache(ISessionImplementor session, QueryParameters q private QueryKey GenerateQueryKey(ISessionImplementor session, QueryParameters queryParameters) { - ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters, session.EntityMode); + ISet filterKeys = FilterKey.CreateFilterKeys(session.EnabledFilters); return new QueryKey(Factory, SqlString, queryParameters, filterKeys, CreateCacheableResultTransformer(queryParameters)); } diff --git a/src/NHibernate/Mapping/Component.cs b/src/NHibernate/Mapping/Component.cs index 5b4a24901f0..3c854925f9c 100644 --- a/src/NHibernate/Mapping/Component.cs +++ b/src/NHibernate/Mapping/Component.cs @@ -263,21 +263,15 @@ public virtual void AddTuplizer(EntityMode entityMode, string implClassName) public virtual string GetTuplizerImplClassName(EntityMode mode) { - // todo : remove this once ComponentMetamodel is complete and merged - if (tuplizerImpls == null) - { - return null; - } - return tuplizerImpls[mode]; + string result = null; + tuplizerImpls?.TryGetValue(mode, out result); + return result; } public virtual IDictionary TuplizerMap { get { - if (tuplizerImpls == null) - return null; - return tuplizerImpls; } } diff --git a/src/NHibernate/Mapping/PersistentClass.cs b/src/NHibernate/Mapping/PersistentClass.cs index d6f938cb8dc..11248ffe4d0 100644 --- a/src/NHibernate/Mapping/PersistentClass.cs +++ b/src/NHibernate/Mapping/PersistentClass.cs @@ -1162,10 +1162,8 @@ public void AddTuplizer(EntityMode entityMode, string implClass) public virtual string GetTuplizerImplClassName(EntityMode mode) { - if (tuplizerImpls == null) - return null; - string result; - tuplizerImpls.TryGetValue(mode, out result); + string result = null; + tuplizerImpls?.TryGetValue(mode, out result); return result; } diff --git a/src/NHibernate/Mapping/Property.cs b/src/NHibernate/Mapping/Property.cs index 81c6028e175..e77a7e48e42 100644 --- a/src/NHibernate/Mapping/Property.cs +++ b/src/NHibernate/Mapping/Property.cs @@ -187,11 +187,6 @@ protected virtual IPropertyAccessor PropertyAccessor get { return PropertyAccessorFactory.GetPropertyAccessor(PropertyAccessorName); } } - public virtual string GetAccessorPropertyName(EntityMode mode) - { - return mode == EntityMode.Xml ? nodeName : Name; - } - public virtual bool IsBasicPropertyAccessor { // NH Different behavior : see IPropertyAccessor.CanAccessThroughReflectionOptimizer (ref. NH-1304) diff --git a/src/NHibernate/Metadata/IClassMetadata.cs b/src/NHibernate/Metadata/IClassMetadata.cs index 969eb1d7315..32367ce3ae2 100644 --- a/src/NHibernate/Metadata/IClassMetadata.cs +++ b/src/NHibernate/Metadata/IClassMetadata.cs @@ -95,55 +95,54 @@ public interface IClassMetadata /// /// The persistent class /// - System.Type GetMappedClass(EntityMode entityMode); + System.Type MappedClass { get; } /// /// Create a class instance initialized with the given identifier /// - object Instantiate(object id, EntityMode entityMode); + object Instantiate(object id); /// /// Get the value of a particular (named) property /// - object GetPropertyValue(object obj, string propertyName, EntityMode entityMode); + object GetPropertyValue(object obj, string propertyName); /// Extract the property values from the given entity. /// The entity from which to extract the property values. - /// The entity-mode of the given entity /// The property values. - object[] GetPropertyValues(object entity, EntityMode entityMode); + object[] GetPropertyValues(object entity); /// /// Set the value of a particular (named) property /// - void SetPropertyValue(object obj, string propertyName, object value, EntityMode entityMode); + void SetPropertyValue(object obj, string propertyName, object value); /// /// Set the given values to the mapped properties of the given object /// - void SetPropertyValues(object entity, object[] values, EntityMode entityMode); + void SetPropertyValues(object entity, object[] values); /// /// Get the identifier of an instance (throw an exception if no identifier property) /// - object GetIdentifier(object entity, EntityMode entityMode); + object GetIdentifier(object entity); /// /// Set the identifier of an instance (or do nothing if no identifier property) /// - void SetIdentifier(object entity, object id, EntityMode entityMode); + void SetIdentifier(object entity, object id); /// Does the class implement the interface? - bool ImplementsLifecycle(EntityMode entityMode); + bool ImplementsLifecycle { get; } /// Does the class implement the interface? - bool ImplementsValidatable(EntityMode entityMode); + bool ImplementsValidatable { get; } /// /// Get the version number (or timestamp) from the object's version property /// (or return null if not versioned) /// - object GetVersion(object obj, EntityMode entityMode); + object GetVersion(object obj); #endregion } diff --git a/src/NHibernate/NHibernate.csproj b/src/NHibernate/NHibernate.csproj index b46410523eb..c25e725fff8 100644 --- a/src/NHibernate/NHibernate.csproj +++ b/src/NHibernate/NHibernate.csproj @@ -922,7 +922,6 @@ - @@ -1714,16 +1713,15 @@ - + - - + @@ -1785,7 +1783,6 @@ - diff --git a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs index 6eee9c6bbe0..bc5f7acdf8f 100644 --- a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs +++ b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs @@ -228,7 +228,7 @@ public string ToLoggableString(object value, ISessionFactoryImplementor factory) throw new InvalidOperationException(); } - public object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImplementor factory) + public object DeepCopy(object val, ISessionFactoryImplementor factory) { throw new InvalidOperationException(); } @@ -258,32 +258,32 @@ public object Replace(object original, object target, ISessionImplementor sessio throw new InvalidOperationException(); } - public bool IsSame(object x, object y, EntityMode entityMode) + public bool IsSame(object x, object y) { return false; } - public bool IsEqual(object x, object y, EntityMode entityMode) + public bool IsEqual(object x, object y) { return false; } - public bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory) + public bool IsEqual(object x, object y, ISessionFactoryImplementor factory) { return false; } - public int GetHashCode(object x, EntityMode entityMode) + public int GetHashCode(object x) { return GetHashCode(); } - public int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory) + public int GetHashCode(object x, ISessionFactoryImplementor factory) { return GetHashCode(); } - public int Compare(object x, object y, EntityMode? entityMode) + public int Compare(object x, object y) { return 1; } diff --git a/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs b/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs index c0b98bb0eeb..69e0df18f47 100644 --- a/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs +++ b/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs @@ -332,7 +332,7 @@ protected AbstractEntityPersister(PersistentClass persistentClass, ICacheConcurr #region PROPERTIES // NH: see consistence with the implementation on EntityMetamodel where we are disabling lazy-properties for no lazy entities - bool lazyAvailable = IsInstrumented(EntityMode.Poco) && entityMetamodel.IsLazy; + bool lazyAvailable = IsInstrumented && entityMetamodel.IsLazy; int hydrateSpan = entityMetamodel.PropertySpan; propertyColumnSpans = new int[hydrateSpan]; @@ -1028,7 +1028,7 @@ protected virtual object GetJoinTableId(int j, object[] fields) return null; } - protected virtual object GetJoinTableId(int table, object obj, EntityMode entityMode) + protected virtual object GetJoinTableId(int table, object obj) { return null; } @@ -1353,11 +1353,11 @@ private object InitializeLazyPropertiesFromCache(string fieldName, object entity private bool InitializeLazyProperty(string fieldName, object entity, ISessionImplementor session, object[] snapshot, int j, object propValue) { - SetPropertyValue(entity, lazyPropertyNumbers[j], propValue, session.EntityMode); + SetPropertyValue(entity, lazyPropertyNumbers[j], propValue); if (snapshot != null) { // object have been loaded with setReadOnly(true); HHH-2236 - snapshot[lazyPropertyNumbers[j]] = lazyPropertyTypes[j].DeepCopy(propValue, session.EntityMode, factory); + snapshot[lazyPropertyNumbers[j]] = lazyPropertyTypes[j].DeepCopy(propValue, factory); } return fieldName.Equals(lazyPropertyNames[j]); } @@ -2879,7 +2879,7 @@ public void Delete(object id, object version, int j, object obj, SqlCommandInfo object[] loadedState) { //check if the id should come from another column - object tableId = GetJoinTableId(j, obj, session.EntityMode) ?? id; + object tableId = GetJoinTableId(j, obj) ?? id; if (IsInverseTable(j)) { @@ -3050,8 +3050,8 @@ public void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyC else { // For the case of dynamic-update="false", or no snapshot, we use the static SQL - updateStrings = GetUpdateStrings(rowId != null, HasUninitializedLazyProperties(obj, session.EntityMode)); - propsToUpdate = GetPropertyUpdateability(obj, session.EntityMode); + updateStrings = GetUpdateStrings(rowId != null, HasUninitializedLazyProperties(obj)); + propsToUpdate = GetPropertyUpdateability(obj); } for (int j = 0; j < span; j++) @@ -3676,7 +3676,7 @@ protected bool[] GetPropertiesToInsert(object[] fields) public virtual int[] FindDirty(object[] currentState, object[] previousState, object entity, ISessionImplementor session) { int[] props = TypeHelper.FindDirty( - entityMetamodel.Properties, currentState, previousState, propertyColumnUpdateable, HasUninitializedLazyProperties(entity, session.EntityMode), session); + entityMetamodel.Properties, currentState, previousState, propertyColumnUpdateable, HasUninitializedLazyProperties(entity), session); if (props == null) { @@ -3692,7 +3692,7 @@ public virtual int[] FindDirty(object[] currentState, object[] previousState, ob public virtual int[] FindModified(object[] old, object[] current, object entity, ISessionImplementor session) { int[] props = TypeHelper.FindModified( - entityMetamodel.Properties, current, old, propertyColumnUpdateable, HasUninitializedLazyProperties(entity, session.EntityMode), session); + entityMetamodel.Properties, current, old, propertyColumnUpdateable, HasUninitializedLazyProperties(entity), session); if (props == null) { return null; @@ -3705,9 +3705,9 @@ public virtual int[] FindModified(object[] old, object[] current, object entity, } /// Which properties appear in the SQL update? (Initialized, updateable ones!) - protected bool[] GetPropertyUpdateability(object entity, EntityMode entityMode) + protected bool[] GetPropertyUpdateability(object entity) { - return HasUninitializedLazyProperties(entity, entityMode) ? NonLazyPropertyUpdateability : PropertyUpdateability; + return HasUninitializedLazyProperties(entity) ? NonLazyPropertyUpdateability : PropertyUpdateability; } private void LogDirtyProperties(int[] props) @@ -3724,13 +3724,9 @@ private void LogDirtyProperties(int[] props) protected internal IEntityTuplizer GetTuplizer(ISessionImplementor session) { - return GetTuplizer(session.EntityMode); + return EntityTuplizer; } - protected internal IEntityTuplizer GetTuplizer(EntityMode entityMode) - { - return entityMetamodel.GetTuplizer(entityMode); - } public virtual bool HasCache { @@ -3775,7 +3771,7 @@ public virtual void AfterReassociate(object entity, ISessionImplementor session) } else { - IFieldInterceptor fieldInterceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, GetMappedClass(session.EntityMode), null, null, session); + IFieldInterceptor fieldInterceptor = FieldInterceptionHelper.InjectFieldInterceptor(entity, EntityName, MappedClass, null, null, session); fieldInterceptor.MarkDirty(); } } @@ -3786,7 +3782,7 @@ public virtual void AfterReassociate(object entity, ISessionImplementor session) object id; if (CanExtractIdOutOfEntity) { - id = GetIdentifier(entity, session.EntityMode); + id = GetIdentifier(entity); } else { @@ -3820,7 +3816,7 @@ public virtual void AfterReassociate(object entity, ISessionImplementor session) // check the version unsaved-value, if appropriate if (IsVersioned) { - object version = GetVersion(entity, session.EntityMode); + object version = GetVersion(entity); bool? result = entityMetamodel.VersionProperty.UnsavedValue.IsUnsaved(version); if (result.HasValue) { @@ -3911,7 +3907,7 @@ protected Versioning.OptimisticLock OptimisticLockMode public object CreateProxy(object id, ISessionImplementor session) { - return entityMetamodel.GetTuplizer(session.EntityMode).CreateProxy(id, session); + return entityMetamodel.Tuplizer.CreateProxy(id, session); } public override string ToString() @@ -3925,10 +3921,9 @@ public string SelectFragment(IJoinable rhs, string rhsAlias, string lhsAlias, return SelectFragment(lhsAlias, entitySuffix); } - public bool IsInstrumented(EntityMode entityMode) + public bool IsInstrumented { - IEntityTuplizer tuplizer = entityMetamodel.GetTuplizerOrNull(entityMode); - return tuplizer != null && tuplizer.IsInstrumented; + get { return EntityTuplizer.IsInstrumented; } } public bool HasInsertGeneratedProperties @@ -3943,7 +3938,7 @@ public bool HasUpdateGeneratedProperties public void AfterInitialize(object entity, bool lazyPropertiesAreUnfetched, ISessionImplementor session) { - GetTuplizer(session).AfterInitialize(entity, lazyPropertiesAreUnfetched, session); + EntityTuplizer.AfterInitialize(entity, lazyPropertiesAreUnfetched, session); } public virtual bool[] PropertyUpdateability @@ -3951,70 +3946,69 @@ public virtual bool[] PropertyUpdateability get { return entityMetamodel.PropertyUpdateability; } } - public System.Type GetMappedClass(EntityMode entityMode) + public System.Type MappedClass { - ITuplizer tup = entityMetamodel.GetTuplizerOrNull(entityMode); - return tup == null ? null : tup.MappedClass; + get { return EntityTuplizer.MappedClass; } } - public bool ImplementsLifecycle(EntityMode entityMode) + public bool ImplementsLifecycle { - return GetTuplizer(entityMode).IsLifecycleImplementor; + get { return EntityTuplizer.IsLifecycleImplementor; } } - public bool ImplementsValidatable(EntityMode entityMode) + public bool ImplementsValidatable { - return GetTuplizer(entityMode).IsValidatableImplementor; + get { return EntityTuplizer.IsValidatableImplementor; } } - public System.Type GetConcreteProxyClass(EntityMode entityMode) + public System.Type ConcreteProxyClass { - return GetTuplizer(entityMode).ConcreteProxyClass; + get { return EntityTuplizer.ConcreteProxyClass; } } - public void SetPropertyValues(object obj, object[] values, EntityMode entityMode) + public void SetPropertyValues(object obj, object[] values) { - GetTuplizer(entityMode).SetPropertyValues(obj, values); + EntityTuplizer.SetPropertyValues(obj, values); } - public void SetPropertyValue(object obj, int i, object value, EntityMode entityMode) + public void SetPropertyValue(object obj, int i, object value) { - GetTuplizer(entityMode).SetPropertyValue(obj, i, value); + EntityTuplizer.SetPropertyValue(obj, i, value); } - public object[] GetPropertyValues(object obj, EntityMode entityMode) + public object[] GetPropertyValues(object obj) { - return GetTuplizer(entityMode).GetPropertyValues(obj); + return EntityTuplizer.GetPropertyValues(obj); } - public object GetPropertyValue(object obj, int i, EntityMode entityMode) + public object GetPropertyValue(object obj, int i) { - return GetTuplizer(entityMode).GetPropertyValue(obj, i); + return EntityTuplizer.GetPropertyValue(obj, i); } - public object GetPropertyValue(object obj, string propertyName, EntityMode entityMode) + public object GetPropertyValue(object obj, string propertyName) { - return GetTuplizer(entityMode).GetPropertyValue(obj, propertyName); + return EntityTuplizer.GetPropertyValue(obj, propertyName); } - public virtual object GetIdentifier(object obj, EntityMode entityMode) + public virtual object GetIdentifier(object obj) { - return GetTuplizer(entityMode).GetIdentifier(obj); + return EntityTuplizer.GetIdentifier(obj); } - public virtual void SetIdentifier(object obj, object id, EntityMode entityMode) + public virtual void SetIdentifier(object obj, object id) { - GetTuplizer(entityMode).SetIdentifier(obj, id); + EntityTuplizer.SetIdentifier(obj, id); } - public virtual object GetVersion(object obj, EntityMode entityMode) + public virtual object GetVersion(object obj) { - return GetTuplizer(entityMode).GetVersion(obj); + return EntityTuplizer.GetVersion(obj); } - public virtual object Instantiate(object id, EntityMode entityMode) + public virtual object Instantiate(object id) { - return GetTuplizer(entityMode).Instantiate(id); + return EntityTuplizer.Instantiate(id); } /// @@ -4022,27 +4016,25 @@ public virtual object Instantiate(object id, EntityMode entityMode) /// managed by this persister. /// /// The entity. - /// The entity mode. /// /// if the specified entity is an instance; otherwise, . /// - public bool IsInstance(object entity, EntityMode entityMode) + public bool IsInstance(object entity) { - return GetTuplizer(entityMode).IsInstance(entity); + return EntityTuplizer.IsInstance(entity); } - public virtual bool HasUninitializedLazyProperties(object obj, EntityMode entityMode) + public virtual bool HasUninitializedLazyProperties(object obj) { - return GetTuplizer(entityMode).HasUninitializedLazyProperties(obj); + return EntityTuplizer.HasUninitializedLazyProperties(obj); } - public virtual void ResetIdentifier(object entity, object currentId, object currentVersion, EntityMode entityMode) + public virtual void ResetIdentifier(object entity, object currentId, object currentVersion) { - GetTuplizer(entityMode).ResetIdentifier(entity, currentId, currentVersion); + EntityTuplizer.ResetIdentifier(entity, currentId, currentVersion); } - public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory, - EntityMode entityMode) + public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory) { if (!HasSubclasses) { @@ -4051,7 +4043,7 @@ public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFact // TODO : really need a way to do something like : // getTuplizer(entityMode).determineConcreteSubclassEntityName(instance) var clazz = instance.GetType(); - if (clazz == GetMappedClass(entityMode)) + if (clazz == MappedClass) { return this; } @@ -4063,14 +4055,9 @@ public IEntityPersister GetSubclassEntityPersister(object instance, ISessionFact return factory.GetEntityPersister(subclassEntityName); } - public virtual EntityMode? GuessEntityMode(object obj) - { - return entityMetamodel.GuessEntityMode(obj); - } - public virtual object[] GetPropertyValuesToInsert(object obj, IDictionary mergeMap, ISessionImplementor session) { - return GetTuplizer(session.EntityMode).GetPropertyValuesToInsert(obj, mergeMap, session); + return EntityTuplizer.GetPropertyValuesToInsert(obj, mergeMap, session); } public void ProcessInsertGeneratedProperties(object id, object entity, object[] state, ISessionImplementor session) @@ -4143,7 +4130,7 @@ private void ProcessGeneratedPropertiesWithGeneratedSql(object id, object entity { object hydratedState = PropertyTypes[i].Hydrate(rs, GetPropertyAliases(string.Empty, i), session, entity); state[i] = PropertyTypes[i].ResolveIdentifier(hydratedState, session, entity); - SetPropertyValue(entity, i, state[i], session.EntityMode); + SetPropertyValue(entity, i, state[i]); } } } @@ -4291,11 +4278,15 @@ public virtual bool HasNaturalIdentifier get { return entityMetamodel.HasNaturalIdentifier; } } - public virtual void SetPropertyValue(object obj, string propertyName, object value, EntityMode entityMode) + public virtual void SetPropertyValue(object obj, string propertyName, object value) { - GetTuplizer(entityMode).SetPropertyValue(obj, propertyName, value); + EntityTuplizer.SetPropertyValue(obj, propertyName, value); } + public EntityMode EntityMode => entityMetamodel.EntityMode; + + public IEntityTuplizer EntityTuplizer => entityMetamodel.Tuplizer; + public abstract string GetPropertyTableName(string propertyName); public abstract string FromTableFragment(string alias); public abstract string GetSubclassForDiscriminatorValue(object value); diff --git a/src/NHibernate/Persister/Entity/IEntityPersister.cs b/src/NHibernate/Persister/Entity/IEntityPersister.cs index 9aabd1ce0d9..73beddf637b 100644 --- a/src/NHibernate/Persister/Entity/IEntityPersister.cs +++ b/src/NHibernate/Persister/Entity/IEntityPersister.cs @@ -33,18 +33,18 @@ public interface IEntityPersister : IOptimisticCacheSource /// Returns an object that identifies the space in which identifiers of /// this entity hierarchy are unique. /// - string RootEntityName { get;} + string RootEntityName { get; } /// /// The entity name which this persister maps. /// - string EntityName { get;} + string EntityName { get; } /// /// Retrieve the underlying entity metamodel instance... /// /// The metamodel - EntityMetamodel EntityMetamodel { get;} + EntityMetamodel EntityMetamodel { get; } /// /// Returns an array of objects that identify spaces in which properties of @@ -79,7 +79,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// In other words, is this entity a subclass of other entities. /// /// True if other entities extend this entity; false otherwise. - bool IsInherited { get;} + bool IsInherited { get; } /// /// Is the identifier assigned before the insert by an IDGenerator or is it returned @@ -113,7 +113,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// The indices of the properties making of the natural id; or /// null, if no natural id is defined. /// - int[] NaturalIdentifierProperties { get;} + int[] NaturalIdentifierProperties { get; } /// /// Return the IIdentifierGenerator for the class @@ -141,10 +141,10 @@ public interface IEntityPersister : IOptimisticCacheSource bool[] PropertyInsertability { get; } /// Which of the properties of this class are database generated values on insert? - ValueInclusion[] PropertyInsertGenerationInclusions { get;} + ValueInclusion[] PropertyInsertGenerationInclusions { get; } /// Which of the properties of this class are database generated values on update? - ValueInclusion[] PropertyUpdateGenerationInclusions { get;} + ValueInclusion[] PropertyUpdateGenerationInclusions { get; } /// /// Properties that may be dirty (and thus should be dirty-checked). These @@ -163,7 +163,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// if the property is optimistic-locked; otherwise, . bool[] PropertyVersionability { get; } - bool[] PropertyLaziness { get;} + bool[] PropertyLaziness { get; } /// /// Get the cascade styles of the properties (optional operation) @@ -189,7 +189,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// /// Should lazy properties of this entity be cached? /// - bool IsLazyPropertiesCacheable { get;} + bool IsLazyPropertiesCacheable { get; } /// /// Get the cache (optional operation) @@ -197,7 +197,7 @@ public interface IEntityPersister : IOptimisticCacheSource ICacheConcurrencyStrategy Cache { get; } /// Get the cache structure - ICacheEntryStructure CacheEntryStructure { get;} + ICacheEntryStructure CacheEntryStructure { get; } /// /// Get the user-visible metadata for the class (optional operation) @@ -253,7 +253,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// /// True if any properties of the entity are mutable; false otherwise (meaning none are). /// - bool HasMutableProperties { get;} + bool HasMutableProperties { get; } /// /// Determine whether this entity contains references to persistent collections @@ -262,7 +262,7 @@ public interface IEntityPersister : IOptimisticCacheSource /// /// True if the entity contains collections fetchable by subselect; false otherwise. /// - bool HasSubselectLoadableCollections { get;} + bool HasSubselectLoadableCollections { get; } /// /// Does this class declare any cascading save/update/deletes? @@ -375,8 +375,16 @@ public interface IEntityPersister : IOptimisticCacheSource /// The obj. /// The rowId /// The session. - void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyCollection, object[] oldFields, - object oldVersion, object obj, object rowId, ISessionImplementor session); + void Update( + object id, + object[] fields, + int[] dirtyFields, + bool hasDirtyCollection, + object[] oldFields, + object oldVersion, + object obj, + object rowId, + ISessionImplementor session); /// /// Gets if the Property is updatable @@ -412,11 +420,8 @@ void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyCollecti object ForceVersionIncrement(object id, object currentVersion, ISessionImplementor session); - /// Try to discover the entity mode from the entity instance - EntityMode? GuessEntityMode(object obj); - /// Has the class actually been bytecode instrumented? - bool IsInstrumented(EntityMode entityMode); + bool IsInstrumented { get; } /// /// Does this entity define any properties as being database-generated on insert? @@ -491,93 +496,91 @@ void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyCollecti /// /// The persistent class, or null /// - System.Type GetMappedClass(EntityMode entityMode); + System.Type MappedClass { get; } /// /// Does the class implement the ILifecycle inteface? /// - bool ImplementsLifecycle(EntityMode entityMode); + bool ImplementsLifecycle { get; } /// /// Does the class implement the IValidatable interface? /// - bool ImplementsValidatable(EntityMode entityMode); + bool ImplementsValidatable { get; } /// /// Get the proxy interface that instances of this concrete class will be cast to /// - System.Type GetConcreteProxyClass(EntityMode entityMode); + System.Type ConcreteProxyClass { get; } /// /// Set the given values to the mapped properties of the given object /// - void SetPropertyValues(object obj, object[] values, EntityMode entityMode); + void SetPropertyValues(object obj, object[] values); /// /// Set the value of a particular property /// - void SetPropertyValue(object obj, int i, object value, EntityMode entityMode); + void SetPropertyValue(object obj, int i, object value); /// /// Return the values of the mapped properties of the object /// - object[] GetPropertyValues(object obj, EntityMode entityMode); + object[] GetPropertyValues(object obj); /// /// Get the value of a particular property /// - object GetPropertyValue(object obj, int i, EntityMode entityMode); + object GetPropertyValue(object obj, int i); /// /// Get the value of a particular property /// - object GetPropertyValue(object obj, string name, EntityMode entityMode); + object GetPropertyValue(object obj, string name); /// /// Get the identifier of an instance ( throw an exception if no identifier property) /// - object GetIdentifier(object obj, EntityMode entityMode); + object GetIdentifier(object obj); /// /// Set the identifier of an instance (or do nothing if no identifier property) /// /// The object to set the Id property on. /// The value to set the Id property to. - /// The EntityMode - void SetIdentifier(object obj, object id, EntityMode entityMode); + void SetIdentifier(object obj, object id); /// /// Get the version number (or timestamp) from the object's version property (or return null if not versioned) /// - object GetVersion(object obj, EntityMode entityMode); + object GetVersion(object obj); /// /// Create a class instance initialized with the given identifier /// - object Instantiate(object id, EntityMode entityMode); + object Instantiate(object id); /// /// Determines whether the specified entity is an instance of the class /// managed by this persister. /// /// The entity. - /// The EntityMode /// /// if the specified entity is an instance; otherwise, . /// - bool IsInstance(object entity, EntityMode entityMode); + bool IsInstance(object entity); /// Does the given instance have any uninitialized lazy properties? - bool HasUninitializedLazyProperties(object obj, EntityMode entityMode); + bool HasUninitializedLazyProperties(object obj); /// /// Set the identifier and version of the given instance back /// to its "unsaved" value, returning the id /// - void ResetIdentifier(object entity, object currentId, object currentVersion, EntityMode entityMode); + void ResetIdentifier(object entity, object currentId, object currentVersion); /// Get the persister for an instance of this class or a subclass - IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory, EntityMode entityMode); + IEntityPersister GetSubclassEntityPersister(object instance, ISessionFactoryImplementor factory); #endregion @@ -588,5 +591,12 @@ void Update(object id, object[] fields, int[] dirtyFields, bool hasDirtyCollecti /// The result of . /// NHibernate-specific feature, not present in H3.2 bool? IsUnsavedVersion(object version); + + /// + /// Gets EntityMode. + /// + EntityMode EntityMode { get; } + + IEntityTuplizer EntityTuplizer { get; } } } diff --git a/src/NHibernate/Persister/Entity/SingleTableEntityPersister.cs b/src/NHibernate/Persister/Entity/SingleTableEntityPersister.cs index 7ce36aaa03f..8076890f308 100644 --- a/src/NHibernate/Persister/Entity/SingleTableEntityPersister.cs +++ b/src/NHibernate/Persister/Entity/SingleTableEntityPersister.cs @@ -163,7 +163,7 @@ public SingleTableEntityPersister(PersistentClass persistentClass, ICacheConcurr spaces = qualifiedTableNames.Concat(persistentClass.SynchronizedTables).ToArray(); - bool lazyAvailable = IsInstrumented(EntityMode.Poco); + bool lazyAvailable = IsInstrumented; bool hasDeferred = false; List subclassTables = new List(); @@ -534,7 +534,7 @@ protected override bool IsTableCascadeDeleteEnabled(int j) return cascadeDeleteEnabled[j]; } - protected override object GetJoinTableId(int table, object obj, EntityMode entityMode) + protected override object GetJoinTableId(int table, object obj) { //0 is the base table there is no join if (table == 0) @@ -545,7 +545,7 @@ protected override object GetJoinTableId(int table, object obj, EntityMode entit if (refIdColumn == null) return null; - object[] fields = GetPropertyValues(obj, entityMode); + object[] fields = GetPropertyValues(obj); return GetJoinTableId(table, refIdColumn, fields); } diff --git a/src/NHibernate/Properties/PropertyAccessorFactory.cs b/src/NHibernate/Properties/PropertyAccessorFactory.cs index f7e4ee328a6..289b6cc96a3 100644 --- a/src/NHibernate/Properties/PropertyAccessorFactory.cs +++ b/src/NHibernate/Properties/PropertyAccessorFactory.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using NHibernate.Type; using NHibernate.Util; -using NHibernate.Engine; namespace NHibernate.Properties { @@ -224,27 +222,18 @@ public static IPropertyAccessor GetPropertyAccessor(string type) public static IPropertyAccessor GetPropertyAccessor(Mapping.Property property, EntityMode? mode) { //TODO: this is temporary in that the end result will probably not take a Property reference per-se. - EntityMode modeToUse = mode.HasValue ? mode.Value : EntityMode.Poco; + EntityMode modeToUse = mode ?? EntityMode.Poco; switch(modeToUse) { case EntityMode.Poco: return GetPocoPropertyAccessor(property.PropertyAccessorName); case EntityMode.Map: return DynamicMapPropertyAccessor; - case EntityMode.Xml: - return GetXmlPropertyAccessor(property.GetAccessorPropertyName(modeToUse), property.Type, null); default: throw new MappingException("Unknown entity mode [" + mode + "]"); } } - private static IPropertyAccessor GetXmlPropertyAccessor(string nodeName, IType type, ISessionFactoryImplementor factory) - { - //TODO: need some caching scheme? really comes down to decision - // regarding amount of state (if any) kept on PropertyAccessors - return new XmlAccessor(nodeName, type, factory); - } - private static IPropertyAccessor GetPocoPropertyAccessor(string accessorName) { string accName = string.IsNullOrEmpty(accessorName) ? DefaultAccessorName : accessorName; diff --git a/src/NHibernate/Properties/XmlAccessor.cs b/src/NHibernate/Properties/XmlAccessor.cs deleted file mode 100644 index f4e0a435ae1..00000000000 --- a/src/NHibernate/Properties/XmlAccessor.cs +++ /dev/null @@ -1,426 +0,0 @@ -using System; -using System.Collections; -using System.Reflection; -using System.Xml; -using NHibernate.Engine; -using NHibernate.Type; - -namespace NHibernate.Properties -{ - /// - /// Responsible for accessing property values represented as a XmlElement - /// or XmlAttribute. - /// - [Serializable] - public class XmlAccessor : IPropertyAccessor - { - private readonly ISessionFactoryImplementor factory; - private readonly string nodeName; - private readonly IType propertyType; - - public XmlAccessor(string nodeName, IType propertyType, ISessionFactoryImplementor factory) - { - this.factory = factory; - this.nodeName = nodeName; - this.propertyType = propertyType; - } - - #region Implementation of IPropertyAccessor - - public IGetter GetGetter(System.Type theClass, string propertyName) - { - if (nodeName == null) - { - throw new MappingException("no node name for property: " + propertyName); - } - if (".".Equals(nodeName)) - { - return new TextGetter(propertyType, factory); - } - else if (nodeName.IndexOf('/') > -1) - { - return new ElementAttributeGetter(nodeName, propertyType, factory); - } - else if (nodeName.IndexOf('@') > -1) - { - return new AttributeGetter(nodeName, propertyType, factory); - } - else - { - return new ElementGetter(nodeName, propertyType, factory); - } - } - - public ISetter GetSetter(System.Type theClass, string propertyName) - { - if (nodeName == null) - { - throw new MappingException("no node name for property: " + propertyName); - } - if (".".Equals(nodeName)) - { - return new TextSetter(propertyType); - } - else if (nodeName.IndexOf('/') > -1) - { - return new ElementAttributeSetter(nodeName, propertyType); - } - else if (nodeName.IndexOf('@') > -1) - { - return new AttributeSetter(nodeName, propertyType); - } - else - { - return new ElementSetter(nodeName, propertyType); - } - } - - public bool CanAccessThroughReflectionOptimizer - { - get { return true; } - } - - #endregion - - #region Nested type: AttributeGetter - - /// For nodes like "@bar" - [Serializable] - public class AttributeGetter : XmlGetter - { - private readonly string attributeName; - - public AttributeGetter(string name, IType propertyType, ISessionFactoryImplementor factory) - : base(propertyType, factory) - { - attributeName = name.Substring(1); - } - - public override object Get(object owner) - { - var ownerElement = (XmlNode) owner; - XmlNode attribute = ownerElement.Attributes[attributeName]; - return attribute == null ? null : propertyType.FromXMLNode(attribute, factory); - } - } - - #endregion - - #region Nested type: AttributeSetter - - /// For nodes like "@bar" - [Serializable] - public class AttributeSetter : XmlSetter - { - private readonly string attributeName; - - public AttributeSetter(string name, IType propertyType) : base(propertyType) - { - attributeName = name.Substring(1); - } - - public override void Set(object target, object value) - { - var owner = (XmlElement) target; - XmlAttribute attribute = owner.Attributes[attributeName]; - if (value == null) - { - if (attribute != null) - { - owner.Attributes.Remove(attribute); - } - } - else - { - if (attribute == null) - { - owner.SetAttribute(attributeName, "null"); - attribute = owner.Attributes[attributeName]; - } - propertyType.SetToXMLNode(attribute, value, null); - } - } - } - - #endregion - - #region Nested type: ElementAttributeGetter - - /// For nodes like "foo/@bar" - [Serializable] - public class ElementAttributeGetter : XmlGetter - { - private readonly string attributeName; - private readonly string elementName; - - public ElementAttributeGetter(string name, IType propertyType, ISessionFactoryImplementor factory) - : base(propertyType, factory) - { - elementName = name.Substring(0, (name.IndexOf('/'))); - attributeName = name.Substring(name.IndexOf('/') + 2); - } - - public override object Get(object owner) - { - var ownerElement = (XmlNode) owner; - - XmlNode element = ownerElement[elementName]; - - if (element == null) - { - return null; - } - else - { - XmlAttribute attribute = element.Attributes[attributeName]; - if (attribute == null) - { - return null; - } - else - { - return propertyType.FromXMLNode(attribute, factory); - } - } - } - } - - #endregion - - #region Nested type: ElementAttributeSetter - - /// For nodes like "foo/@bar" - [Serializable] - public class ElementAttributeSetter : XmlSetter - { - private readonly string attributeName; - private readonly string elementName; - - public ElementAttributeSetter(string name, IType propertyType) : base(propertyType) - { - elementName = name.Substring(0, name.IndexOf('/')); - attributeName = name.Substring(name.IndexOf('/') + 2); - } - - public override void Set(object target, object value) - { - var owner = (XmlElement) target; - XmlElement element = owner[elementName]; - if (value == null) - { - if (element != null) - { - owner.RemoveChild(element); - } - } - else - { - XmlAttribute attribute; - if (element == null) - { - element = owner.OwnerDocument.CreateElement(elementName); - owner.AppendChild(element); - attribute = null; - } - else - { - attribute = element.Attributes[attributeName]; - } - - if (attribute == null) - { - element.SetAttribute(attributeName, "null"); - attribute = element.Attributes[attributeName]; - } - propertyType.SetToXMLNode(attribute, value, null); - } - } - } - - #endregion - - #region Nested type: ElementGetter - - /// For nodes like "foo" - [Serializable] - public class ElementGetter : XmlGetter - { - private readonly string elementName; - - public ElementGetter(string name, IType propertyType, ISessionFactoryImplementor factory) - : base(propertyType, factory) - { - elementName = name; - } - - public override object Get(object owner) - { - var ownerElement = (XmlNode) owner; - XmlNode element = ownerElement[elementName]; - return element == null ? null : propertyType.FromXMLNode(element, factory); - } - } - - #endregion - - #region Nested type: ElementSetter - - /// For nodes like "foo" - [Serializable] - public class ElementSetter : XmlSetter - { - private readonly string elementName; - - public ElementSetter(string name, IType propertyType) : base(propertyType) - { - elementName = name; - } - - public override void Set(object target, object value) - { - if (value != CollectionType.UnfetchedCollection) - { - var owner = (XmlElement) target; - XmlElement existing = owner[elementName]; - if (existing != null) - { - owner.RemoveChild(existing); - } - if (value != null) - { - XmlElement element = owner.OwnerDocument.CreateElement(elementName); - owner.AppendChild(element); - propertyType.SetToXMLNode(element, value, null); - } - } - } - } - - #endregion - - #region Nested type: TextGetter - - /// For nodes like "." - [Serializable] - public class TextGetter : XmlGetter - { - public TextGetter(IType propertyType, ISessionFactoryImplementor factory) : base(propertyType, factory) {} - - public override object Get(object owner) - { - var ownerElement = (XmlNode) owner; - return propertyType.FromXMLNode(ownerElement, factory); - } - } - - #endregion - - #region Nested type: TextSetter - - /// For nodes like "." - [Serializable] - public class TextSetter : XmlSetter - { - public TextSetter(IType propertyType) : base(propertyType) {} - - public override void Set(object target, object value) - { - var owner = (XmlNode) target; - if (!propertyType.IsXMLElement) - { - //kinda ugly, but needed for collections with a "." node mapping - if (value == null) - { - owner.InnerText = ""; //is this ok? - } - else - { - propertyType.SetToXMLNode(owner, value, null); - } - } - } - } - - #endregion - - #region Nested type: XmlGetter - - /// Defines the strategy for getting property values out of a dom4j Node. - [Serializable] - public abstract class XmlGetter : IGetter - { - protected ISessionFactoryImplementor factory; - protected IType propertyType; - - internal XmlGetter(IType propertyType, ISessionFactoryImplementor factory) - { - this.propertyType = propertyType; - this.factory = factory; - } - - #region IGetter Members - - /// Get the declared type - public virtual System.Type ReturnType - { - get { return typeof (object); } - } - - /// Optional operation (return null) - public virtual string PropertyName - { - get { return null; } - } - - /// Optional operation (return null) - public virtual MethodInfo Method - { - get { return null; } - } - - public virtual object GetForInsert(object owner, IDictionary mergeMap, ISessionImplementor session) - { - return Get(owner); - } - - public abstract object Get(object target); - - #endregion - } - - #endregion - - #region Nested type: XmlSetter - - [Serializable] - public abstract class XmlSetter : ISetter - { - protected internal IType propertyType; - - internal XmlSetter(IType propertyType) - { - this.propertyType = propertyType; - } - - #region ISetter Members - - /// Optional operation (return null) - public virtual string PropertyName - { - get { return null; } - } - - /// Optional operation (return null) - public virtual MethodInfo Method - { - get { return null; } - } - - public abstract void Set(object target, object value); - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs b/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs deleted file mode 100644 index 4734e508a75..00000000000 --- a/src/NHibernate/Tuple/Component/ComponentEntityModeToTuplizerMapping.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Collections.Generic; -using NHibernate.Mapping; -using NHibernate.Util; - -namespace NHibernate.Tuple.Component -{ - /// - /// Handles mapping s to ComponentTuplizers. - ///

- /// Most of the handling is really in the super class; here we just create - /// the tuplizers and add them to the superclass - ///

- [Serializable] - public class ComponentEntityModeToTuplizerMapping : EntityModeToTuplizerMapping - { - private static readonly System.Type[] componentTuplizerCTORSignature = new System.Type[] { typeof(Mapping.Component) }; - - public ComponentEntityModeToTuplizerMapping(Mapping.Component component) - { - PersistentClass owner = component.Owner; - - // create our own copy of the user-supplied tuplizer impl map - Dictionary userSuppliedTuplizerImpls; - if (component.TuplizerMap != null) - userSuppliedTuplizerImpls = new Dictionary(component.TuplizerMap); - else - userSuppliedTuplizerImpls = new Dictionary(); - - // Build the dynamic-map tuplizer... - ITuplizer dynamicMapTuplizer; - string tuplizerImpl; - if (!userSuppliedTuplizerImpls.TryGetValue(EntityMode.Map,out tuplizerImpl)) - { - dynamicMapTuplizer = new DynamicMapComponentTuplizer(component); - } - else - { - dynamicMapTuplizer = BuildComponentTuplizer(tuplizerImpl, component); - userSuppliedTuplizerImpls.Remove(EntityMode.Map); - } - - // then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available - ITuplizer pojoTuplizer; - string tempObject2; - userSuppliedTuplizerImpls.TryGetValue(EntityMode.Poco, out tempObject2); - userSuppliedTuplizerImpls.Remove(EntityMode.Poco); - tuplizerImpl = tempObject2; - if (component.HasPocoRepresentation) - { - if (tuplizerImpl == null) - { - pojoTuplizer = new PocoComponentTuplizer(component); - } - else - { - pojoTuplizer = BuildComponentTuplizer(tuplizerImpl, component); - } - } - else - { - pojoTuplizer = dynamicMapTuplizer; - } - - // put the "standard" tuplizers into the tuplizer map first - if (pojoTuplizer != null) - { - AddTuplizer(EntityMode.Poco, pojoTuplizer); - } - if (dynamicMapTuplizer != null) - { - AddTuplizer(EntityMode.Map, dynamicMapTuplizer); - } - - // then handle any user-defined entity modes.. - foreach (KeyValuePair entry in userSuppliedTuplizerImpls) - { - IComponentTuplizer tuplizer = BuildComponentTuplizer(entry.Value, component); - AddTuplizer(entry.Key, tuplizer); - } - } - - private IComponentTuplizer BuildComponentTuplizer(string tuplizerImpl, Mapping.Component component) - { - try - { - System.Type implClass = ReflectHelper.ClassForName(tuplizerImpl); - return (IComponentTuplizer)implClass.GetConstructor(componentTuplizerCTORSignature).Invoke(new object[] { component }); - } - catch (Exception t) - { - throw new HibernateException("Could not build tuplizer [" + tuplizerImpl + "]", t); - } - } - } -} diff --git a/src/NHibernate/Tuple/Component/ComponentMetamodel.cs b/src/NHibernate/Tuple/Component/ComponentMetamodel.cs index cae11ca6193..b42673c4cb9 100644 --- a/src/NHibernate/Tuple/Component/ComponentMetamodel.cs +++ b/src/NHibernate/Tuple/Component/ComponentMetamodel.cs @@ -11,7 +11,6 @@ public class ComponentMetamodel private readonly int propertySpan; private readonly StandardProperty[] properties; private readonly Dictionary propertyIndexes; - private readonly ComponentEntityModeToTuplizerMapping tuplizerMapping; public ComponentMetamodel(Mapping.Component component) { @@ -27,7 +26,14 @@ public ComponentMetamodel(Mapping.Component component) propertyIndexes[property.Name] = i; i++; } - tuplizerMapping = new ComponentEntityModeToTuplizerMapping(component); + EntityMode = component.HasPocoRepresentation ? EntityMode.Poco : EntityMode.Map; + + var componentTuplizerFactory = new ComponentTuplizerFactory(); + var tuplizerClassName = component.GetTuplizerImplClassName(EntityMode); + + ComponentTuplizer = tuplizerClassName == null + ? componentTuplizerFactory.BuildDefaultComponentTuplizer(EntityMode, component) + : componentTuplizerFactory.BuildComponentTuplizer(tuplizerClassName, component); } public string Role @@ -50,11 +56,6 @@ public StandardProperty[] Properties get { return properties; } } - public ComponentEntityModeToTuplizerMapping TuplizerMapping - { - get { return tuplizerMapping; } - } - public StandardProperty GetProperty(int index) { if (index < 0 || index >= propertySpan) @@ -78,5 +79,9 @@ public StandardProperty GetProperty(string propertyName) { return properties[GetPropertyIndex(propertyName)]; } + + public EntityMode EntityMode { get; } + + public IComponentTuplizer ComponentTuplizer { get; } } } diff --git a/src/NHibernate/Tuple/Component/ComponentTuplizerFactory.cs b/src/NHibernate/Tuple/Component/ComponentTuplizerFactory.cs new file mode 100644 index 00000000000..3468d88813e --- /dev/null +++ b/src/NHibernate/Tuple/Component/ComponentTuplizerFactory.cs @@ -0,0 +1,40 @@ +using System; +using NHibernate.Util; + +namespace NHibernate.Tuple.Component +{ + /// + /// A registry allowing users to define the default class to use per ;. + /// + [Serializable] + public class ComponentTuplizerFactory + { + static readonly System.Type[] ComponentTuplizerCtorSignature = { typeof(Mapping.Component) }; + + public IComponentTuplizer BuildDefaultComponentTuplizer(EntityMode entityMode, Mapping.Component component) + { + switch (entityMode) + { + case EntityMode.Poco: + return new PocoComponentTuplizer(component); + case EntityMode.Map: + return new DynamicMapComponentTuplizer(component); + default: + throw new ArgumentOutOfRangeException(nameof(entityMode), entityMode, null); + } + } + + public IComponentTuplizer BuildComponentTuplizer(string tuplizerImpl, Mapping.Component component) + { + try + { + System.Type implClass = ReflectHelper.ClassForName(tuplizerImpl); + return (IComponentTuplizer)implClass.GetConstructor(ComponentTuplizerCtorSignature).Invoke(new object[] { component }); + } + catch (Exception t) + { + throw new HibernateException("Could not build tuplizer [" + tuplizerImpl + "]", t); + } + } + } +} diff --git a/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs b/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs index 2a096450b74..f663a7676cb 100644 --- a/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs +++ b/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs @@ -130,8 +130,8 @@ public object GetIdentifier(object entity) else { ComponentType copier = (ComponentType)entityMetamodel.IdentifierProperty.Type; - id = copier.Instantiate(EntityMode); - copier.SetPropertyValues(id, identifierMapperType.GetPropertyValues(entity, EntityMode), EntityMode); + id = copier.Instantiate(); + copier.SetPropertyValues(id, identifierMapperType.GetPropertyValues(entity)); } } else @@ -150,7 +150,7 @@ public void SetIdentifier(object entity, object id) if (entity != id) { IAbstractComponentType copier = (IAbstractComponentType)entityMetamodel.IdentifierProperty.Type; - copier.SetPropertyValues(entity, copier.GetPropertyValues(id, EntityMode), EntityMode); + copier.SetPropertyValues(entity, copier.GetPropertyValues(id)); } } else if (idSetter != null) @@ -364,7 +364,7 @@ protected virtual object GetComponentValue(ComponentType type, object component, throw new MappingException("component property not found: " + basePropertyName); } - object baseValue = type.GetPropertyValue(component, index, EntityMode); + object baseValue = type.GetPropertyValue(component, index); if (loc > 0) { diff --git a/src/NHibernate/Tuple/Entity/EntityEntityModeToTuplizerMapping.cs b/src/NHibernate/Tuple/Entity/EntityEntityModeToTuplizerMapping.cs deleted file mode 100644 index a669454e015..00000000000 --- a/src/NHibernate/Tuple/Entity/EntityEntityModeToTuplizerMapping.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using NHibernate.Mapping; -using NHibernate.Util; - -namespace NHibernate.Tuple.Entity -{ - /// - /// Handles mapping s to s. - /// - /// - /// Most of the handling is really in the super class; here we just create - /// the tuplizers and add them to the superclass - /// - [Serializable] - public class EntityEntityModeToTuplizerMapping : EntityModeToTuplizerMapping - { - private static readonly System.Type[] entityTuplizerCTORSignature = new System.Type[] { typeof(EntityMetamodel), typeof(PersistentClass) }; - - /// - /// Instantiates a EntityEntityModeToTuplizerMapping based on the given - /// entity mapping and metamodel definitions. - /// - /// The entity mapping definition. - /// The entity metamodel definition. - public EntityEntityModeToTuplizerMapping(PersistentClass mappedEntity, EntityMetamodel em) - { - // create our own copy of the user-supplied tuplizer impl map - Dictionary userSuppliedTuplizerImpls = mappedEntity.TuplizerMap != null - ? new Dictionary( - mappedEntity.TuplizerMap) - : new Dictionary(); - - // Build the dynamic-map tuplizer... - ITuplizer dynamicMapTuplizer; - string tuplizerImpl; - if (!userSuppliedTuplizerImpls.TryGetValue(EntityMode.Map, out tuplizerImpl)) - { - dynamicMapTuplizer = new DynamicMapEntityTuplizer(em, mappedEntity); - } - else - { - dynamicMapTuplizer = BuildEntityTuplizer(tuplizerImpl, mappedEntity, em); - userSuppliedTuplizerImpls.Remove(EntityMode.Map); - } - - // then the pojo tuplizer, using the dynamic-map tuplizer if no pojo representation is available - ITuplizer pojoTuplizer; - - string tempObject2; - userSuppliedTuplizerImpls.TryGetValue(EntityMode.Poco, out tempObject2); - userSuppliedTuplizerImpls.Remove(EntityMode.Poco); - tuplizerImpl = tempObject2; - if (mappedEntity.HasPocoRepresentation) - { - if (tuplizerImpl == null) - { - pojoTuplizer = new PocoEntityTuplizer(em, mappedEntity); - } - else - { - pojoTuplizer = BuildEntityTuplizer(tuplizerImpl, mappedEntity, em); - } - } - else - { - pojoTuplizer = dynamicMapTuplizer; - } - - // put the "standard" tuplizers into the tuplizer map first - if (pojoTuplizer != null) - { - AddTuplizer(EntityMode.Poco, pojoTuplizer); - } - if (dynamicMapTuplizer != null) - { - AddTuplizer(EntityMode.Map, dynamicMapTuplizer); - } - - // then handle any user-defined entity modes... - foreach (KeyValuePair pair in userSuppliedTuplizerImpls) - { - IEntityTuplizer tuplizer = BuildEntityTuplizer(pair.Value, mappedEntity, em); - AddTuplizer(pair.Key, tuplizer); - } - } - - private static IEntityTuplizer BuildEntityTuplizer(string className, PersistentClass pc, EntityMetamodel em) - { - try - { - System.Type implClass = ReflectHelper.ClassForName(className); - return (IEntityTuplizer)implClass.GetConstructor(entityTuplizerCTORSignature).Invoke(new object[] { em, pc }); - } - catch (Exception t) - { - throw new HibernateException("Could not build tuplizer [" + className + "]", t); - } - } - - } -} diff --git a/src/NHibernate/Tuple/Entity/EntityMetamodel.cs b/src/NHibernate/Tuple/Entity/EntityMetamodel.cs index 7e11bd4950b..93523caff24 100644 --- a/src/NHibernate/Tuple/Entity/EntityMetamodel.cs +++ b/src/NHibernate/Tuple/Entity/EntityMetamodel.cs @@ -314,7 +314,13 @@ public EntityMetamodel(PersistentClass persistentClass, ISessionFactoryImplement } subclassEntityNames.Add(name); - tuplizerMapping = new EntityEntityModeToTuplizerMapping(persistentClass, this); + EntityMode = persistentClass.HasPocoRepresentation ? EntityMode.Poco : EntityMode.Map; + + var entityTuplizerFactory = new EntityTuplizerFactory(); + var tuplizerClassName = persistentClass.GetTuplizerImplClassName(EntityMode); + Tuplizer = tuplizerClassName == null + ? entityTuplizerFactory.BuildDefaultEntityTuplizer(EntityMode, this, persistentClass) + : entityTuplizerFactory.BuildEntityTuplizer(tuplizerClassName, this, persistentClass); } public bool HasPocoRepresentation { get; private set; } @@ -685,25 +691,11 @@ public bool HasUpdateGeneratedValues #endregion - #region Tuplizer - private readonly EntityEntityModeToTuplizerMapping tuplizerMapping; private bool hasUnwrapProxyForProperties; - public IEntityTuplizer GetTuplizer(EntityMode entityMode) - { - return (IEntityTuplizer)tuplizerMapping.GetTuplizer(entityMode); - } + public IEntityTuplizer Tuplizer { get; } - public IEntityTuplizer GetTuplizerOrNull(EntityMode entityMode) - { - return (IEntityTuplizer)tuplizerMapping.GetTuplizerOrNull(entityMode); - } - - public EntityMode? GuessEntityMode(object obj) - { - return tuplizerMapping.GuessEntityMode(obj); - } - #endregion + public EntityMode EntityMode { get; } public bool HasNaturalIdentifier { diff --git a/src/NHibernate/Tuple/Entity/EntityTuplizerFactory.cs b/src/NHibernate/Tuple/Entity/EntityTuplizerFactory.cs new file mode 100644 index 00000000000..8d10538659d --- /dev/null +++ b/src/NHibernate/Tuple/Entity/EntityTuplizerFactory.cs @@ -0,0 +1,41 @@ +using System; +using NHibernate.Mapping; +using NHibernate.Util; + +namespace NHibernate.Tuple.Entity +{ + /// + /// A registry allowing users to define the default class to use per . + /// + [Serializable] + public class EntityTuplizerFactory + { + static readonly System.Type[] EntityTuplizerCtorSignature = { typeof(EntityMetamodel), typeof(PersistentClass) }; + + public IEntityTuplizer BuildEntityTuplizer(string className, EntityMetamodel em, PersistentClass pc) + { + try + { + System.Type implClass = ReflectHelper.ClassForName(className); + return (IEntityTuplizer)implClass.GetConstructor(EntityTuplizerCtorSignature).Invoke(new object[] { em, pc }); + } + catch (Exception t) + { + throw new HibernateException("Could not build tuplizer [" + className + "]", t); + } + } + + public IEntityTuplizer BuildDefaultEntityTuplizer(EntityMode entityMode, EntityMetamodel entityMetamodel, PersistentClass persistentClass) + { + switch (entityMode) + { + case EntityMode.Poco: + return new PocoEntityTuplizer(entityMetamodel, persistentClass); + case EntityMode.Map: + return new DynamicMapEntityTuplizer(entityMetamodel, persistentClass); + default: + throw new ArgumentOutOfRangeException(nameof(entityMode), entityMode, null); + } + } + } +} diff --git a/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs b/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs deleted file mode 100644 index 14bf6a83421..00000000000 --- a/src/NHibernate/Tuple/EntityModeToTuplizerMapping.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; -using NHibernate.Util; - -namespace NHibernate.Tuple -{ - /// Centralizes handling of to mappings. - [Serializable] - public abstract class EntityModeToTuplizerMapping : IDeserializationCallback - { - - // NH-1660 - private readonly IDictionary _tuplizers - = new LinkedHashMap(5, new EntityModeEqualityComparer()); - - /// - /// This class might get called during serialization, and may therefore need to deserialize on-demand. - /// - [NonSerialized] private bool _isFullyDeserialized; - - - protected EntityModeToTuplizerMapping() - { - _isFullyDeserialized = true; - } - - protected internal void AddTuplizer(EntityMode entityMode, ITuplizer tuplizer) - { - EnsureFullyDeserialized(); - _tuplizers[entityMode] = tuplizer; - } - - /// Given a supposed instance of an entity/component, guess its entity mode. - /// The supposed instance of the entity/component. - /// The guessed entity mode. - public virtual EntityMode? GuessEntityMode(object obj) - { - EnsureFullyDeserialized(); - foreach (KeyValuePair entry in _tuplizers) - { - ITuplizer tuplizer = entry.Value; - if (tuplizer.IsInstance(obj)) - { - return entry.Key; - } - } - return null; - } - - /// - /// Locate the contained tuplizer responsible for the given entity-mode. If - /// no such tuplizer is defined on this mapping, then return null. - /// - /// The entity-mode for which the caller wants a tuplizer. - /// The tuplizer, or null if not found. - public virtual ITuplizer GetTuplizerOrNull(EntityMode entityMode) - { - EnsureFullyDeserialized(); - ITuplizer result; - _tuplizers.TryGetValue(entityMode, out result); - return result; - } - - /// Locate the tuplizer contained within this mapping which is responsible - /// for the given entity-mode. If no such tuplizer is defined on this - /// mapping, then an exception is thrown. - /// - /// - /// The entity-mode for which the caller wants a tuplizer. - /// - /// The tuplizer. - /// - /// HibernateException Unable to locate the requested tuplizer. - public virtual ITuplizer GetTuplizer(EntityMode entityMode) - { - ITuplizer tuplizer = GetTuplizerOrNull(entityMode); - if (tuplizer == null) - { - throw new HibernateException("No tuplizer found for entity-mode [" + entityMode + "]"); - } - return tuplizer; - } - - private void EnsureFullyDeserialized() - { - if (!_isFullyDeserialized) - { - ((IDeserializationCallback) this).OnDeserialization(this); - } - } - - void IDeserializationCallback.OnDeserialization(object sender) - { - ((IDeserializationCallback) _tuplizers).OnDeserialization(sender); - _isFullyDeserialized = true; - } - } -} diff --git a/src/NHibernate/Type/AbstractBinaryType.cs b/src/NHibernate/Type/AbstractBinaryType.cs index 5f59a43be76..954b0dbda4a 100644 --- a/src/NHibernate/Type/AbstractBinaryType.cs +++ b/src/NHibernate/Type/AbstractBinaryType.cs @@ -21,8 +21,8 @@ internal AbstractBinaryType(BinarySqlType sqlType) { } - #region IVersionType Members + // Note : simply returns null for seed() and next() as the only known // application of binary types for versioning is for use with the // TIMESTAMP datatype supported by Sybase and SQL Server, which @@ -56,16 +56,7 @@ public IComparer Comparator #endregion - #region IComparer Members - - public virtual int Compare(object x, object y) - { - return Compare(x, y, null); - } - - #endregion - - public abstract override string Name { get;} + public abstract override string Name { get; } /// Convert the byte[] into the expected object type protected internal abstract object ToExternalFormat(byte[] bytes); @@ -89,7 +80,7 @@ public override void Set(DbCommand cmd, object value, int index) public override object Get(DbDataReader rs, int index) { - int length = (int)rs.GetBytes(index, 0, null, 0, 0); + int length = (int) rs.GetBytes(index, 0, null, 0, 0); byte[] buffer = new byte[length]; if (length > 0) { @@ -104,7 +95,7 @@ public override object Get(DbDataReader rs, string name) return Get(rs, rs.GetOrdinal(name)); } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { byte[] bytes = ToInternalFormat(x); int hashCode = 1; @@ -118,7 +109,7 @@ public override int GetHashCode(object x, EntityMode entityMode) return hashCode; } - public override int Compare(object x, object y, EntityMode? entityMode) + public override int Compare(object x, object y) { byte[] xbytes = ToInternalFormat(x); byte[] ybytes = ToInternalFormat(y); @@ -170,7 +161,7 @@ public override object FromStringValue(string xml) for (int i = 0; i < bytes.Length; i++) { string hexStr = xml.Substring(i * 2, ((i + 1) * 2) - (i * 2)); - bytes[i] = (byte)(Convert.ToInt32(hexStr, 16) + Byte.MinValue); + bytes[i] = (byte) (Convert.ToInt32(hexStr, 16) + Byte.MinValue); } return ToExternalFormat(bytes); } diff --git a/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs b/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs index 1a197dfdfa4..a4e0b0f9278 100644 --- a/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs +++ b/src/NHibernate/Type/AbstractDateTimeSpecificKindType.cs @@ -18,9 +18,9 @@ public override object FromStringValue(string xml) return DateTime.SpecifyKind(DateTime.Parse(xml), DateTimeKind); } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { - int hashCode = base.GetHashCode(x, entityMode); + int hashCode = base.GetHashCode(x); unchecked { hashCode = 31*hashCode + ((DateTime) x).Kind.GetHashCode(); diff --git a/src/NHibernate/Type/AbstractType.cs b/src/NHibernate/Type/AbstractType.cs index 8acb64645f7..567f00013d6 100644 --- a/src/NHibernate/Type/AbstractType.cs +++ b/src/NHibernate/Type/AbstractType.cs @@ -71,7 +71,7 @@ public virtual object Disassemble(object value, ISessionImplementor session, obj if (value == null) return null; - return DeepCopy(value, session.EntityMode, session.Factory); + return DeepCopy(value, session.Factory); } /// @@ -89,7 +89,7 @@ public virtual object Assemble(object cached, ISessionImplementor session, objec if (cached == null) return null; - return DeepCopy(cached, session.EntityMode, session.Factory); + return DeepCopy(cached, session.Factory); } public virtual void BeforeAssemble(object cached, ISessionImplementor session) @@ -107,7 +107,7 @@ public virtual void BeforeAssemble(object cached, ISessionImplementor session) /// This method uses IType.Equals(object, object) to determine the value of IsDirty. public virtual bool IsDirty(object old, object current, ISessionImplementor session) { - return !IsSame(old, current, session.EntityMode); + return !IsSame(old, current); } /// @@ -185,7 +185,7 @@ public override int GetHashCode() /// - public abstract object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImplementor factory); + public abstract object DeepCopy(object val, ISessionFactoryImplementor factory); /// public override System.Type ReturnedClass { - get { return tuplizerMapping.GetTuplizer(EntityMode.Poco).MappedClass; } + get { return ComponentTuplizer.MappedClass; } } - public override int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory) + public override int GetHashCode(object x, ISessionFactoryImplementor factory) { if (overridesGetHashCode) return x.GetHashCode(); - return GetHashCode(x, entityMode); + return GetHashCode(x); } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { int result = 17; - object[] values = GetPropertyValues(x, entityMode); + object[] values = GetPropertyValues(x); unchecked { for (int i = 0; i < propertySpan; i++) @@ -122,7 +121,7 @@ public override int GetHashCode(object x, EntityMode entityMode) object y = values[i]; result *= 37; if (y != null) - result += propertyTypes[i].GetHashCode(y, entityMode); + result += propertyTypes[i].GetHashCode(y); } } return result; @@ -138,13 +137,12 @@ public override bool IsDirty(object x, object y, ISessionImplementor session) * NH Different behavior : we don't use the shortcut because NH-1101 * let the tuplizer choose how cosiderer properties when the component is null. */ - EntityMode entityMode = session.EntityMode; - if (entityMode != EntityMode.Poco && (x == null || y == null)) + if (EntityMode != EntityMode.Poco && (x == null || y == null)) { return true; } - object[] xvalues = GetPropertyValues(x, entityMode); - object[] yvalues = GetPropertyValues(y, entityMode); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); for (int i = 0; i < xvalues.Length; i++) { if (propertyTypes[i].IsDirty(xvalues[i], yvalues[i], session)) @@ -165,13 +163,12 @@ public override bool IsDirty(object x, object y, bool[] checkable, ISessionImple * NH Different behavior : we don't use the shortcut because NH-1101 * let the tuplizer choose how cosiderer properties when the component is null. */ - EntityMode entityMode = session.EntityMode; - if (entityMode != EntityMode.Poco && (x == null || y == null)) + if (EntityMode != EntityMode.Poco && (x == null || y == null)) { return true; } - object[] xvalues = GetPropertyValues(x, entityMode); - object[] yvalues = GetPropertyValues(y, entityMode); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); int loc = 0; for (int i = 0; i < xvalues.Length; i++) { @@ -214,7 +211,7 @@ public override object NullSafeGet(DbDataReader rs, string[] names, ISessionImpl /// public override void NullSafeSet(DbCommand st, object value, int begin, ISessionImplementor session) { - object[] subvalues = NullSafeGetValues(value, session.EntityMode); + object[] subvalues = NullSafeGetValues(value); for (int i = 0; i < propertySpan; i++) { @@ -225,7 +222,7 @@ public override void NullSafeSet(DbCommand st, object value, int begin, ISession public override void NullSafeSet(DbCommand st, object value, int begin, bool[] settable, ISessionImplementor session) { - object[] subvalues = NullSafeGetValues(value, session.EntityMode); + object[] subvalues = NullSafeGetValues(value); int loc = 0; for (int i = 0; i < propertySpan; i++) @@ -254,7 +251,7 @@ public override void NullSafeSet(DbCommand st, object value, int begin, bool[] s } } - private object[] NullSafeGetValues(object value, EntityMode entityMode) + private object[] NullSafeGetValues(object value) { if (value == null) { @@ -262,7 +259,7 @@ private object[] NullSafeGetValues(object value, EntityMode entityMode) } else { - return GetPropertyValues(value, entityMode); + return GetPropertyValues(value); } } @@ -271,29 +268,29 @@ public override object NullSafeGet(DbDataReader rs, string name, ISessionImpleme return NullSafeGet(rs, new string[] {name}, session, owner); } - public object GetPropertyValue(object component, int i, EntityMode entityMode) + public object GetPropertyValue(object component, int i) { - return tuplizerMapping.GetTuplizer(entityMode).GetPropertyValue(component, i); + return ComponentTuplizer.GetPropertyValue(component, i); } public object GetPropertyValue(object component, int i, ISessionImplementor session) { - return GetPropertyValue(component, i, session.EntityMode); + return GetPropertyValue(component, i); } - public object[] GetPropertyValues(object component, EntityMode entityMode) + public object[] GetPropertyValues(object component) { - return tuplizerMapping.GetTuplizer(entityMode).GetPropertyValues(component); + return ComponentTuplizer.GetPropertyValues(component); } public object[] GetPropertyValues(object component, ISessionImplementor session) { - return GetPropertyValues(component, session.EntityMode); + return GetPropertyValues(component); } - public virtual void SetPropertyValues(object component, object[] values, EntityMode entityMode) + public virtual void SetPropertyValues(object component, object[] values) { - tuplizerMapping.GetTuplizer(entityMode).SetPropertyValues(component, values); + ComponentTuplizer.SetPropertyValues(component, values); } /// @@ -321,12 +318,7 @@ public override string ToLoggableString(object value, ISessionFactoryImplementor return "null"; } IDictionary result = new Dictionary(); - EntityMode? entityMode = tuplizerMapping.GuessEntityMode(value); - if (!entityMode.HasValue) - { - throw new InvalidCastException(value.GetType().FullName); - } - object[] values = GetPropertyValues(value, entityMode.Value); + object[] values = GetPropertyValues(value); for (int i = 0; i < propertyTypes.Length; i++) { result[propertyNames[i]] = propertyTypes[i].ToLoggableString(values[i], factory); @@ -340,28 +332,27 @@ public string[] PropertyNames get { return propertyNames; } } - public override object DeepCopy(object component, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object component, ISessionFactoryImplementor factory) { if (component == null) { return null; } - object[] values = GetPropertyValues(component, entityMode); + object[] values = GetPropertyValues(component); for (int i = 0; i < propertySpan; i++) { - values[i] = propertyTypes[i].DeepCopy(values[i], entityMode, factory); + values[i] = propertyTypes[i].DeepCopy(values[i], factory); } - object result = Instantiate(entityMode); - SetPropertyValues(result, values, entityMode); + object result = Instantiate(); + SetPropertyValues(result, values); //not absolutely necessary, but helps for some //equals()/hashCode() implementations - IComponentTuplizer ct = (IComponentTuplizer)tuplizerMapping.GetTuplizer(entityMode); - if (ct.HasParentProperty) + if (ComponentTuplizer.HasParentProperty) { - ct.SetParent(result, ct.GetParent(component), factory); + ComponentTuplizer.SetParent(result, ComponentTuplizer.GetParent(component), factory); } return result; @@ -375,10 +366,9 @@ public override object Replace(object original, object target, ISessionImplement object result = target ?? Instantiate(owner, session); - EntityMode entityMode = session.EntityMode; - object[] values = TypeHelper.Replace(GetPropertyValues(original, entityMode), GetPropertyValues(result, entityMode), propertyTypes, session, owner, copiedAlready); + object[] values = TypeHelper.Replace(GetPropertyValues(original), GetPropertyValues(result), propertyTypes, session, owner, copiedAlready); - SetPropertyValues(result, values, entityMode); + SetPropertyValues(result, values); return result; } @@ -389,27 +379,25 @@ public override object Replace(object original, object target, ISessionImplement object result = target ?? Instantiate(owner, session); - EntityMode entityMode = session.EntityMode; - object[] values = TypeHelper.Replace(GetPropertyValues(original, entityMode), GetPropertyValues(result, entityMode), propertyTypes, session, owner, copyCache, foreignKeyDirection); + object[] values = TypeHelper.Replace(GetPropertyValues(original), GetPropertyValues(result), propertyTypes, session, owner, copyCache, foreignKeyDirection); - SetPropertyValues(result, values, entityMode); + SetPropertyValues(result, values); return result; } /// This method does not populate the component parent - public object Instantiate(EntityMode entityMode) + public object Instantiate() { - return tuplizerMapping.GetTuplizer(entityMode).Instantiate(); + return ComponentTuplizer.Instantiate(); } public virtual object Instantiate(object parent, ISessionImplementor session) { - object result = Instantiate(session.EntityMode); + object result = Instantiate(); - IComponentTuplizer ct = (IComponentTuplizer)tuplizerMapping.GetTuplizer(session.EntityMode); - if (ct.HasParentProperty && parent != null) + if (ComponentTuplizer.HasParentProperty && parent != null) { - ct.SetParent(result, session.PersistenceContext.ProxyFor(parent), session.Factory); + ComponentTuplizer.SetParent(result, session.PersistenceContext.ProxyFor(parent), session.Factory); } return result; @@ -439,7 +427,7 @@ public override object Disassemble(object value, ISessionImplementor session, ob } else { - object[] values = GetPropertyValues(value, session.EntityMode); + object[] values = GetPropertyValues(value); for (int i = 0; i < propertyTypes.Length; i++) { values[i] = propertyTypes[i].Disassemble(values[i], session, owner); @@ -463,7 +451,7 @@ public override object Assemble(object obj, ISessionImplementor session, object assembled[i] = propertyTypes[i].Assemble(values[i], session, owner); } object result = Instantiate(owner, session); - SetPropertyValues(result, assembled, session.EntityMode); + SetPropertyValues(result, assembled); return result; } } @@ -520,7 +508,7 @@ public override object ResolveIdentifier(object value, ISessionImplementor sessi { resolvedValues[i] = propertyTypes[i].ResolveIdentifier(values[i], session, owner); } - SetPropertyValues(result, resolvedValues, session.EntityMode); + SetPropertyValues(result, resolvedValues); return result; } else @@ -568,17 +556,17 @@ public bool[] PropertyNullability get { return propertyNullability; } } - public override int Compare(object x, object y, EntityMode? entityMode) + public override int Compare(object x, object y) { if (x == y) { return 0; } - object[] xvalues = GetPropertyValues(x, entityMode.GetValueOrDefault()); - object[] yvalues = GetPropertyValues(y, entityMode.GetValueOrDefault()); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); for (int i = 0; i < propertySpan; i++) { - int propertyCompare = propertyTypes[i].Compare(xvalues[i], yvalues[i], entityMode); + int propertyCompare = propertyTypes[i].Compare(xvalues[i], yvalues[i]); if (propertyCompare != 0) return propertyCompare; } @@ -590,7 +578,7 @@ public override object FromXMLNode(XmlNode xml, IMapping factory) return xml; } - public override bool IsEqual(object x, object y, EntityMode entityMode) + public override bool IsEqual(object x, object y) { if (x == y) { @@ -600,11 +588,11 @@ public override bool IsEqual(object x, object y, EntityMode entityMode) { return false; } - object[] xvalues = GetPropertyValues(x, entityMode); - object[] yvalues = GetPropertyValues(y, entityMode); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); for (int i = 0; i < propertySpan; i++) { - if (!propertyTypes[i].IsEqual(xvalues[i], yvalues[i], entityMode)) + if (!propertyTypes[i].IsEqual(xvalues[i], yvalues[i])) { return false; } @@ -612,7 +600,7 @@ public override bool IsEqual(object x, object y, EntityMode entityMode) return true; } - public override bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory) + public override bool IsEqual(object x, object y, ISessionFactoryImplementor factory) { if (x == y) { @@ -622,11 +610,11 @@ public override bool IsEqual(object x, object y, EntityMode entityMode, ISession { return false; } - object[] xvalues = GetPropertyValues(x, entityMode); - object[] yvalues = GetPropertyValues(y, entityMode); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); for (int i = 0; i < propertySpan; i++) { - if (!propertyTypes[i].IsEqual(xvalues[i], yvalues[i], entityMode, factory)) + if (!propertyTypes[i].IsEqual(xvalues[i], yvalues[i], factory)) { return false; } @@ -639,7 +627,7 @@ public virtual bool IsMethodOf(MethodBase method) return false; } - public override bool IsSame(object x, object y, EntityMode entityMode) + public override bool IsSame(object x, object y) { if (x == y) { @@ -649,11 +637,11 @@ public override bool IsSame(object x, object y, EntityMode entityMode) { return false; } - object[] xvalues = GetPropertyValues(x, entityMode); - object[] yvalues = GetPropertyValues(y, entityMode); + object[] xvalues = GetPropertyValues(x); + object[] yvalues = GetPropertyValues(y); for (int i = 0; i < propertySpan; i++) { - if (!propertyTypes[i].IsSame(xvalues[i], yvalues[i], entityMode)) + if (!propertyTypes[i].IsSame(xvalues[i], yvalues[i])) { return false; } @@ -673,7 +661,7 @@ public override bool[] ToColumnNullness(object value, IMapping mapping) { return result; } - object[] values = GetPropertyValues(value, EntityMode.Poco); + object[] values = GetPropertyValues(value); int loc = 0; for (int i = 0; i < propertyTypes.Length; i++) { @@ -689,6 +677,10 @@ public override bool IsXMLElement get { return true; } } + public EntityMode EntityMode { get; } + + public IComponentTuplizer ComponentTuplizer { get; } + public int GetPropertyIndex(string name) { string[] names = PropertyNames; diff --git a/src/NHibernate/Type/CompositeCustomType.cs b/src/NHibernate/Type/CompositeCustomType.cs index 13164f11c9b..d20852679ae 100644 --- a/src/NHibernate/Type/CompositeCustomType.cs +++ b/src/NHibernate/Type/CompositeCustomType.cs @@ -73,10 +73,10 @@ public virtual string[] PropertyNames public virtual object[] GetPropertyValues(object component, ISessionImplementor session) { - return GetPropertyValues(component, session.EntityMode); + return GetPropertyValues(component); } - public virtual object[] GetPropertyValues(object component, EntityMode entityMode) + public virtual object[] GetPropertyValues(object component) { int len = Subtypes.Length; object[] result = new object[len]; @@ -87,7 +87,7 @@ public virtual object[] GetPropertyValues(object component, EntityMode entityMod return result; } - public virtual void SetPropertyValues(object component, object[] values, EntityMode entityMode) + public virtual void SetPropertyValues(object component, object[] values) { for (int i = 0; i < values.Length; i++) userType.SetPropertyValue(component, i, values[i]); @@ -128,7 +128,7 @@ public override object Assemble(object cached, ISessionImplementor session, obje return userType.Assemble(cached, session, owner); } - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return userType.DeepCopy(value); } @@ -241,7 +241,7 @@ public override object FromXMLNode(XmlNode xml, IMapping factory) return xml; } - public override bool IsEqual(object x, object y, EntityMode entityMode) + public override bool IsEqual(object x, object y) { return userType.Equals(x, y); } @@ -261,7 +261,7 @@ public override bool[] ToColumnNullness(object value, IMapping mapping) bool[] result = new bool[GetColumnSpan(mapping)]; if (value == null) return result; - object[] values = GetPropertyValues(value, EntityMode.Poco); + object[] values = GetPropertyValues(value); int loc = 0; IType[] propertyTypes = Subtypes; for (int i = 0; i < propertyTypes.Length; i++) diff --git a/src/NHibernate/Type/CustomType.cs b/src/NHibernate/Type/CustomType.cs index 6e9f8c51f78..a53d930fb89 100644 --- a/src/NHibernate/Type/CustomType.cs +++ b/src/NHibernate/Type/CustomType.cs @@ -137,7 +137,7 @@ public override string Name get { return name; } } - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return userType.DeepCopy(value); } @@ -163,7 +163,7 @@ public override int GetHashCode() return userType.GetType().GetHashCode(); } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { return userType.GetHashCode(x); } @@ -229,16 +229,11 @@ public virtual object FromXMLString(string xml, IMapping factory) return ((IEnhancedUserType)userType).FromXMLString(xml); } - public virtual bool IsEqual(object x, object y) + public override bool IsEqual(object x, object y) { return userType.Equals(x, y); } - public override bool IsEqual(object x, object y, EntityMode entityMode) - { - return IsEqual(x, y); - } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) { node.Value= ToXMLString(value, factory); diff --git a/src/NHibernate/Type/DateTimeType.cs b/src/NHibernate/Type/DateTimeType.cs index c14ec598ccb..ab98a8d1da5 100644 --- a/src/NHibernate/Type/DateTimeType.cs +++ b/src/NHibernate/Type/DateTimeType.cs @@ -112,7 +112,7 @@ public virtual IComparer Comparator #endregion - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { // Custom hash code implementation because DateTimeType is only accurate // up to seconds. diff --git a/src/NHibernate/Type/DateType.cs b/src/NHibernate/Type/DateType.cs index 1447dcb8638..609a7b402e1 100644 --- a/src/NHibernate/Type/DateType.cs +++ b/src/NHibernate/Type/DateType.cs @@ -81,7 +81,7 @@ public override bool IsEqual(object x, object y) && date1.Year == date2.Year; } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { DateTime date = (DateTime)x; int hashCode = 1; diff --git a/src/NHibernate/Type/EntityType.cs b/src/NHibernate/Type/EntityType.cs index a9a12bd019d..985e14ae5c2 100644 --- a/src/NHibernate/Type/EntityType.cs +++ b/src/NHibernate/Type/EntityType.cs @@ -54,39 +54,39 @@ public override sealed bool IsEntityType get { return true; } } - public override bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory) + public override bool IsEqual(object x, object y, ISessionFactoryImplementor factory) { IEntityPersister persister = factory.GetEntityPersister(associatedEntityName); if (!persister.CanExtractIdOutOfEntity) { - return base.IsEqual(x, y, entityMode); + return base.IsEqual(x, y); } object xid; - + if (x.IsProxy()) { - INHibernateProxy proxy = x as INHibernateProxy; + INHibernateProxy proxy = x as INHibernateProxy; xid = proxy.HibernateLazyInitializer.Identifier; } else { - xid = persister.GetIdentifier(x, entityMode); + xid = persister.GetIdentifier(x); } object yid; - + if (y.IsProxy()) { - INHibernateProxy proxy = y as INHibernateProxy; + INHibernateProxy proxy = y as INHibernateProxy; yid = proxy.HibernateLazyInitializer.Identifier; } else { - yid = persister.GetIdentifier(y, entityMode); + yid = persister.GetIdentifier(y); } - return persister.IdentifierType.IsEqual(xid, yid, entityMode, factory); + return persister.IdentifierType.IsEqual(xid, yid, factory); } public virtual bool IsNull(object owner, ISessionImplementor session) @@ -97,9 +97,8 @@ public virtual bool IsNull(object owner, ISessionImplementor session) /// Two entities are considered the same when their instances are the same. /// One entity instance /// Another entity instance - /// The entity mode. /// True if x == y; false otherwise. - public override bool IsSame(object x, object y, EntityMode entityMode) + public override bool IsSame(object x, object y) { return ReferenceEquals(x, y); } @@ -127,7 +126,6 @@ override public System.Type ReturnedClass } return returnedClass; } - } /// @@ -137,20 +135,19 @@ override public System.Type ReturnedClass /// /// The object from which to extract the identifier. /// The entity persister - /// The entity mode /// The extracted identifier. - private static object GetIdentifier(object obj, IEntityPersister persister, EntityMode entityMode) + private static object GetIdentifier(object obj, IEntityPersister persister) { if (obj.IsProxy()) { - INHibernateProxy proxy = obj as INHibernateProxy; + INHibernateProxy proxy = obj as INHibernateProxy; ILazyInitializer li = proxy.HibernateLazyInitializer; - + return li.Identifier; } else { - return persister.GetIdentifier(obj, entityMode); + return persister.GetIdentifier(obj); } } @@ -182,7 +179,7 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se else { IEntityPersister entityPersister = session.Factory.GetEntityPersister(GetAssociatedEntityName()); - object propertyValue = entityPersister.GetPropertyValue(value, uniqueKeyPropertyName, session.EntityMode); + object propertyValue = entityPersister.GetPropertyValue(value, uniqueKeyPropertyName); // We now have the value of the property-ref we reference. However, // we need to dig a little deeper, as that property might also be @@ -190,7 +187,7 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se IType type = entityPersister.GetPropertyType(uniqueKeyPropertyName); if (type.IsEntityType) { - propertyValue = ((EntityType)type).GetReferenceValue(propertyValue, session); + propertyValue = ((EntityType) type).GetReferenceValue(propertyValue, session); } return propertyValue; @@ -199,7 +196,7 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se protected internal virtual bool IsNotEmbedded(ISessionImplementor session) { - return !isEmbeddedInXML && false; //session.EntityMode == EntityMode.DOM4J; + return false; //session.EntityMode == EntityMode.DOM4J; } public override string ToLoggableString(object value, ISessionFactoryImplementor factory) @@ -214,19 +211,7 @@ public override string ToLoggableString(object value, ISessionFactoryImplementor if (persister.HasIdentifierProperty) { - EntityMode? entityMode = persister.GuessEntityMode(value); - object id; - if (!entityMode.HasValue) - { - if (isEmbeddedInXML) - throw new InvalidCastException(value.GetType().FullName); - - id = value; - } - else - { - id = GetIdentifier(value, persister, entityMode.Value); - } + var id = GetIdentifier(value, persister); result.Append('#').Append(persister.IdentifierType.ToLoggableString(id, factory)); } @@ -251,7 +236,7 @@ public override string Name get { return associatedEntityName; } } - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return value; //special case ... this is the leaf of the containment graph, even though not immutable } @@ -287,7 +272,7 @@ public override object Replace(object original, object target, ISessionImplement } if (session.GetContextEntityIdentifier(original) == null && ForeignKeys.IsTransient(associatedEntityName, original, false, session)) { - object copy = session.Factory.GetEntityPersister(associatedEntityName).Instantiate(null, session.EntityMode); + object copy = session.Factory.GetEntityPersister(associatedEntityName).Instantiate(null); //TODO: should this be Session.instantiate(Persister, ...)? copyCache.Add(original, copy); return copy; @@ -339,7 +324,7 @@ public bool IsUniqueKeyReference /// The associated joinable public IJoinable GetAssociatedJoinable(ISessionFactoryImplementor factory) { - return (IJoinable)factory.GetEntityPersister(associatedEntityName); + return (IJoinable) factory.GetEntityPersister(associatedEntityName); } /// @@ -360,7 +345,7 @@ public IType GetIdentifierOrUniqueKeyType(IMapping factory) IType type = factory.GetReferencedPropertyType(GetAssociatedEntityName(), uniqueKeyPropertyName); if (type.IsEntityType) { - type = ((EntityType)type).GetIdentifierOrUniqueKeyType(factory); + type = ((EntityType) type).GetIdentifierOrUniqueKeyType(factory); } return type; } @@ -406,8 +391,7 @@ protected object ResolveIdentifier(object id, ISessionImplementor session) { string entityName = GetAssociatedEntityName(); bool isProxyUnwrapEnabled = unwrapProxy && session.Factory - .GetEntityPersister(entityName) - .IsInstrumented(session.EntityMode); + .GetEntityPersister(entityName).IsInstrumented; object proxyOrEntity = session.InternalLoad(entityName, id, eager, IsNullable && !isProxyUnwrapEnabled); @@ -498,26 +482,26 @@ public virtual string PropertyName get { return null; } } - public override int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory) + public override int GetHashCode(object x, ISessionFactoryImplementor factory) { IEntityPersister persister = factory.GetEntityPersister(associatedEntityName); if (!persister.CanExtractIdOutOfEntity) { - return base.GetHashCode(x, entityMode); + return base.GetHashCode(x); } object id; - + if (x.IsProxy()) { - INHibernateProxy proxy = x as INHibernateProxy; + INHibernateProxy proxy = x as INHibernateProxy; id = proxy.HibernateLazyInitializer.Identifier; } else { - id = persister.GetIdentifier(x, entityMode); + id = persister.GetIdentifier(x); } - return persister.IdentifierType.GetHashCode(id, entityMode, factory); + return persister.IdentifierType.GetHashCode(id, factory); } public abstract bool IsAlwaysDirtyChecked { get; } @@ -560,15 +544,18 @@ public override IType GetSemiResolvedType(ISessionFactoryImplementor factory) /// The loaded entity public object LoadByUniqueKey(string entityName, string uniqueKeyPropertyName, object key, ISessionImplementor session) { - ISessionFactoryImplementor factory = session.Factory; - IUniqueKeyLoadable persister = (IUniqueKeyLoadable)factory.GetEntityPersister(entityName); + IUniqueKeyLoadable persister = (IUniqueKeyLoadable) factory.GetEntityPersister(entityName); //TODO: implement caching?! proxies?! EntityUniqueKey euk = - new EntityUniqueKey(entityName, uniqueKeyPropertyName, key, GetIdentifierOrUniqueKeyType(factory), - session.EntityMode, session.Factory); + new EntityUniqueKey( + entityName, + uniqueKeyPropertyName, + key, + GetIdentifierOrUniqueKeyType(factory), + session.Factory); IPersistenceContext persistenceContext = session.PersistenceContext; try @@ -591,7 +578,7 @@ public object LoadByUniqueKey(string entityName, string uniqueKeyPropertyName, o } } - public override int Compare(object x, object y, EntityMode? entityMode) + public override int Compare(object x, object y) { IComparable xComp = x as IComparable; IComparable yComp = y as IComparable; @@ -623,7 +610,7 @@ public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImp } else { - XmlNode elt = (XmlNode)value; + XmlNode elt = (XmlNode) value; ReplaceNode(node, elt); // NH different behavior (we don't use Wrapper) } } @@ -637,6 +624,5 @@ public override bool IsXMLElement { get { return isEmbeddedInXML; } } - } -} \ No newline at end of file +} diff --git a/src/NHibernate/Type/IAbstractComponentType.cs b/src/NHibernate/Type/IAbstractComponentType.cs index 5b9d6904682..5201353d2e6 100644 --- a/src/NHibernate/Type/IAbstractComponentType.cs +++ b/src/NHibernate/Type/IAbstractComponentType.cs @@ -29,12 +29,12 @@ public interface IAbstractComponentType : IType /// /// Optional Operation /// - object[] GetPropertyValues(object component, EntityMode entityMode); + object[] GetPropertyValues(object component); /// /// Optional operation /// - void SetPropertyValues(object component, object[] values, EntityMode entityMode); + void SetPropertyValues(object component, object[] values); object GetPropertyValue(object component, int i, ISessionImplementor session); diff --git a/src/NHibernate/Type/IType.cs b/src/NHibernate/Type/IType.cs index dae8aeb58d4..b04d46826ef 100644 --- a/src/NHibernate/Type/IType.cs +++ b/src/NHibernate/Type/IType.cs @@ -103,7 +103,7 @@ public interface IType : ICacheAssembler /// - object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImplementor factory); + object DeepCopy(object val, ISessionFactoryImplementor factory); /// /// /// - /// /// boolean - bool IsSame(object x, object y, EntityMode entityMode); + bool IsSame(object x, object y); /// /// Compare two instances of the class mapped by this type for persistence @@ -159,9 +158,8 @@ public interface IType : ICacheAssembler /// /// /// - /// /// boolean - bool IsEqual(object x, object y, EntityMode entityMode); + bool IsEqual(object x, object y); /// /// Compare two instances of the class mapped by this type for persistence @@ -169,27 +167,23 @@ public interface IType : ICacheAssembler /// /// /// - /// /// /// boolean - bool IsEqual(object x, object y, EntityMode entityMode, ISessionFactoryImplementor factory); + bool IsEqual(object x, object y, ISessionFactoryImplementor factory); /// Get a hashcode, consistent with persistence "equality" /// - /// - int GetHashCode(object x, EntityMode entityMode); + int GetHashCode(object x); /// Get a hashcode, consistent with persistence "equality" /// - /// /// - int GetHashCode(object x, EntityMode entityMode, ISessionFactoryImplementor factory); + int GetHashCode(object x, ISessionFactoryImplementor factory); /// compare two instances of the type /// /// - /// - int Compare(object x, object y, EntityMode? entityMode); + int Compare(object x, object y); /// Get the type of a semi-resolved value. IType GetSemiResolvedType(ISessionFactoryImplementor factory); diff --git a/src/NHibernate/Type/IType.cs.xmldoc b/src/NHibernate/Type/IType.cs.xmldoc index 0d9bdccb9ff..14012e723f3 100644 --- a/src/NHibernate/Type/IType.cs.xmldoc +++ b/src/NHibernate/Type/IType.cs.xmldoc @@ -207,7 +207,6 @@ state, stopping at entities and at collections. A Collection element or Entity field - The entityMode. The session factory. A deep copy of the object. diff --git a/src/NHibernate/Type/IVersionType.cs b/src/NHibernate/Type/IVersionType.cs index 354f4c0644a..a85973be38b 100644 --- a/src/NHibernate/Type/IVersionType.cs +++ b/src/NHibernate/Type/IVersionType.cs @@ -23,14 +23,6 @@ public interface IVersionType : IType /// An instance of the type. object Seed(ISessionImplementor session); - /// - /// Are the two version values considered equal? - /// - /// One value to check. - /// The other value to check. - /// true if the values are equal, false otherwise. - bool IsEqual(object x, object y); - /// /// Get a comparator for the version numbers /// @@ -38,4 +30,4 @@ public interface IVersionType : IType object FromStringValue(string xml); } -} \ No newline at end of file +} diff --git a/src/NHibernate/Type/ImmutableType.cs b/src/NHibernate/Type/ImmutableType.cs index 22ea273ecb6..ebebc563310 100644 --- a/src/NHibernate/Type/ImmutableType.cs +++ b/src/NHibernate/Type/ImmutableType.cs @@ -39,7 +39,7 @@ public override object Replace(object original, object current, ISessionImplemen return original; } - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return value; } diff --git a/src/NHibernate/Type/ManyToOneType.cs b/src/NHibernate/Type/ManyToOneType.cs index e255bb36b37..17d9f0f19a2 100644 --- a/src/NHibernate/Type/ManyToOneType.cs +++ b/src/NHibernate/Type/ManyToOneType.cs @@ -191,7 +191,7 @@ public override bool IsAlwaysDirtyChecked public override bool IsDirty(object old, object current, ISessionImplementor session) { - if (IsSame(old, current, session.EntityMode)) + if (IsSame(old, current)) { return false; } @@ -209,7 +209,7 @@ public override bool IsDirty(object old, object current, bool[] checkable, ISess } else { - if (IsSame(old, current, session.EntityMode)) + if (IsSame(old, current)) { return false; } diff --git a/src/NHibernate/Type/MetaType.cs b/src/NHibernate/Type/MetaType.cs index ef83dd0c71f..084972f0bf3 100644 --- a/src/NHibernate/Type/MetaType.cs +++ b/src/NHibernate/Type/MetaType.cs @@ -72,7 +72,7 @@ public override string Name get { return baseType.Name; } //TODO! } - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return value; } diff --git a/src/NHibernate/Type/MutableType.cs b/src/NHibernate/Type/MutableType.cs index 8eb3eb544b8..2e456f89ecd 100644 --- a/src/NHibernate/Type/MutableType.cs +++ b/src/NHibernate/Type/MutableType.cs @@ -36,14 +36,14 @@ public override sealed bool IsMutable public override object Replace(object original, object target, ISessionImplementor session, object owner, IDictionary copiedAlready) { - if (IsEqual(original, target, session.EntityMode)) + if (IsEqual(original, target)) return original; - return DeepCopy(original, session.EntityMode, session.Factory); + return DeepCopy(original, session.Factory); } public abstract object DeepCopyNotNull(object value); - public override object DeepCopy(object value, EntityMode entityMode, ISessionFactoryImplementor factory) + public override object DeepCopy(object value, ISessionFactoryImplementor factory) { return (value == null) ? null : DeepCopyNotNull(value); } diff --git a/src/NHibernate/Type/NullableType.cs b/src/NHibernate/Type/NullableType.cs index 091116c45eb..0ec163308d7 100644 --- a/src/NHibernate/Type/NullableType.cs +++ b/src/NHibernate/Type/NullableType.cs @@ -363,12 +363,7 @@ public object FromXMLString(string xml, IMapping factory) return string.IsNullOrEmpty(xml) ? null : FromStringValue(xml); } - public override bool IsEqual(object x, object y, EntityMode entityMode) - { - return IsEqual(x, y); - } - - public virtual bool IsEqual(object x, object y) + public override bool IsEqual(object x, object y) { return EqualsHelper.Equals(x, y); } diff --git a/src/NHibernate/Type/SerializableType.cs b/src/NHibernate/Type/SerializableType.cs index 5fe2f1deedb..cd19700d210 100644 --- a/src/NHibernate/Type/SerializableType.cs +++ b/src/NHibernate/Type/SerializableType.cs @@ -86,9 +86,9 @@ public override bool IsEqual(object x, object y) return x.Equals(y) || binaryType.IsEqual(ToBytes(x), ToBytes(y)); } - public override int GetHashCode(Object x, EntityMode entityMode) + public override int GetHashCode(Object x) { - return binaryType.GetHashCode(ToBytes(x), entityMode); + return binaryType.GetHashCode(ToBytes(x)); } public override string ToString(object value) diff --git a/src/NHibernate/Type/TimeType.cs b/src/NHibernate/Type/TimeType.cs index dd74cae61b9..97b23a8f90d 100644 --- a/src/NHibernate/Type/TimeType.cs +++ b/src/NHibernate/Type/TimeType.cs @@ -91,7 +91,7 @@ public override bool IsEqual(object x, object y) && date1.Second == date2.Second; } - public override int GetHashCode(object x, EntityMode entityMode) + public override int GetHashCode(object x) { DateTime date = (DateTime)x; int hashCode = 1; diff --git a/src/NHibernate/Type/TypeHelper.cs b/src/NHibernate/Type/TypeHelper.cs index 8e5b97d3aaf..8f750c48944 100644 --- a/src/NHibernate/Type/TypeHelper.cs +++ b/src/NHibernate/Type/TypeHelper.cs @@ -32,7 +32,7 @@ public static void DeepCopy(object[] values, IType[] types, bool[] copy, object[ } else { - target[i] = types[i].DeepCopy(values[i], session.EntityMode, session.Factory); + target[i] = types[i].DeepCopy(values[i], session.Factory); } } } @@ -199,7 +199,7 @@ public static object[] ReplaceAssociations(object[] original, object[] target, I object[] componentCopy = ReplaceAssociations(origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection); if (!componentType.IsAnyType && target[i] != null) - componentType.SetPropertyValues(target[i], componentCopy, session.EntityMode); + componentType.SetPropertyValues(target[i], componentCopy); copied[i] = target[i]; } From 50bafb3a66c6f0da4becf9efb5949ba2c8fcef5f Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 00:28:22 +1300 Subject: [PATCH 2/8] NH-3722 - Remove per-session EntityMode switch capability from documentation --- doc/reference/modules/persistent_classes.xml | 27 -------------------- 1 file changed, 27 deletions(-) diff --git a/doc/reference/modules/persistent_classes.xml b/doc/reference/modules/persistent_classes.xml index 7bc5fccfc99..c47ab6d84c6 100644 --- a/doc/reference/modules/persistent_classes.xml +++ b/doc/reference/modules/persistent_classes.xml @@ -345,33 +345,6 @@ using(ITransaction tx = s.BeginTransaction()) to the NHibernate mapping, the database schema can easily be normalized and sound, allowing to add a proper domain model implementation on top later on. - - - Entity representation modes can also be set on a per ISession - basis: - - - (); - frank["name"] = "Frank"; - dynamicSession.Save("Customer", frank); - ... -} -// Continue on pocoSession -]]> - - - - Please note that the call to GetSession() using an - EntityMode is on the ISession API, not the - ISessionFactory. That way, the new ISession - shares the underlying ADO connection, transaction, and other context - information. This means you don't have to call Flush() - and Close() on the secondary ISession, and - also leave the transaction and connection handling to the primary unit of work. - From fba9c79a63aa02fdb3c24639025b42f21fbe31c7 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 01:09:37 +1300 Subject: [PATCH 3/8] NH-3722 - Remove EntityMode.Xml related properties from ICollectionPersister * Ported HHH-7736 from https://github.com/hibernate/hibernate-orm/commit/1a5bdd9adbd04dc4cad7b423e85880d7cb0553ef --- .gitignore | 1 + .../UsageOfCustomCollectionPersisterTests.cs | 2 +- .../NHSpecificTest/SetFixture.cs | 15 ----- src/NHibernate/Impl/SessionFactoryImpl.cs | 2 +- .../Collection/AbstractCollectionPersister.cs | 31 +-------- .../Collection/BasicCollectionPersister.cs | 5 +- .../Collection/ICollectionPersister.cs | 6 -- .../Collection/OneToManyPersister.cs | 5 +- src/NHibernate/Persister/PersisterFactory.cs | 65 ++++++------------- 9 files changed, 28 insertions(+), 104 deletions(-) diff --git a/.gitignore b/.gitignore index 6fe6ac4255e..27766c02431 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ current-test-configuration # to satisfy later build steps. But it should not be committed. NHibernate.dll TestResult.xml +.vscode diff --git a/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs b/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs index 4fbbb451612..92aa0c383ba 100644 --- a/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs +++ b/src/NHibernate.Test/NHSpecificTest/NH2568/UsageOfCustomCollectionPersisterTests.cs @@ -46,6 +46,6 @@ public void BuildingSessionFactoryShouldNotThrows() public class MyCollectionPersister: OneToManyPersister { - public MyCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, ISessionFactoryImplementor factory) : base(collection, cache, cfg, factory) {} + public MyCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) : base(collection, cache, factory) {} } } \ No newline at end of file diff --git a/src/NHibernate.Test/NHSpecificTest/SetFixture.cs b/src/NHibernate.Test/NHSpecificTest/SetFixture.cs index e8b40dd1052..e374340a24b 100644 --- a/src/NHibernate.Test/NHSpecificTest/SetFixture.cs +++ b/src/NHibernate.Test/NHSpecificTest/SetFixture.cs @@ -378,21 +378,6 @@ public bool IsMutable get { throw new NotImplementedException(); } } - public string NodeName - { - get { throw new NotImplementedException(); } - } - - public string ElementNodeName - { - get { throw new NotImplementedException(); } - } - - public string IndexNodeName - { - get { throw new NotImplementedException(); } - } - #endregion } diff --git a/src/NHibernate/Impl/SessionFactoryImpl.cs b/src/NHibernate/Impl/SessionFactoryImpl.cs index daf3c1c6cbb..feaadece7b3 100644 --- a/src/NHibernate/Impl/SessionFactoryImpl.cs +++ b/src/NHibernate/Impl/SessionFactoryImpl.cs @@ -276,7 +276,7 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings { allCacheRegions[cache.RegionName] = cache.Cache; } - ICollectionPersister persister = PersisterFactory.CreateCollectionPersister(cfg, model, cache, this); + ICollectionPersister persister = PersisterFactory.CreateCollectionPersister(model, cache, this); collectionPersisters[model.Role] = persister; IType indexType = persister.IndexType; if (indexType != null && indexType.IsAssociationType && !indexType.IsAnyType) diff --git a/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs b/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs index 288c018810f..d68b1d158c8 100644 --- a/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs @@ -8,7 +8,6 @@ using NHibernate.AdoNet; using NHibernate.Cache; using NHibernate.Cache.Entry; -using NHibernate.Cfg; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Exceptions; @@ -52,9 +51,6 @@ public abstract class AbstractCollectionPersister : ICollectionMetadata, ISqlLoa private readonly bool hasOrder; private readonly bool hasWhere; private readonly int baseIndex; - private readonly string nodeName; - private readonly string elementNodeName; - private readonly string indexNodeName; protected internal bool indexContainsFormula; protected internal bool elementIsPureFormula; @@ -165,8 +161,7 @@ public abstract class AbstractCollectionPersister : ICollectionMetadata, ISqlLoa private static readonly IInternalLogger log = LoggerProvider.LoggerFor(typeof (ICollectionPersister)); - public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, - ISessionFactoryImplementor factory) + public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) { this.factory = factory; this.cache = cache; @@ -188,7 +183,6 @@ public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurre entityName = collection.OwnerEntityName; ownerPersister = factory.GetEntityPersister(entityName); queryLoaderName = collection.LoaderName; - nodeName = collection.NodeName; isMutable = collection.IsMutable; Table table = collection.CollectionTable; @@ -277,22 +271,16 @@ public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurre CheckColumnDuplication(distinctColumns, element.ColumnIterator); } - string elemNode = collection.ElementNodeName; if (elementType.IsEntityType) { string _entityName = ((EntityType) elementType).GetAssociatedEntityName(); elementPersister = factory.GetEntityPersister(_entityName); - if (elemNode == null) - { - elemNode = cfg.GetClassMapping(_entityName).NodeName; - } // NativeSQL: collect element column and auto-aliases } else { elementPersister = null; } - elementNodeName = elemNode; int elementSpan = element.ColumnSpan; elementColumnAliases = new string[elementSpan]; @@ -377,7 +365,6 @@ public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurre indexContainsFormula = hasFormula; baseIndex = indexedCollection.IsList ? ((List) indexedCollection).BaseIndex : 0; - indexNodeName = indexedCollection.IndexNodeName; CheckColumnDuplication(distinctColumns, indexedCollection.Index.ColumnIterator); } else @@ -390,7 +377,6 @@ public AbstractCollectionPersister(Mapping.Collection collection, ICacheConcurre indexColumnNames = null; indexColumnAliases = null; baseIndex = 0; - indexNodeName = null; } hasIdentifier = collection.IsIdentified; @@ -1937,21 +1923,6 @@ public bool IsVersioned get { return isVersioned && OwnerEntityPersister.IsVersioned; } } - public string NodeName - { - get { return nodeName; } - } - - public string ElementNodeName - { - get { return elementNodeName; } - } - - public string IndexNodeName - { - get { return indexNodeName; } - } - protected virtual ISQLExceptionConverter SQLExceptionConverter { get { return sqlExceptionConverter; } diff --git a/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs b/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs index b8de412a1f4..368eb9aecd2 100644 --- a/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/BasicCollectionPersister.cs @@ -3,7 +3,6 @@ using System.Data.Common; using NHibernate.AdoNet; using NHibernate.Cache; -using NHibernate.Cfg; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Exceptions; @@ -23,8 +22,8 @@ namespace NHibernate.Persister.Collection /// public class BasicCollectionPersister : AbstractCollectionPersister { - public BasicCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, ISessionFactoryImplementor factory) - : base(collection, cache, cfg, factory) { } + public BasicCollectionPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) + : base(collection, cache, factory) { } public override bool CascadeDeleteEnabled { diff --git a/src/NHibernate/Persister/Collection/ICollectionPersister.cs b/src/NHibernate/Persister/Collection/ICollectionPersister.cs index e98fd4d68aa..b5fe8493440 100644 --- a/src/NHibernate/Persister/Collection/ICollectionPersister.cs +++ b/src/NHibernate/Persister/Collection/ICollectionPersister.cs @@ -130,12 +130,6 @@ public interface ICollectionPersister /// Can the elements of this collection change? bool IsMutable { get;} - string NodeName { get;} - - string ElementNodeName { get;} - - string IndexNodeName { get;} - ISessionFactoryImplementor Factory { get; } bool IsExtraLazy { get;} diff --git a/src/NHibernate/Persister/Collection/OneToManyPersister.cs b/src/NHibernate/Persister/Collection/OneToManyPersister.cs index 9f3914f6983..df487b22c5f 100644 --- a/src/NHibernate/Persister/Collection/OneToManyPersister.cs +++ b/src/NHibernate/Persister/Collection/OneToManyPersister.cs @@ -5,7 +5,6 @@ using System.Text; using NHibernate.AdoNet; using NHibernate.Cache; -using NHibernate.Cfg; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Exceptions; @@ -24,8 +23,8 @@ public class OneToManyPersister : AbstractCollectionPersister private readonly bool _keyIsNullable; private readonly bool _keyIsUpdateable; - public OneToManyPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, Configuration cfg, ISessionFactoryImplementor factory) - : base(collection, cache, cfg, factory) + public OneToManyPersister(Mapping.Collection collection, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) + : base(collection, cache, factory) { _cascadeDeleteEnabled = collection.Key.IsCascadeDeleteEnabled && factory.Dialect.SupportsCascadeDelete; _keyIsNullable = collection.Key.IsNullable; diff --git a/src/NHibernate/Persister/PersisterFactory.cs b/src/NHibernate/Persister/PersisterFactory.cs index 1231d4181f9..c8cafc5716d 100644 --- a/src/NHibernate/Persister/PersisterFactory.cs +++ b/src/NHibernate/Persister/PersisterFactory.cs @@ -2,7 +2,6 @@ using System.Reflection; using System.Text; using NHibernate.Cache; -using NHibernate.Cfg; using NHibernate.Engine; using NHibernate.Mapping; using NHibernate.Persister.Collection; @@ -18,30 +17,19 @@ public static class PersisterFactory //TODO: make ClassPersisters *not* depend on ISessionFactoryImplementor // interface, if possible - private static readonly System.Type[] PersisterConstructorArgs = new System.Type[] - { - typeof(PersistentClass), - typeof(ICacheConcurrencyStrategy), - typeof(ISessionFactoryImplementor), - typeof(IMapping) - }; - - // TODO: is it really necessary to provide Configuration to CollectionPersisters ? Should it not be enough with associated class ? - // or why does ClassPersister's not get access to configuration ? - private static readonly System.Type[] CollectionPersisterConstructorArgs = new System.Type[] - { - typeof(Mapping.Collection), - typeof(ICacheConcurrencyStrategy), - typeof(ISessionFactoryImplementor) - }; + static readonly System.Type[] PersisterConstructorArgs = { + typeof(PersistentClass), + typeof(ICacheConcurrencyStrategy), + typeof(ISessionFactoryImplementor), + typeof(IMapping) + }; - private static readonly System.Type[] CollectionPersisterConstructor2Args = new System.Type[] - { - typeof(Mapping.Collection), - typeof(ICacheConcurrencyStrategy), - typeof(Configuration), - typeof(ISessionFactoryImplementor) - }; + static readonly System.Type[] CollectionPersisterConstructorArgs = + { + typeof(Mapping.Collection), + typeof(ICacheConcurrencyStrategy), + typeof(ISessionFactoryImplementor) + }; /// /// Creates a built in Entity Persister or a custom Persister. @@ -69,7 +57,7 @@ public static IEntityPersister CreateClassPersister(PersistentClass model, ICach } } - public static ICollectionPersister CreateCollectionPersister(Configuration cfg, Mapping.Collection model, ICacheConcurrencyStrategy cache, + public static ICollectionPersister CreateCollectionPersister(Mapping.Collection model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) { System.Type persisterClass = model.CollectionPersisterClass; @@ -78,12 +66,12 @@ public static ICollectionPersister CreateCollectionPersister(Configuration cfg, // default behaviour return model.IsOneToMany - ? (ICollectionPersister) new OneToManyPersister(model, cache, cfg, factory) - : (ICollectionPersister) new BasicCollectionPersister(model, cache, cfg, factory); + ? (ICollectionPersister) new OneToManyPersister(model, cache, factory) + : (ICollectionPersister) new BasicCollectionPersister(model, cache, factory); } else { - return Create(persisterClass, model, cache, factory, cfg); + return Create(persisterClass, model, cache, factory); } } @@ -127,18 +115,12 @@ public static IEntityPersister Create(System.Type persisterClass, PersistentClas } public static ICollectionPersister Create(System.Type persisterClass, Mapping.Collection model, - ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, Configuration cfg) + ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) { ConstructorInfo pc; - var use4Parameters = false; try { pc = persisterClass.GetConstructor(CollectionPersisterConstructorArgs); - if (pc == null) - { - use4Parameters = true; - pc = persisterClass.GetConstructor(CollectionPersisterConstructor2Args); - } } catch (Exception e) { @@ -147,21 +129,14 @@ public static ICollectionPersister Create(System.Type persisterClass, Mapping.Co if(pc == null) { var messageBuilder = new StringBuilder(); - messageBuilder.AppendLine("Could not find a public constructor for " + persisterClass.Name +";"); - messageBuilder.AppendLine("- The ctor may have " + CollectionPersisterConstructorArgs.Length + " parameters of types (in order):"); + messageBuilder.Append("Could not find a public constructor for ").Append(persisterClass.Name).AppendLine(";"); + messageBuilder.Append("- The ctor may have ").Append(CollectionPersisterConstructorArgs.Length).AppendLine(" parameters of types (in order):"); System.Array.ForEach(CollectionPersisterConstructorArgs, t=> messageBuilder.AppendLine(t.FullName)); - messageBuilder.AppendLine(); - messageBuilder.AppendLine("- The ctor may have " + CollectionPersisterConstructor2Args.Length + " parameters of types (in order):"); - System.Array.ForEach(CollectionPersisterConstructor2Args, t => messageBuilder.AppendLine(t.FullName)); throw new MappingException(messageBuilder.ToString()); } try { - if (!use4Parameters) - { - return (ICollectionPersister) pc.Invoke(new object[] {model, cache, factory}); - } - return (ICollectionPersister)pc.Invoke(new object[] { model, cache, cfg, factory }); + return (ICollectionPersister) pc.Invoke(new object[] {model, cache, factory}); } catch (TargetInvocationException tie) { From fd1b81abef030de011e8f3198b677d716f1e1602 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 01:22:39 +1300 Subject: [PATCH 4/8] NH-3722 - Not propagating XML node names configured in mappings * Ported from HHH-10073 https://github.com/hibernate/hibernate-orm/commit/1376b12ca9e383ef51c2ec50c88f4ef8a01f01f8 --- .../Cfg/XmlHbmBinding/ClassBinder.cs | 11 -------- src/NHibernate/Mapping/Collection.cs | 27 ------------------- src/NHibernate/Mapping/Component.cs | 7 ----- src/NHibernate/Mapping/IndexedCollection.cs | 11 -------- src/NHibernate/Mapping/PersistentClass.cs | 7 ----- src/NHibernate/Mapping/Property.cs | 7 ----- src/NHibernate/Tuple/IdentifierProperty.cs | 7 ++--- src/NHibernate/Tuple/Property.cs | 10 +------ src/NHibernate/Tuple/PropertyFactory.cs | 4 +-- src/NHibernate/Tuple/StandardProperty.cs | 5 +--- src/NHibernate/Tuple/VersionProperty.cs | 5 +--- 11 files changed, 6 insertions(+), 95 deletions(-) diff --git a/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs index de8fa8d2716..22b8a0eedff 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs @@ -39,7 +39,6 @@ protected void BindClass(IEntityMapping classMapping, PersistentClass model, IDi model.EntityName = entityName; BindPocoRepresentation(classMapping, model); - BindXmlRepresentation(classMapping, model); BindMapRepresentation(classMapping, model); BindPersistentClassCommonValues(classMapping, model, inheritedMetas); @@ -128,11 +127,6 @@ private void BindMapRepresentation(IEntityMapping classMapping, PersistentClass } } - private void BindXmlRepresentation(IEntityMapping classMapping, PersistentClass entity) - { - entity.NodeName = string.IsNullOrEmpty(classMapping.Node) ? StringHelper.Unqualify(entity.EntityName): classMapping.Node; - } - private void BindPocoRepresentation(IEntityMapping classMapping, PersistentClass entity) { string className = classMapping.Name == null @@ -321,11 +315,6 @@ protected void BindComponent(IComponentMapping componentMapping, Component model } } - string nodeName = !string.IsNullOrEmpty(componentMapping.EmbeddedNode) - ? componentMapping.EmbeddedNode - : !string.IsNullOrEmpty(componentMapping.Name) ? componentMapping.Name : model.Owner.NodeName; - model.NodeName = nodeName; - // Parent if (componentMapping.Parent != null && !string.IsNullOrEmpty(componentMapping.Parent.name)) { diff --git a/src/NHibernate/Mapping/Collection.cs b/src/NHibernate/Mapping/Collection.cs index 1c3fed0f18e..5829cb9cd87 100644 --- a/src/NHibernate/Mapping/Collection.cs +++ b/src/NHibernate/Mapping/Collection.cs @@ -26,7 +26,6 @@ public abstract class Collection : IFetchable, IValue, IFilterable private IKeyValue key; private IValue element; - private string elementNodeName; private Table collectionTable; private string role; private bool lazy; @@ -47,7 +46,6 @@ public abstract class Collection : IFetchable, IValue, IFilterable private string referencedPropertyName; private string typeName; private bool embedded = true; - private string nodeName; private string loaderName; @@ -397,19 +395,6 @@ public virtual void Validate(IMapping mapping) } CheckColumnDuplication(); - - if (elementNodeName != null && elementNodeName.StartsWith("@")) - { - throw new MappingException(string.Format("element node must not be an attribute: {0}", elementNodeName)); - } - if (elementNodeName != null && elementNodeName.Equals(".")) - { - throw new MappingException(string.Format("element node must not be the parent: {0}", elementNodeName)); - } - if (nodeName != null && nodeName.IndexOf('@') > -1) - { - throw new MappingException(string.Format("collection node must not be an attribute: {0}", elementNodeName)); - } } public bool[] ColumnInsertability @@ -566,12 +551,6 @@ public bool IsOptimisticLocked set { optimisticLocked = value; } } - public string ElementNodeName - { - get { return elementNodeName; } - set { elementNodeName = value; } - } - public bool Embedded { get { return embedded; } @@ -642,12 +621,6 @@ public bool IsMutable set { mutable = value; } } - public string NodeName - { - get { return nodeName; } - set { nodeName = value; } - } - public ISet SynchronizedTables { get { return synchronizedTables; } diff --git a/src/NHibernate/Mapping/Component.cs b/src/NHibernate/Mapping/Component.cs index 3c854925f9c..3a4793d6458 100644 --- a/src/NHibernate/Mapping/Component.cs +++ b/src/NHibernate/Mapping/Component.cs @@ -20,7 +20,6 @@ public class Component : SimpleValue, IMetaAttributable private PersistentClass owner; private bool dynamic; private bool isKey; - private string nodeName; private string roleName; private Dictionary tuplizerImpls; private string componentClassName; @@ -228,12 +227,6 @@ public bool IsKey set { isKey = value; } } - public string NodeName - { - get { return nodeName; } - set { nodeName = value; } - } - public string RoleName { get { return roleName; } diff --git a/src/NHibernate/Mapping/IndexedCollection.cs b/src/NHibernate/Mapping/IndexedCollection.cs index d523c25a68f..248598506c0 100644 --- a/src/NHibernate/Mapping/IndexedCollection.cs +++ b/src/NHibernate/Mapping/IndexedCollection.cs @@ -14,7 +14,6 @@ public abstract class IndexedCollection : Collection public const string DefaultIndexColumnName = "idx"; private SimpleValue index; - private string indexNodeName; protected IndexedCollection(PersistentClass owner) : base(owner) { @@ -36,12 +35,6 @@ public virtual bool IsList get { return false; } } - public string IndexNodeName - { - get { return indexNodeName; } - set { indexNodeName = value; } - } - public override void CreatePrimaryKey() { if (!IsOneToMany) @@ -78,10 +71,6 @@ public override void Validate(IMapping mapping) throw new MappingException( string.Format("collection index mapping has wrong number of columns: {0} type: {1}", Role, Index.Type.Name)); } - if (indexNodeName != null && !indexNodeName.StartsWith("@")) - { - throw new MappingException("index node must be an attribute: " + indexNodeName); - } } } } diff --git a/src/NHibernate/Mapping/PersistentClass.cs b/src/NHibernate/Mapping/PersistentClass.cs index 11248ffe4d0..202bf463055 100644 --- a/src/NHibernate/Mapping/PersistentClass.cs +++ b/src/NHibernate/Mapping/PersistentClass.cs @@ -27,7 +27,6 @@ public abstract class PersistentClass : IFilterable, IMetaAttributable, ISqlCust private string entityName; private string className; private string proxyInterfaceName; - private string nodeName; private string discriminatorValue; private bool lazy; private readonly List properties = new List(); @@ -541,12 +540,6 @@ protected virtual internal IEnumerable DiscriminatorColumnIterator get { return new CollectionHelper.EmptyEnumerableClass(); } } - public string NodeName - { - get { return nodeName; } - set { nodeName = value; } - } - public virtual bool HasSubselectLoadableCollections { get { return hasSubselectLoadableCollections; } diff --git a/src/NHibernate/Mapping/Property.cs b/src/NHibernate/Mapping/Property.cs index e77a7e48e42..49d29cac0a4 100644 --- a/src/NHibernate/Mapping/Property.cs +++ b/src/NHibernate/Mapping/Property.cs @@ -23,7 +23,6 @@ public class Property : IMetaAttributable private bool selectable = true; private string propertyAccessorName; private bool optional; - private string nodeName; private IDictionary metaAttributes; private PersistentClass persistentClass; private bool isOptimisticLocked; @@ -276,12 +275,6 @@ public bool IsNaturalIdentifier set { isNaturalIdentifier = value; } } - public string NodeName - { - get { return nodeName; } - set { nodeName = value; } - } - // both many-to-one and one-to-one are represented as a // Property. EntityPersister is relying on this value to // determine "lazy fetch groups" in terms of field-level diff --git a/src/NHibernate/Tuple/IdentifierProperty.cs b/src/NHibernate/Tuple/IdentifierProperty.cs index 5511ad041a4..345ed50551f 100644 --- a/src/NHibernate/Tuple/IdentifierProperty.cs +++ b/src/NHibernate/Tuple/IdentifierProperty.cs @@ -28,8 +28,6 @@ public class IdentifierProperty : Property /// /// The name of the property representing the identifier within /// its owning entity. - /// The node name to use for XML-based representation of this - /// property. /// The Hibernate Type for the identifier property. /// Is this an embedded identifier. /// The value which, if found as the value on the identifier @@ -37,12 +35,11 @@ public class IdentifierProperty : Property /// The generator to use for id value generation. public IdentifierProperty( String name, - String node, IType type, bool embedded, IdentifierValue unsavedValue, IIdentifierGenerator identifierGenerator) - : base(name, node, type) + : base(name, type) { isVirtual = false; this.embedded = embedded; @@ -62,7 +59,7 @@ public IdentifierProperty( /// The generator to use for id value generation. /// public IdentifierProperty(IType type, bool embedded, bool hasIdentifierMapper, IdentifierValue unsavedValue, IIdentifierGenerator identifierGenerator) - : base(null, null, type) + : base(null, type) { isVirtual = true; this.embedded = embedded; diff --git a/src/NHibernate/Tuple/Property.cs b/src/NHibernate/Tuple/Property.cs index 235220f5c8e..a3d5c0ec2a6 100644 --- a/src/NHibernate/Tuple/Property.cs +++ b/src/NHibernate/Tuple/Property.cs @@ -10,19 +10,16 @@ namespace NHibernate.Tuple public abstract class Property { private readonly string name; - private readonly string node; private readonly IType type; /// /// Constructor for Property instances. /// /// The name by which the property can be referenced within its owner. - /// The node name to use for XML-based representation of this property. /// The Hibernate Type of this property. - protected Property(string name, string node, IType type) + protected Property(string name, IType type) { this.name = name; - this.node = node; this.type = type; } @@ -31,11 +28,6 @@ public string Name get { return name; } } - public string Node - { - get { return node; } - } - public IType Type { get { return type; } diff --git a/src/NHibernate/Tuple/PropertyFactory.cs b/src/NHibernate/Tuple/PropertyFactory.cs index 739a873590e..8d3e8fbfae6 100644 --- a/src/NHibernate/Tuple/PropertyFactory.cs +++ b/src/NHibernate/Tuple/PropertyFactory.cs @@ -40,7 +40,7 @@ public static IdentifierProperty BuildIdentifierProperty(PersistentClass mappedE } else { - return new IdentifierProperty(property.Name, property.NodeName, type, mappedEntity.HasEmbeddedIdentifier, unsavedValue, generator); + return new IdentifierProperty(property.Name, type, mappedEntity.HasEmbeddedIdentifier, unsavedValue, generator); } } @@ -66,7 +66,6 @@ public static VersionProperty BuildVersionProperty(Mapping.Property property, bo return new VersionProperty( property.Name, - property.NodeName, property.Value.Type, lazy, property.IsInsertable, @@ -104,7 +103,6 @@ public static StandardProperty BuildStandardProperty(Mapping.Property property, return new StandardProperty( property.Name, - property.NodeName, type, lazyAvailable && property.IsLazy, property.IsInsertable, diff --git a/src/NHibernate/Tuple/StandardProperty.cs b/src/NHibernate/Tuple/StandardProperty.cs index 3f1c4f14e89..4349e815b99 100644 --- a/src/NHibernate/Tuple/StandardProperty.cs +++ b/src/NHibernate/Tuple/StandardProperty.cs @@ -28,8 +28,6 @@ public class StandardProperty : Property ///
/// The name by which the property can be referenced within /// its owner. - /// The node name to use for XML-based representation of this - /// property. /// The Hibernate Type of this property. /// Should this property be handled lazily? /// Is this property an insertable value? @@ -43,7 +41,6 @@ public class StandardProperty : Property /// Any fetch mode defined for this property public StandardProperty( String name, - String node, IType type, bool lazy, bool insertable, @@ -55,7 +52,7 @@ public StandardProperty( bool versionable, CascadeStyle cascadeStyle, FetchMode? fetchMode) - : base(name, node, type) + : base(name, type) { this.lazy = lazy; this.insertable = insertable; diff --git a/src/NHibernate/Tuple/VersionProperty.cs b/src/NHibernate/Tuple/VersionProperty.cs index dd21c1b81bc..f27ec372b4a 100644 --- a/src/NHibernate/Tuple/VersionProperty.cs +++ b/src/NHibernate/Tuple/VersionProperty.cs @@ -20,8 +20,6 @@ public class VersionProperty : StandardProperty ///
/// The name by which the property can be referenced within /// its owner. - /// The node name to use for XML-based representation of this - /// property. /// The Hibernate Type of this property. /// Should this property be handled lazily? /// Is this property an insertable value? @@ -37,7 +35,6 @@ public class VersionProperty : StandardProperty /// instances of the owning entity. public VersionProperty( string name, - string node, IType type, bool lazy, bool insertable, @@ -50,7 +47,7 @@ public VersionProperty( CascadeStyle cascadeStyle, VersionValue unsavedValue) : base( - name, node, type, lazy, insertable, updateable, insertGenerated, updateGenerated, nullable, checkable, versionable, + name, type, lazy, insertable, updateable, insertGenerated, updateGenerated, nullable, checkable, versionable, cascadeStyle, null) { this.unsavedValue = unsavedValue; From 0dbacba4d5be657edded8c20c8ed0fe118169ecd Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 01:48:47 +1300 Subject: [PATCH 5/8] NH-3722 - Remove IsEmbedded * Ported from HHH-10073 https://github.com/hibernate/hibernate-orm/commit/47b8ed51212f6ff8bec3675758ac05912ef8c2dc --- .../Bytecode/ICollectionTypeFactory.cs | 28 +++------ src/NHibernate/Mapping/Array.cs | 2 +- src/NHibernate/Mapping/Collection.cs | 9 +-- src/NHibernate/Mapping/ManyToOne.cs | 2 +- src/NHibernate/Mapping/OneToMany.cs | 9 +-- src/NHibernate/Mapping/OneToOne.cs | 2 +- src/NHibernate/Mapping/ToOne.cs | 7 --- .../DynamicFilterParameterSpecification.cs | 16 ----- src/NHibernate/Type/AbstractType.cs | 18 ------ src/NHibernate/Type/AnyType.cs | 17 ----- src/NHibernate/Type/ArrayType.cs | 5 +- src/NHibernate/Type/ClassMetaType.cs | 23 +------ src/NHibernate/Type/CollectionType.cs | 22 +------ src/NHibernate/Type/ComponentType.cs | 16 ----- src/NHibernate/Type/CompositeCustomType.cs | 12 ---- src/NHibernate/Type/CustomCollectionType.cs | 4 +- src/NHibernate/Type/CustomType.cs | 40 ++---------- .../Type/DefaultCollectionTypeFactory.cs | 22 +++---- src/NHibernate/Type/EntityType.cs | 61 +----------------- src/NHibernate/Type/GenericBagType.cs | 2 +- .../Type/GenericIdentifierBagType.cs | 2 +- src/NHibernate/Type/GenericListType.cs | 2 +- src/NHibernate/Type/GenericMapType.cs | 2 +- src/NHibernate/Type/GenericSetType.cs | 2 +- src/NHibernate/Type/IAssociationType.cs | 2 - src/NHibernate/Type/IType.cs | 15 ----- src/NHibernate/Type/ManyToOneType.cs | 16 +---- src/NHibernate/Type/MetaType.cs | 25 +------- src/NHibernate/Type/NullableType.cs | 22 ------- src/NHibernate/Type/OneToOneType.cs | 4 +- src/NHibernate/Type/SpecialOneToOneType.cs | 2 +- src/NHibernate/Type/TypeFactory.cs | 62 +++++++++---------- 32 files changed, 80 insertions(+), 393 deletions(-) diff --git a/src/NHibernate/Bytecode/ICollectionTypeFactory.cs b/src/NHibernate/Bytecode/ICollectionTypeFactory.cs index c31c229cd6d..14f3d37bbc3 100644 --- a/src/NHibernate/Bytecode/ICollectionTypeFactory.cs +++ b/src/NHibernate/Bytecode/ICollectionTypeFactory.cs @@ -17,11 +17,10 @@ public interface ICollectionTypeFactory /// owner object containing the collection ID, or if it is /// the primary key. /// The to use to create the array. - /// Is embedded in XML (not supported yet) /// /// An for the specified role. /// - CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass); + CollectionType Array(string role, string propertyRef, System.Type elementClass); /// /// Creates a new for an @@ -33,11 +32,10 @@ public interface ICollectionTypeFactory /// The name of the property in the owner object containing the collection ID, /// or if it is the primary key. /// - /// Is embedded in XML (not supported yet) /// /// A for the specified role. /// - CollectionType Bag(string role, string propertyRef, bool embedded); + CollectionType Bag(string role, string propertyRef); /// /// Creates a new for an @@ -51,11 +49,10 @@ public interface ICollectionTypeFactory /// owner object containing the collection ID, or if it is /// the primary key. /// - /// Is embedded in XML (not supported yet) /// /// A for the specified role. /// - CollectionType List(string role, string propertyRef, bool embedded); + CollectionType List(string role, string propertyRef); /// /// Creates a new for an @@ -68,11 +65,10 @@ public interface ICollectionTypeFactory /// owner object containing the collection ID, or if it is /// the primary key. /// - /// Is embedded in XML (not supported yet) /// /// A for the specified role. /// - CollectionType IdBag(string role, string propertyRef, bool embedded); + CollectionType IdBag(string role, string propertyRef); /// /// Creates a new for an . @@ -82,9 +78,8 @@ public interface ICollectionTypeFactory /// The name of the property in the /// owner object containing the collection ID, or if it is /// the primary key. - /// Is embedded in XML (not supported yet) /// A for the specified role. - CollectionType Set(string role, string propertyRef, bool embedded); + CollectionType Set(string role, string propertyRef); /// /// Creates a new for a sorted . @@ -94,10 +89,9 @@ public interface ICollectionTypeFactory /// The name of the property in the /// owner object containing the collection ID, or if it is /// the primary key. - /// Is embedded in XML (not supported yet) /// The to use for the set. /// A for the specified role. - CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer); + CollectionType SortedSet(string role, string propertyRef, IComparer comparer); /// /// Creates a new for an ordered . @@ -108,9 +102,8 @@ public interface ICollectionTypeFactory /// The name of the property in the owner object containing the collection ID, /// or if it is the primary key. /// - /// Is embedded in XML (not supported yet) /// A for the specified role. - CollectionType OrderedSet(string role, string propertyRef, bool embedded); + CollectionType OrderedSet(string role, string propertyRef); /// /// Creates a new for an @@ -123,14 +116,13 @@ public interface ICollectionTypeFactory /// owner object containing the collection ID, or if it is /// the primary key. /// - /// Is embedded in XML (not supported yet) /// /// A for the specified role. /// - CollectionType Map(string role, string propertyRef, bool embedded); + CollectionType Map(string role, string propertyRef); + CollectionType SortedDictionary(string role, string propertyRef, IComparer comparer); - CollectionType SortedDictionary(string role, string propertyRef, bool embedded, IComparer comparer); - CollectionType SortedList(string role, string propertyRef, bool embedded, IComparer comparer); + CollectionType SortedList(string role, string propertyRef, IComparer comparer); } } \ No newline at end of file diff --git a/src/NHibernate/Mapping/Array.cs b/src/NHibernate/Mapping/Array.cs index c737a1fc136..cb5650bf8bc 100644 --- a/src/NHibernate/Mapping/Array.cs +++ b/src/NHibernate/Mapping/Array.cs @@ -46,7 +46,7 @@ public System.Type ElementClass public override CollectionType DefaultCollectionType { - get { return TypeFactory.Array(Role, ReferencedPropertyName, Embedded, ElementClass); } + get { return TypeFactory.Array(Role, ReferencedPropertyName, ElementClass); } } public override bool IsArray diff --git a/src/NHibernate/Mapping/Collection.cs b/src/NHibernate/Mapping/Collection.cs index 5829cb9cd87..c6bc98f7e3f 100644 --- a/src/NHibernate/Mapping/Collection.cs +++ b/src/NHibernate/Mapping/Collection.cs @@ -45,7 +45,6 @@ public abstract class Collection : IFetchable, IValue, IFilterable private System.Type collectionPersisterClass; private string referencedPropertyName; private string typeName; - private bool embedded = true; private string loaderName; @@ -210,7 +209,7 @@ public virtual CollectionType CollectionType } else { - return TypeFactory.CustomCollection(typeName, typeParameters, role, referencedPropertyName, Embedded); + return TypeFactory.CustomCollection(typeName, typeParameters, role, referencedPropertyName); } } } @@ -551,12 +550,6 @@ public bool IsOptimisticLocked set { optimisticLocked = value; } } - public bool Embedded - { - get { return embedded; } - set { embedded = value; } - } - public bool ExtraLazy { get { return extraLazy; } diff --git a/src/NHibernate/Mapping/ManyToOne.cs b/src/NHibernate/Mapping/ManyToOne.cs index b7d9ff5b590..71107a57108 100644 --- a/src/NHibernate/Mapping/ManyToOne.cs +++ b/src/NHibernate/Mapping/ManyToOne.cs @@ -50,7 +50,7 @@ public override IType Type if (type == null) { type = - TypeFactory.ManyToOne(ReferencedEntityName, ReferencedPropertyName, IsLazy, UnwrapProxy, Embedded, IsIgnoreNotFound, isLogicalOneToOne); + TypeFactory.ManyToOne(ReferencedEntityName, ReferencedPropertyName, IsLazy, UnwrapProxy, IsIgnoreNotFound, isLogicalOneToOne); } return type; } diff --git a/src/NHibernate/Mapping/OneToMany.cs b/src/NHibernate/Mapping/OneToMany.cs index 51dbdc4ac5f..119398bec67 100644 --- a/src/NHibernate/Mapping/OneToMany.cs +++ b/src/NHibernate/Mapping/OneToMany.cs @@ -15,7 +15,6 @@ public class OneToMany : IValue private readonly Table referencingTable; private PersistentClass associatedClass; private bool ignoreNotFound; - private bool embedded; public OneToMany(PersistentClass owner) { @@ -24,7 +23,7 @@ public OneToMany(PersistentClass owner) private EntityType EntityType { - get { return TypeFactory.ManyToOne(ReferencedEntityName, null, false, false, IsEmbedded, IsIgnoreNotFound, false); } + get { return TypeFactory.ManyToOne(ReferencedEntityName, null, false, false, IsIgnoreNotFound, false); } } public bool IsIgnoreNotFound @@ -154,11 +153,5 @@ public bool[] ColumnUpdateability { get { throw new InvalidOperationException(); } } - - public bool IsEmbedded - { - get { return embedded; } - set { embedded = value; } - } } } \ No newline at end of file diff --git a/src/NHibernate/Mapping/OneToOne.cs b/src/NHibernate/Mapping/OneToOne.cs index 6b4adba092e..20454af6b0b 100644 --- a/src/NHibernate/Mapping/OneToOne.cs +++ b/src/NHibernate/Mapping/OneToOne.cs @@ -97,7 +97,7 @@ public override IType Type else { return - TypeFactory.OneToOne(ReferencedEntityName, foreignKeyType, referencedPropertyName, IsLazy, UnwrapProxy, Embedded, + TypeFactory.OneToOne(ReferencedEntityName, foreignKeyType, referencedPropertyName, IsLazy, UnwrapProxy, entityName, propertyName); } } diff --git a/src/NHibernate/Mapping/ToOne.cs b/src/NHibernate/Mapping/ToOne.cs index 169a4246007..d327bbc4b7a 100644 --- a/src/NHibernate/Mapping/ToOne.cs +++ b/src/NHibernate/Mapping/ToOne.cs @@ -14,7 +14,6 @@ public abstract class ToOne : SimpleValue, IFetchable private bool lazy = true; internal string referencedPropertyName; private string referencedEntityName; - private bool embedded; private bool unwrapProxy; /// @@ -50,12 +49,6 @@ public bool IsLazy set { lazy = value; } } - public bool Embedded - { - get { return embedded; } - set { embedded = value; } - } - /// /// /// diff --git a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs index bc5f7acdf8f..f2fdf79ff32 100644 --- a/src/NHibernate/Param/DynamicFilterParameterSpecification.cs +++ b/src/NHibernate/Param/DynamicFilterParameterSpecification.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Data.Common; using System.Linq; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -139,11 +138,6 @@ public bool IsAssociationType get { return false; } } - public bool IsXMLElement - { - get { return false; } - } - public bool IsCollectionType { get { return false; } @@ -293,16 +287,6 @@ public IType GetSemiResolvedType(ISessionFactoryImplementor factory) throw new InvalidOperationException(); } - public void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - throw new InvalidOperationException(); - } - - public object FromXMLNode(XmlNode xml, IMapping factory) - { - throw new InvalidOperationException(); - } - public bool[] ToColumnNullness(object value, IMapping mapping) { throw new InvalidOperationException(); diff --git a/src/NHibernate/Type/AbstractType.cs b/src/NHibernate/Type/AbstractType.cs index 567f00013d6..52eae438d54 100644 --- a/src/NHibernate/Type/AbstractType.cs +++ b/src/NHibernate/Type/AbstractType.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Data.Common; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.Util; @@ -24,11 +23,6 @@ public virtual bool IsAssociationType get { return false; } } - public virtual bool IsXMLElement - { - get { return false; } - } - /// /// Gets a value indicating if the is a . /// @@ -256,21 +250,9 @@ public virtual IType GetSemiResolvedType(ISessionFactoryImplementor factory) return this; } - protected internal static void ReplaceNode(XmlNode container, XmlNode value) - { - if (container != value) - { - //not really necessary, I guess... - XmlNode parent = container.ParentNode; - parent.ReplaceChild(value, container); - } - } - public abstract object Replace(object original, object current, ISessionImplementor session, object owner, IDictionary copiedAlready); - public abstract void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory); - public abstract object FromXMLNode(XmlNode xml, IMapping factory); public abstract bool[] ToColumnNullness(object value, IMapping mapping); /// if it is /// the primary key. /// The of the element contained in the array. - /// /// /// This creates a bag that is non-generic. /// - public ArrayType(string role, string propertyRef, System.Type elementClass, bool isEmbeddedInXML) - : base(role, propertyRef, isEmbeddedInXML) + public ArrayType(string role, string propertyRef, System.Type elementClass) + : base(role, propertyRef) { this.elementClass = elementClass; arrayClass = Array.CreateInstance(elementClass, 0).GetType(); diff --git a/src/NHibernate/Type/ClassMetaType.cs b/src/NHibernate/Type/ClassMetaType.cs index 9dd717c5db3..4d6f9b30e7c 100644 --- a/src/NHibernate/Type/ClassMetaType.cs +++ b/src/NHibernate/Type/ClassMetaType.cs @@ -1,6 +1,5 @@ using System; using System.Data.Common; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -69,7 +68,7 @@ public override void NullSafeSet(DbCommand st,object value,int index,ISessionImp public override string ToLoggableString(object value, ISessionFactoryImplementor factory) { - return ToXMLString(value, factory); + return (string)value; } public override string Name @@ -92,34 +91,14 @@ public override bool IsDirty(object old, object current, bool[] checkable, ISess return checkable[0] && IsDirty(old, current, session); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return FromXMLString(xml.Value, factory); - } - - public object FromXMLString(string xml, IMapping factory) - { - return xml; //xml is the entity name - } - public override object Replace(object original, object current, ISessionImplementor session, object owner, System.Collections.IDictionary copiedAlready) { return original; } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - node.Value = ToXMLString(value, factory); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { throw new NotSupportedException(); } - - public string ToXMLString(object value, ISessionFactoryImplementor factory) - { - return (string)value; //value is the entity name - } } } diff --git a/src/NHibernate/Type/CollectionType.cs b/src/NHibernate/Type/CollectionType.cs index 0e9da0adaec..64b5283604c 100644 --- a/src/NHibernate/Type/CollectionType.cs +++ b/src/NHibernate/Type/CollectionType.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Data.Common; -using System.Xml; using NHibernate.Collection; using NHibernate.Engine; using NHibernate.Persister.Collection; @@ -28,7 +27,6 @@ public abstract class CollectionType : AbstractType, IAssociationType private readonly string role; private readonly string foreignKeyPropertyName; - private readonly bool isEmbeddedInXML; private static readonly SqlType[] NoSqlTypes = {}; @@ -42,11 +40,9 @@ public abstract class CollectionType : AbstractType, IAssociationType /// owner object containing the collection ID, or if it is /// the primary key. /// - /// - protected CollectionType(string role, string foreignKeyPropertyName, bool isEmbeddedInXML) + protected CollectionType(string role, string foreignKeyPropertyName) { this.role = role; - this.isEmbeddedInXML = isEmbeddedInXML; this.foreignKeyPropertyName = foreignKeyPropertyName; } @@ -444,11 +440,6 @@ public bool IsAlwaysDirtyChecked get { return true; } } - public bool IsEmbeddedInXML - { - get { return isEmbeddedInXML; } - } - public override bool IsDirty(object old, object current, bool[] checkable, ISessionImplementor session) { return IsDirty(old, current, session); @@ -525,17 +516,6 @@ public string GetOnCondition(string alias, ISessionFactoryImplementor factory, I return GetAssociatedJoinable(factory).FilterFragment(alias, enabledFilters); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return xml; - } - - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - if (isEmbeddedInXML) - ReplaceNode(node, (XmlNode)value); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { return ArrayHelper.EmptyBoolArray; diff --git a/src/NHibernate/Type/ComponentType.cs b/src/NHibernate/Type/ComponentType.cs index dfa70a7d0ea..d5b4eee4b6b 100644 --- a/src/NHibernate/Type/ComponentType.cs +++ b/src/NHibernate/Type/ComponentType.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Data.Common; using System.Reflection; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.Tuple; @@ -573,11 +572,6 @@ public override int Compare(object x, object y) return 0; } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return xml; - } - public override bool IsEqual(object x, object y) { if (x == y) @@ -649,11 +643,6 @@ public override bool IsSame(object x, object y) return true; } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - ReplaceNode(node, (XmlNode)value); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { bool[] result = new bool[GetColumnSpan(mapping)]; @@ -672,11 +661,6 @@ public override bool[] ToColumnNullness(object value, IMapping mapping) return result; } - public override bool IsXMLElement - { - get { return true; } - } - public EntityMode EntityMode { get; } public IComponentTuplizer ComponentTuplizer { get; } diff --git a/src/NHibernate/Type/CompositeCustomType.cs b/src/NHibernate/Type/CompositeCustomType.cs index d20852679ae..209768e28ec 100644 --- a/src/NHibernate/Type/CompositeCustomType.cs +++ b/src/NHibernate/Type/CompositeCustomType.cs @@ -3,8 +3,6 @@ using System.Data.Common; using System.Linq; using System.Reflection; -using System.Xml; - using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -236,11 +234,6 @@ public override object Replace(object original, object current, ISessionImplemen return userType.Replace(original, current, session, owner); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return xml; - } - public override bool IsEqual(object x, object y) { return userType.Equals(x, y); @@ -251,11 +244,6 @@ public virtual bool IsMethodOf(MethodBase method) return false; } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - ReplaceNode(node, (XmlNode)value); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { bool[] result = new bool[GetColumnSpan(mapping)]; diff --git a/src/NHibernate/Type/CustomCollectionType.cs b/src/NHibernate/Type/CustomCollectionType.cs index 9ce032c6040..1e082fce3d7 100644 --- a/src/NHibernate/Type/CustomCollectionType.cs +++ b/src/NHibernate/Type/CustomCollectionType.cs @@ -18,8 +18,8 @@ public class CustomCollectionType : CollectionType { private readonly IUserCollectionType userType; - public CustomCollectionType(System.Type userTypeClass, string role, string foreignKeyPropertyName, bool isEmbeddedInXML) - : base(role, foreignKeyPropertyName, isEmbeddedInXML) + public CustomCollectionType(System.Type userTypeClass, string role, string foreignKeyPropertyName) + : base(role, foreignKeyPropertyName) { if (!typeof(IUserCollectionType).IsAssignableFrom(userTypeClass)) { diff --git a/src/NHibernate/Type/CustomType.cs b/src/NHibernate/Type/CustomType.cs index a53d930fb89..00c19f295cc 100644 --- a/src/NHibernate/Type/CustomType.cs +++ b/src/NHibernate/Type/CustomType.cs @@ -2,8 +2,6 @@ using System.Collections; using System.Data.Common; using System.Reflection; -using System.Xml; - using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.UserTypes; @@ -125,10 +123,12 @@ public override string ToLoggableString(object value, ISessionFactoryImplementor { return "null"; } - else + IEnhancedUserType eut = userType as IEnhancedUserType; + if (eut != null) { - return ToXMLString(value, factory); + return eut.ToXMLString(value); } + return value.ToString(); } /// @@ -219,26 +219,11 @@ public override object Disassemble(object value, ISessionImplementor session, ob return userType.Disassemble(value); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return FromXMLString(xml.Value, factory); - } - - public virtual object FromXMLString(string xml, IMapping factory) - { - return ((IEnhancedUserType)userType).FromXMLString(xml); - } - public override bool IsEqual(object x, object y) { return userType.Equals(x, y); } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - node.Value= ToXMLString(value, factory); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { bool[] result = new bool[GetColumnSpan(mapping)]; @@ -246,20 +231,5 @@ public override bool[] ToColumnNullness(object value, IMapping mapping) ArrayHelper.Fill(result, true); return result; } - - public virtual string ToXMLString(object value, ISessionFactoryImplementor factory) - { - if (value == null) - return null; - IEnhancedUserType eut = userType as IEnhancedUserType; - if (eut != null) - { - return eut.ToXMLString(value); - } - else - { - return value.ToString(); - } - } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Type/DefaultCollectionTypeFactory.cs b/src/NHibernate/Type/DefaultCollectionTypeFactory.cs index 91116527a65..9de2bbb5191 100644 --- a/src/NHibernate/Type/DefaultCollectionTypeFactory.cs +++ b/src/NHibernate/Type/DefaultCollectionTypeFactory.cs @@ -6,52 +6,52 @@ namespace NHibernate.Type { public class DefaultCollectionTypeFactory : ICollectionTypeFactory { - public virtual CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) + public virtual CollectionType Array(string role, string propertyRef, System.Type elementClass) { - return new ArrayType(role, propertyRef, elementClass, embedded); + return new ArrayType(role, propertyRef, elementClass); } - public virtual CollectionType Bag(string role, string propertyRef, bool embedded) + public virtual CollectionType Bag(string role, string propertyRef) { return new GenericBagType(role, propertyRef); } - public virtual CollectionType List(string role, string propertyRef, bool embedded) + public virtual CollectionType List(string role, string propertyRef) { return new GenericListType(role, propertyRef); } - public virtual CollectionType IdBag(string role, string propertyRef, bool embedded) + public virtual CollectionType IdBag(string role, string propertyRef) { return new GenericIdentifierBagType(role, propertyRef); } - public virtual CollectionType Set(string role, string propertyRef, bool embedded) + public virtual CollectionType Set(string role, string propertyRef) { return new GenericSetType(role, propertyRef); } - public virtual CollectionType SortedSet(string role, string propertyRef, bool embedded, IComparer comparer) + public virtual CollectionType SortedSet(string role, string propertyRef, IComparer comparer) { return new GenericSortedSetType(role, propertyRef, comparer); } - public virtual CollectionType OrderedSet(string role, string propertyRef, bool embedded) + public virtual CollectionType OrderedSet(string role, string propertyRef) { return new GenericOrderedSetType(role, propertyRef); } - public virtual CollectionType Map(string role, string propertyRef, bool embedded) + public virtual CollectionType Map(string role, string propertyRef) { return new GenericMapType(role, propertyRef); } - public virtual CollectionType SortedDictionary(string role, string propertyRef, bool embedded, IComparer comparer) + public virtual CollectionType SortedDictionary(string role, string propertyRef, IComparer comparer) { return new GenericSortedDictionaryType(role, propertyRef, comparer); } - public virtual CollectionType SortedList(string role, string propertyRef, bool embedded, IComparer comparer) + public virtual CollectionType SortedList(string role, string propertyRef, IComparer comparer) { return new GenericSortedListType(role, propertyRef, comparer); } diff --git a/src/NHibernate/Type/EntityType.cs b/src/NHibernate/Type/EntityType.cs index 985e14ae5c2..cdb0ae4dbb7 100644 --- a/src/NHibernate/Type/EntityType.cs +++ b/src/NHibernate/Type/EntityType.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Data.Common; using System.Text; -using System.Xml; using NHibernate.Engine; using NHibernate.Exceptions; using NHibernate.Persister.Entity; @@ -20,7 +19,6 @@ public abstract class EntityType : AbstractType, IAssociationType { protected readonly string uniqueKeyPropertyName; private readonly bool eager; - private bool isEmbeddedInXML; private readonly string associatedEntityName; private readonly bool unwrapProxy; private System.Type returnedClass; @@ -32,17 +30,15 @@ public abstract class EntityType : AbstractType, IAssociationType /// reference the PK of the associated entity. /// /// Is eager fetching enabled. - /// Should values of this mapping be embedded in XML modes? /// /// Is unwrapping of proxies allowed for this association; unwrapping /// says to return the "implementation target" of lazy proxies; typically only possible /// with lazy="no-proxy". /// - protected internal EntityType(string entityName, string uniqueKeyPropertyName, bool eager, bool isEmbeddedInXML, bool unwrapProxy) + protected internal EntityType(string entityName, string uniqueKeyPropertyName, bool eager, bool unwrapProxy) { associatedEntityName = entityName; this.uniqueKeyPropertyName = uniqueKeyPropertyName; - this.isEmbeddedInXML = isEmbeddedInXML; this.eager = eager; this.unwrapProxy = unwrapProxy; } @@ -153,21 +149,11 @@ private static object GetIdentifier(object obj, IEntityPersister persister) protected internal object GetIdentifier(object value, ISessionImplementor session) { - if (IsNotEmbedded(session)) - { - return value; - } - return ForeignKeys.GetEntityIdentifierIfNotUnsaved(GetAssociatedEntityName(), value, session); //tolerates nulls } protected internal object GetReferenceValue(object value, ISessionImplementor session) { - if (IsNotEmbedded(session)) - { - return value; - } - if (value == null) { return null; @@ -194,11 +180,6 @@ protected internal object GetReferenceValue(object value, ISessionImplementor se } } - protected internal virtual bool IsNotEmbedded(ISessionImplementor session) - { - return false; //session.EntityMode == EntityMode.DOM4J; - } - public override string ToLoggableString(object value, ISessionFactoryImplementor factory) { if (value == null) @@ -219,18 +200,6 @@ public override string ToLoggableString(object value, ISessionFactoryImplementor return result.ToString(); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - if (!isEmbeddedInXML) - { - return GetIdentifierType(factory).FromXMLNode(xml, factory); - } - else - { - return xml; - } - } - public override string Name { get { return associatedEntityName; } @@ -413,11 +382,6 @@ protected object ResolveIdentifier(object id, ISessionImplementor session) /// public override object ResolveIdentifier(object value, ISessionImplementor session, object owner) { - if (IsNotEmbedded(session)) - { - return value; - } - if (value == null) { return null; @@ -511,11 +475,6 @@ public bool IsReferenceToPrimaryKey get { return string.IsNullOrEmpty(uniqueKeyPropertyName); } } - public bool IsEmbeddedInXML - { - get { return isEmbeddedInXML; } - } - public string GetOnCondition(string alias, ISessionFactoryImplementor factory, IDictionary enabledFilters) { if (IsReferenceToPrimaryKey) @@ -602,27 +561,9 @@ private System.Type DetermineAssociatedEntityClass() } } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - if (!isEmbeddedInXML) - { - GetIdentifierType(factory).SetToXMLNode(node, value, factory); - } - else - { - XmlNode elt = (XmlNode) value; - ReplaceNode(node, elt); // NH different behavior (we don't use Wrapper) - } - } - public override string ToString() { return GetType().FullName + '(' + GetAssociatedEntityName() + ')'; } - - public override bool IsXMLElement - { - get { return isEmbeddedInXML; } - } } } diff --git a/src/NHibernate/Type/GenericBagType.cs b/src/NHibernate/Type/GenericBagType.cs index 33e1013f470..6a5483451ab 100644 --- a/src/NHibernate/Type/GenericBagType.cs +++ b/src/NHibernate/Type/GenericBagType.cs @@ -23,7 +23,7 @@ public class GenericBagType : CollectionType /// owner object containing the collection ID, or if it is /// the primary key. public GenericBagType(string role, string propertyRef) - : base(role, propertyRef, false) + : base(role, propertyRef) { } diff --git a/src/NHibernate/Type/GenericIdentifierBagType.cs b/src/NHibernate/Type/GenericIdentifierBagType.cs index 5672c11ae79..0be9e1ca4ec 100644 --- a/src/NHibernate/Type/GenericIdentifierBagType.cs +++ b/src/NHibernate/Type/GenericIdentifierBagType.cs @@ -23,7 +23,7 @@ public class GenericIdentifierBagType : CollectionType /// owner object containing the collection ID, or if it is /// the primary key. public GenericIdentifierBagType(string role, string propertyRef) - : base(role, propertyRef, false) + : base(role, propertyRef) { } diff --git a/src/NHibernate/Type/GenericListType.cs b/src/NHibernate/Type/GenericListType.cs index 90af9c5f224..49a412d3f9c 100644 --- a/src/NHibernate/Type/GenericListType.cs +++ b/src/NHibernate/Type/GenericListType.cs @@ -23,7 +23,7 @@ public class GenericListType : CollectionType /// owner object containing the collection ID, or if it is /// the primary key. public GenericListType(string role, string propertyRef) - : base(role, propertyRef, false) + : base(role, propertyRef) { } diff --git a/src/NHibernate/Type/GenericMapType.cs b/src/NHibernate/Type/GenericMapType.cs index 9b28fb5205d..612ef703c3b 100644 --- a/src/NHibernate/Type/GenericMapType.cs +++ b/src/NHibernate/Type/GenericMapType.cs @@ -25,7 +25,7 @@ public class GenericMapType : CollectionType /// owner object containing the collection ID, or if it is /// the primary key. public GenericMapType(string role, string propertyRef) - : base(role, propertyRef, false) + : base(role, propertyRef) { } diff --git a/src/NHibernate/Type/GenericSetType.cs b/src/NHibernate/Type/GenericSetType.cs index 01eff7d5c5b..edea5df9de2 100644 --- a/src/NHibernate/Type/GenericSetType.cs +++ b/src/NHibernate/Type/GenericSetType.cs @@ -23,7 +23,7 @@ public class GenericSetType : CollectionType /// owner object containing the collection ID, or if it is /// the primary key. public GenericSetType(string role, string propertyRef) - : base(role, propertyRef, false) { } + : base(role, propertyRef) { } /// /// Instantiates a new for the set. diff --git a/src/NHibernate/Type/IAssociationType.cs b/src/NHibernate/Type/IAssociationType.cs index 1c0858ef08d..7c0b621f1c4 100644 --- a/src/NHibernate/Type/IAssociationType.cs +++ b/src/NHibernate/Type/IAssociationType.cs @@ -56,7 +56,5 @@ public interface IAssociationType : IType /// SQL on clause, in addition to the usual join condition. /// string GetOnCondition(string alias, ISessionFactoryImplementor factory, IDictionary enabledFilters); - - bool IsEmbeddedInXML { get;} } } diff --git a/src/NHibernate/Type/IType.cs b/src/NHibernate/Type/IType.cs index b04d46826ef..95960464fb1 100644 --- a/src/NHibernate/Type/IType.cs +++ b/src/NHibernate/Type/IType.cs @@ -1,6 +1,5 @@ using System.Collections; using System.Data.Common; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -34,8 +33,6 @@ public interface IType : ICacheAssembler /// /> bool IsAssociationType { get; } - bool IsXMLElement { get;} - /// @@ -188,18 +185,6 @@ public interface IType : ICacheAssembler /// Get the type of a semi-resolved value. IType GetSemiResolvedType(ISessionFactoryImplementor factory); - /// A representation of the value to be embedded in an XML element. - /// - /// - /// - void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory); - - /// Parse the XML representation of an instance. - /// - /// - /// an instance of the type - object FromXMLNode(XmlNode xml, IMapping factory); - /// /// Given an instance of the type, return an array of boolean, indicating /// which mapped columns would be null. diff --git a/src/NHibernate/Type/ManyToOneType.cs b/src/NHibernate/Type/ManyToOneType.cs index 17d9f0f19a2..43b1fad93b8 100644 --- a/src/NHibernate/Type/ManyToOneType.cs +++ b/src/NHibernate/Type/ManyToOneType.cs @@ -22,14 +22,14 @@ public ManyToOneType(string className) } public ManyToOneType(string className, bool lazy) - : base(className, null, !lazy, true, false) + : base(className, null, !lazy, false) { ignoreNotFound = false; isLogicalOneToOne = false; } - public ManyToOneType(string entityName, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, bool ignoreNotFound, bool isLogicalOneToOne) - : base(entityName, uniqueKeyPropertyName, !lazy, isEmbeddedInXML, unwrapProxy) + public ManyToOneType(string entityName, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool ignoreNotFound, bool isLogicalOneToOne) + : base(entityName, uniqueKeyPropertyName, !lazy, unwrapProxy) { this.ignoreNotFound = ignoreNotFound; this.isLogicalOneToOne = isLogicalOneToOne; @@ -129,11 +129,6 @@ public override bool IsModified(object old, object current, bool[] checkable, IS public override object Disassemble(object value, ISessionImplementor session, object owner) { - if (IsNotEmbedded(session)) - { - return GetIdentifierType(session).Disassemble(value, session, owner); - } - if (value == null) { return null; @@ -158,11 +153,6 @@ public override object Assemble(object oid, ISessionImplementor session, object object id = AssembleId(oid, session); - if (IsNotEmbedded(session)) - { - return id; - } - if (id == null) { return null; diff --git a/src/NHibernate/Type/MetaType.cs b/src/NHibernate/Type/MetaType.cs index 084972f0bf3..f3018721785 100644 --- a/src/NHibernate/Type/MetaType.cs +++ b/src/NHibernate/Type/MetaType.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Data.Common; -using System.Xml; using NHibernate.Engine; using NHibernate.SqlTypes; @@ -64,7 +63,7 @@ public override void NullSafeSet(DbCommand st,object value,int index,ISessionImp public override string ToLoggableString(object value, ISessionFactoryImplementor factory) { - return ToXMLString(value, factory); + return (string)value; } public override string Name @@ -87,39 +86,19 @@ public override bool IsDirty(object old, object current, bool[] checkable, ISess return checkable[0] && IsDirty(old, current, session); } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return FromXMLString(xml.Value, factory); - } - - public object FromXMLString(string xml, IMapping factory) - { - return xml; //xml is the entity name - } - public override object Replace(object original, object current, ISessionImplementor session, object owner, System.Collections.IDictionary copiedAlready) { return original; } - public override void SetToXMLNode(XmlNode node, object value, ISessionFactoryImplementor factory) - { - node.Value = ToXMLString(value, factory); - } - public override bool[] ToColumnNullness(object value, IMapping mapping) { return baseType.ToColumnNullness(value, mapping); } - public string ToXMLString(object value, ISessionFactoryImplementor factory) - { - return (string)value; //value is the entity name - } - internal object GetMetaValue(string className) { return keys[className]; } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Type/NullableType.cs b/src/NHibernate/Type/NullableType.cs index 0ec163308d7..b82ebe620f5 100644 --- a/src/NHibernate/Type/NullableType.cs +++ b/src/NHibernate/Type/NullableType.cs @@ -1,7 +1,5 @@ using System; using System.Data.Common; -using System.Xml; - using NHibernate.Engine; using NHibernate.SqlTypes; using NHibernate.Util; @@ -343,26 +341,6 @@ public override bool[] ToColumnNullness(object value, IMapping mapping) return value == null ? ArrayHelper.False : ArrayHelper.True; } - public override object FromXMLNode(XmlNode xml, IMapping factory) - { - return FromXMLString(xml.InnerText, factory); - } - - public override void SetToXMLNode(XmlNode xml, object value, ISessionFactoryImplementor factory) - { - xml.InnerText = ToXMLString(value, factory); - } - - public string ToXMLString(object value, ISessionFactoryImplementor pc) - { - return ToString(value); - } - - public object FromXMLString(string xml, IMapping factory) - { - return string.IsNullOrEmpty(xml) ? null : FromStringValue(xml); - } - public override bool IsEqual(object x, object y) { return EqualsHelper.Equals(x, y); diff --git a/src/NHibernate/Type/OneToOneType.cs b/src/NHibernate/Type/OneToOneType.cs index d24e7533a3c..1131194a3d7 100644 --- a/src/NHibernate/Type/OneToOneType.cs +++ b/src/NHibernate/Type/OneToOneType.cs @@ -29,8 +29,8 @@ public override SqlType[] SqlTypes(IMapping session) return NoSqlTypes; } - public OneToOneType(string referencedEntityName, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName) - : base(referencedEntityName, uniqueKeyPropertyName, !lazy, isEmbeddedInXML, unwrapProxy) + public OneToOneType(string referencedEntityName, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, string entityName, string propertyName) + : base(referencedEntityName, uniqueKeyPropertyName, !lazy, unwrapProxy) { foreignKeyDirection = foreignKeyType; this.propertyName = propertyName; diff --git a/src/NHibernate/Type/SpecialOneToOneType.cs b/src/NHibernate/Type/SpecialOneToOneType.cs index 120acff3913..693b2b1b890 100644 --- a/src/NHibernate/Type/SpecialOneToOneType.cs +++ b/src/NHibernate/Type/SpecialOneToOneType.cs @@ -11,7 +11,7 @@ namespace NHibernate.Type public class SpecialOneToOneType : OneToOneType { public SpecialOneToOneType(string referencedEntityName, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, string entityName, string propertyName) - : base(referencedEntityName, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, true, entityName, propertyName) + : base(referencedEntityName, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName) { } diff --git a/src/NHibernate/Type/TypeFactory.cs b/src/NHibernate/Type/TypeFactory.cs index 25673494088..910854f0fce 100644 --- a/src/NHibernate/Type/TypeFactory.cs +++ b/src/NHibernate/Type/TypeFactory.cs @@ -40,23 +40,23 @@ private enum TypeClassification private static readonly TypeFactory Instance; private static readonly MethodInfo BagDefinition = ReflectionHelper.GetMethodDefinition( - f => f.Bag(null, null, false)); + f => f.Bag(null, null)); private static readonly MethodInfo IdBagDefinition = ReflectionHelper.GetMethodDefinition( - f => f.IdBag(null, null, false)); + f => f.IdBag(null, null)); private static readonly MethodInfo ListDefinition = ReflectionHelper.GetMethodDefinition( - f => f.List(null, null, false)); + f => f.List(null, null)); private static readonly MethodInfo MapDefinition = ReflectionHelper.GetMethodDefinition( - f => f.Map(null, null, false)); + f => f.Map(null, null)); private static readonly MethodInfo SortedListDefinition = ReflectionHelper.GetMethodDefinition( - f => f.SortedList(null, null, false, null)); + f => f.SortedList(null, null, null)); private static readonly MethodInfo SortedDictionaryDefinition = ReflectionHelper.GetMethodDefinition( - f => f.SortedDictionary(null, null, false, null)); + f => f.SortedDictionary(null, null, null)); private static readonly MethodInfo SetDefinition = ReflectionHelper.GetMethodDefinition( - f => f.Set(null, null, false)); + f => f.Set(null, null)); private static readonly MethodInfo SortedSetDefinition = ReflectionHelper.GetMethodDefinition( - f => f.SortedSet(null, null, false, null)); + f => f.SortedSet(null, null, null)); private static readonly MethodInfo OrderedSetDefinition = ReflectionHelper.GetMethodDefinition( - f => f.OrderedSet(null, null, false)); + f => f.OrderedSet(null, null)); /* * Maps the string representation of the type to the IType. The string @@ -745,10 +745,10 @@ public static NullableType GetTypeType(int length) /// A one-to-one association type for the given class and cascade style. /// public static EntityType OneToOne(string persistentClass, ForeignKeyDirection foreignKeyType, string uniqueKeyPropertyName, - bool lazy, bool unwrapProxy, bool isEmbeddedInXML, string entityName, string propertyName) + bool lazy, bool unwrapProxy, string entityName, string propertyName) { return - new OneToOneType(persistentClass, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, + new OneToOneType(persistentClass, foreignKeyType, uniqueKeyPropertyName, lazy, unwrapProxy, entityName, propertyName); } @@ -773,15 +773,14 @@ public static EntityType ManyToOne(string persistentClass, bool lazy) /// /// A many-to-one association type for the given class and cascade style. /// - public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, - bool isEmbeddedInXML, bool ignoreNotFound, bool isLogicalOneToOne) + public static EntityType ManyToOne(string persistentClass, string uniqueKeyPropertyName, bool lazy, bool unwrapProxy, bool ignoreNotFound, bool isLogicalOneToOne) { - return new ManyToOneType(persistentClass, uniqueKeyPropertyName, lazy, unwrapProxy, isEmbeddedInXML, ignoreNotFound, isLogicalOneToOne); + return new ManyToOneType(persistentClass, uniqueKeyPropertyName, lazy, unwrapProxy, ignoreNotFound, isLogicalOneToOne); } - public static CollectionType Array(string role, string propertyRef, bool embedded, System.Type elementClass) + public static CollectionType Array(string role, string propertyRef, System.Type elementClass) { - return Instance.CollectionTypeFactory.Array(role, propertyRef, embedded, elementClass); + return Instance.CollectionTypeFactory.Array(role, propertyRef, elementClass); } @@ -789,69 +788,66 @@ public static CollectionType GenericBag(string role, string propertyRef, System. { MethodInfo mi = BagDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } public static CollectionType GenericIdBag(string role, string propertyRef, System.Type elementClass) { MethodInfo mi = IdBagDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } public static CollectionType GenericList(string role, string propertyRef, System.Type elementClass) { MethodInfo mi = ListDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } public static CollectionType GenericMap(string role, string propertyRef, System.Type indexClass, System.Type elementClass) { MethodInfo mi = MapDefinition.MakeGenericMethod(new[] { indexClass, elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } - public static CollectionType GenericSortedList(string role, string propertyRef, object comparer, - System.Type indexClass, System.Type elementClass) + public static CollectionType GenericSortedList(string role, string propertyRef, object comparer, System.Type indexClass, System.Type elementClass) { MethodInfo mi = SortedListDefinition.MakeGenericMethod(new[] { indexClass, elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, comparer }); } - public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer, - System.Type indexClass, System.Type elementClass) + public static CollectionType GenericSortedDictionary(string role, string propertyRef, object comparer, System.Type indexClass, System.Type elementClass) { MethodInfo mi = SortedDictionaryDefinition.MakeGenericMethod(new[] { indexClass, elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, comparer }); } public static CollectionType GenericSet(string role, string propertyRef, System.Type elementClass) { MethodInfo mi = SetDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } public static CollectionType GenericSortedSet(string role, string propertyRef, object comparer, System.Type elementClass) { MethodInfo mi = SortedSetDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false, comparer }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, comparer }); } public static CollectionType GenericOrderedSet(string role, string propertyRef, System.Type elementClass) { MethodInfo mi = OrderedSetDefinition.MakeGenericMethod(new[] { elementClass }); - return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef, false }); + return (CollectionType)mi.Invoke(Instance.CollectionTypeFactory, new object[] { role, propertyRef }); } - public static CollectionType CustomCollection(string typeName, IDictionary typeParameters, - string role, string propertyRef, bool embedded) + public static CollectionType CustomCollection(string typeName, IDictionary typeParameters, string role, string propertyRef) { System.Type typeClass; try @@ -862,7 +858,7 @@ public static CollectionType CustomCollection(string typeName, IDictionary par { ((IParameterizedType) type).SetParameterValues(parameters); } - else if (parameters != null && !(parameters.Count == 0)) + else if (parameters != null && parameters.Count != 0) { throw new MappingException("type is not parameterized: " + type.GetType().Name); } From cd02df414aeb4ad6100bee0fbdfb3266daf3106e Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 17:32:43 +1300 Subject: [PATCH 6/8] Fix schema for NH-2053 --- src/NHibernate/nhibernate-mapping.xsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NHibernate/nhibernate-mapping.xsd b/src/NHibernate/nhibernate-mapping.xsd index 3e66daec5a5..f3d9736a4f7 100644 --- a/src/NHibernate/nhibernate-mapping.xsd +++ b/src/NHibernate/nhibernate-mapping.xsd @@ -677,7 +677,6 @@ - @@ -689,6 +688,7 @@ + @@ -1355,7 +1355,6 @@ - @@ -1368,6 +1367,7 @@ + From acd305de16016fe97bc1d078b6daeaf36117b560 Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Fri, 24 Mar 2017 17:36:19 +1300 Subject: [PATCH 7/8] NH-3722 - Remove xml entity mode and embed-xml from the schema --- .../Cfg/MappingSchema/Hbm.generated.cs | 316 +++++++----------- src/NHibernate/nhibernate-mapping.xsd | 17 +- 2 files changed, 124 insertions(+), 209 deletions(-) diff --git a/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs b/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs index eb1849ccb58..3ac0ddb71be 100644 --- a/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs +++ b/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs @@ -2,7 +2,7 @@ namespace NHibernate.Cfg.MappingSchema { /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -83,7 +83,7 @@ public HbmAny() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +110,7 @@ public HbmMeta() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -128,7 +128,7 @@ public partial class HbmMetaValue { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -193,7 +193,7 @@ public partial class HbmColumn { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -207,7 +207,7 @@ public partial class HbmComment { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -311,7 +311,7 @@ public partial class HbmArray { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -358,21 +358,15 @@ public partial class HbmArray { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - public HbmArray() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -386,7 +380,7 @@ public partial class HbmSubselect { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -413,7 +407,7 @@ public HbmCache() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheUsage { @@ -436,7 +430,7 @@ public enum HbmCacheUsage { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheInclude { @@ -451,7 +445,7 @@ public enum HbmCacheInclude { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -465,7 +459,7 @@ public partial class HbmSynchronize { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -524,7 +518,7 @@ public HbmKey() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOndelete { @@ -539,7 +533,7 @@ public enum HbmOndelete { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -565,7 +559,7 @@ public partial class HbmIndex { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -586,7 +580,7 @@ public partial class HbmListIndex { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -618,7 +612,7 @@ public partial class HbmCompositeElement { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -636,7 +630,7 @@ public partial class HbmParent { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -758,23 +752,17 @@ public partial class HbmManyToOne { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - public HbmManyToOne() { this.unique = false; this.update = true; this.insert = true; this.optimisticlock = true; this.notfound = HbmNotFoundMode.Exception; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -788,7 +776,7 @@ public partial class HbmFormula { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOuterJoinStrategy { @@ -807,7 +795,7 @@ public enum HbmOuterJoinStrategy { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFetchMode { @@ -822,7 +810,7 @@ public enum HbmFetchMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLaziness { @@ -841,7 +829,7 @@ public enum HbmLaziness { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmNotFoundMode { @@ -856,7 +844,7 @@ public enum HbmNotFoundMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -892,7 +880,7 @@ public partial class HbmNestedCompositeElement { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1009,7 +997,7 @@ public HbmProperty() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1027,7 +1015,7 @@ public partial class HbmType { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1045,7 +1033,7 @@ public partial class HbmParam { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPropertyGeneration { @@ -1064,7 +1052,7 @@ public enum HbmPropertyGeneration { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1125,7 +1113,7 @@ public HbmElement() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1155,7 +1143,7 @@ public partial class HbmManyToAny { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1184,11 +1172,6 @@ public partial class HbmManyToMany { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute("entity-name")] public string entityname; @@ -1241,7 +1224,7 @@ public partial class HbmManyToMany { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("order-by")] @@ -1252,14 +1235,13 @@ public partial class HbmManyToMany { public string propertyref; public HbmManyToMany() { - this.embedxml = true; this.notfound = HbmNotFoundMode.Exception; this.unique = false; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1281,7 +1263,7 @@ public partial class HbmFilter { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmRestrictedLaziness { @@ -1296,7 +1278,7 @@ public enum HbmRestrictedLaziness { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1317,23 +1299,17 @@ public partial class HbmOneToMany { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute("entity-name")] public string entityname; public HbmOneToMany() { this.notfound = HbmNotFoundMode.Exception; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1347,7 +1323,7 @@ public partial class HbmLoader { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1377,7 +1353,7 @@ public partial class HbmCustomSQL { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCustomSQLCheck { @@ -1396,7 +1372,7 @@ public enum HbmCustomSQLCheck { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionFetchMode { @@ -1415,7 +1391,7 @@ public enum HbmCollectionFetchMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1526,7 +1502,7 @@ public partial class HbmBag { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -1573,11 +1549,6 @@ public partial class HbmBag { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public bool generic; @@ -1590,12 +1561,11 @@ public HbmBag() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionLazy { @@ -1614,7 +1584,7 @@ public enum HbmCollectionLazy { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1776,7 +1746,7 @@ public partial class HbmClass { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute()] @@ -1833,7 +1803,7 @@ public HbmClass() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1855,7 +1825,7 @@ public partial class HbmTuplizer { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTuplizerEntitymode { @@ -1864,17 +1834,13 @@ public enum HbmTuplizerEntitymode { [System.Xml.Serialization.XmlEnumAttribute("poco")] Poco, - /// - [System.Xml.Serialization.XmlEnumAttribute("xml")] - Xml, - /// [System.Xml.Serialization.XmlEnumAttribute("dynamic-map")] DynamicMap, } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1924,7 +1890,7 @@ public HbmCompositeId() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1983,7 +1949,7 @@ public HbmKeyManyToOne() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2028,7 +1994,7 @@ public partial class HbmKeyProperty { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmUnsavedValueType { @@ -2047,7 +2013,7 @@ public enum HbmUnsavedValueType { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2103,7 +2069,7 @@ public partial class HbmId { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2121,7 +2087,7 @@ public partial class HbmGenerator { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2175,7 +2141,7 @@ public HbmDiscriminator() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2202,7 +2168,7 @@ public HbmNaturalId() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2288,7 +2254,7 @@ public HbmComponent() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2352,7 +2318,7 @@ public HbmDynamicComponent() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2468,7 +2434,7 @@ public partial class HbmList { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -2515,11 +2481,6 @@ public partial class HbmList { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public bool generic; @@ -2532,12 +2493,11 @@ public HbmList() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2658,7 +2618,7 @@ public partial class HbmMap { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -2705,11 +2665,6 @@ public partial class HbmMap { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public bool generic; @@ -2726,12 +2681,11 @@ public HbmMap() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2750,7 +2704,7 @@ public partial class HbmCompositeIndex { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2769,7 +2723,7 @@ public partial class HbmCompositeMapKey { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2795,7 +2749,7 @@ public partial class HbmIndexManyToAny { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2825,7 +2779,7 @@ public partial class HbmIndexManyToMany { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2860,7 +2814,7 @@ public partial class HbmMapKey { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2895,7 +2849,7 @@ public partial class HbmMapKeyManyToMany { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2976,19 +2930,13 @@ public partial class HbmOneToOne { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - public HbmOneToOne() { this.constrained = false; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3074,7 +3022,7 @@ public partial class HbmPrimitiveArray { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size", DataType="positiveInteger")] @@ -3117,20 +3065,14 @@ public partial class HbmPrimitiveArray { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - public HbmPrimitiveArray() { this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayOuterjoin { @@ -3149,7 +3091,7 @@ public enum HbmPrimitivearrayOuterjoin { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayFetch { @@ -3168,7 +3110,7 @@ public enum HbmPrimitivearrayFetch { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3279,7 +3221,7 @@ public partial class HbmSet { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -3326,11 +3268,6 @@ public partial class HbmSet { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public bool generic; @@ -3347,12 +3284,11 @@ public HbmSet() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3466,7 +3402,7 @@ public partial class HbmIdbag { /// [System.Xml.Serialization.XmlAttributeAttribute()] - public string @where; + public string where; /// [System.Xml.Serialization.XmlAttributeAttribute("batch-size")] @@ -3513,11 +3449,6 @@ public partial class HbmIdbag { [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - /// - [System.Xml.Serialization.XmlAttributeAttribute("embed-xml")] - [System.ComponentModel.DefaultValueAttribute(true)] - public bool embedxml; - /// [System.Xml.Serialization.XmlAttributeAttribute()] public bool generic; @@ -3530,12 +3461,11 @@ public HbmIdbag() { this.inverse = false; this.mutable = true; this.optimisticlock = true; - this.embedxml = true; } } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3568,7 +3498,7 @@ public partial class HbmCollectionId { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3621,7 +3551,7 @@ public HbmTimestamp() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampUnsavedvalue { @@ -3636,7 +3566,7 @@ public enum HbmTimestampUnsavedvalue { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTimestampSource { @@ -3651,7 +3581,7 @@ public enum HbmTimestampSource { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmVersionGeneration { @@ -3666,7 +3596,7 @@ public enum HbmVersionGeneration { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3727,7 +3657,7 @@ public HbmVersion() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3779,7 +3709,7 @@ public HbmProperties() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3862,7 +3792,7 @@ public HbmJoin() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmJoinFetch { @@ -3877,7 +3807,7 @@ public enum HbmJoinFetch { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3951,6 +3881,10 @@ public partial class HbmJoinedSubclass { [System.Xml.Serialization.XmlElementAttribute("sql-query", typeof(HbmSqlQuery))] public object[] Items1; + /// + [System.Xml.Serialization.XmlElementAttribute("filter")] + public HbmFilter[] filter; + /// [System.Xml.Serialization.XmlAttributeAttribute("entity-name")] public string entityname; @@ -4033,11 +3967,7 @@ public partial class HbmJoinedSubclass { /// [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - - /// - [System.Xml.Serialization.XmlElementAttribute("filter")] - public HbmFilter[] filter; - + public HbmJoinedSubclass() { this.dynamicupdate = false; this.dynamicinsert = false; @@ -4046,7 +3976,7 @@ public HbmJoinedSubclass() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4067,7 +3997,7 @@ public partial class HbmResultSet { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4098,7 +4028,7 @@ public HbmLoadCollection() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4120,7 +4050,7 @@ public partial class HbmReturnProperty { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4134,7 +4064,7 @@ public partial class HbmReturnColumn { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLockMode { @@ -4161,7 +4091,7 @@ public enum HbmLockMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4200,7 +4130,7 @@ public HbmReturn() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4214,7 +4144,7 @@ public partial class HbmReturnDiscriminator { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4245,7 +4175,7 @@ public HbmReturnJoin() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4263,7 +4193,7 @@ public partial class HbmReturnScalar { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4338,7 +4268,7 @@ public HbmQuery() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4356,7 +4286,7 @@ public partial class HbmQueryParam { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFlushMode { @@ -4375,7 +4305,7 @@ public enum HbmFlushMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheMode { @@ -4402,7 +4332,7 @@ public enum HbmCacheMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4492,7 +4422,7 @@ public HbmSqlQuery() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4561,6 +4491,10 @@ public partial class HbmSubclass { [System.Xml.Serialization.XmlElementAttribute("sql-query", typeof(HbmSqlQuery))] public object[] Items1; + /// + [System.Xml.Serialization.XmlElementAttribute("filter")] + public HbmFilter[] filter; + /// [System.Xml.Serialization.XmlAttributeAttribute("entity-name")] public string entityname; @@ -4623,10 +4557,6 @@ public partial class HbmSubclass { /// [System.Xml.Serialization.XmlAttributeAttribute()] public string node; - - /// - [System.Xml.Serialization.XmlElementAttribute("filter")] - public HbmFilter[] filter; public HbmSubclass() { this.dynamicupdate = false; @@ -4636,7 +4566,7 @@ public HbmSubclass() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4794,7 +4724,7 @@ public HbmUnionSubclass() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPolymorphismType { @@ -4809,7 +4739,7 @@ public enum HbmPolymorphismType { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOptimisticLockMode { @@ -4832,7 +4762,7 @@ public enum HbmOptimisticLockMode { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4846,7 +4776,7 @@ public partial class HbmCreate { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4866,7 +4796,7 @@ public partial class HbmDatabaseObject { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4884,7 +4814,7 @@ public partial class HbmDefinition { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4898,7 +4828,7 @@ public partial class HbmDrop { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4916,7 +4846,7 @@ public partial class HbmDialectScope { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4951,7 +4881,7 @@ public HbmFilterDef() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4969,7 +4899,7 @@ public partial class HbmFilterParam { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5058,7 +4988,7 @@ public HbmMapping() { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5080,7 +5010,7 @@ public partial class HbmTypedef { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "3.2.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "5.0.0.Alpha1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] diff --git a/src/NHibernate/nhibernate-mapping.xsd b/src/NHibernate/nhibernate-mapping.xsd index f3d9736a4f7..ad16681ea85 100644 --- a/src/NHibernate/nhibernate-mapping.xsd +++ b/src/NHibernate/nhibernate-mapping.xsd @@ -70,8 +70,6 @@ - - @@ -844,8 +842,6 @@ - - @@ -904,8 +900,6 @@ - - @@ -1024,8 +1018,6 @@ - - @@ -1052,8 +1044,6 @@ - - @@ -1122,8 +1112,6 @@ - - @@ -1461,7 +1449,6 @@ - @@ -1615,8 +1602,6 @@ - - The concrete collection should use a generic version or an object-based version. @@ -1727,4 +1712,4 @@ - \ No newline at end of file + From ba6576bb13b251e0fa16f426148d69c2a171d4fc Mon Sep 17 00:00:00 2001 From: Alexander Zaytsev Date: Sat, 25 Mar 2017 14:00:28 +1300 Subject: [PATCH 8/8] NH-3722 - Remove mentions of default_entity_mode from documentation --- doc/reference/modules/persistent_classes.xml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/doc/reference/modules/persistent_classes.xml b/doc/reference/modules/persistent_classes.xml index c47ab6d84c6..a112fde9502 100644 --- a/doc/reference/modules/persistent_classes.xml +++ b/doc/reference/modules/persistent_classes.xml @@ -256,18 +256,11 @@ namespace Eg (using Dictionaries of Dictionarys at runtime) . With this approach, you don't write persistent classes, only mapping files. - - - By default, NHibernate works in normal POCO mode. You may set a default entity - representation mode for a particular ISessionFactory using the - default_entity_mode configuration option (see - . - - + The following examples demonstrates the representation using Maps (Dictionary). First, in the mapping file, an entity-name has to be declared - instead of (or in addition to) a class name: + instead of a class name: @@ -305,16 +298,13 @@ namespace Eg ]]> - Note that even though associations are declared using target class names, the target type of an associations may also be a dynamic entity instead of a POCO. - After setting the default entity mode to dynamic-map - for the ISessionFactory, we can at runtime work with - Dictionaries of Dictionaries: + At runtime we can work with Dictionaries of Dictionaries: