Skip to content

NH-3722 - Remove entity mode switching capability #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 26, 2017

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Mar 23, 2017

@@ -268,11 +268,6 @@ public Settings BuildSettings(IDictionary<string, string> 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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it's better to warn that default entity mode is deprecated rather then silently remove it.

/// <returns>The new session</returns>
ISession GetSession(EntityMode entityMode);
ISession GetChildSession();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add this method to 4.1.x and deprecate old one.

Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we removing the dynamic-map mode altogether? I do not see how we are supposed to activate it since default_entity_mode parameter is removed. On Hibernate side, it looks like they are still supporting it.

Reference documentation on dynamic models needs to be either entirely removed, or amended for explaining how to use dynamic-map mode now. (And for removing reference to default_entity_mode configuration parameter, which is removed.)

It looks to me it is still there but handled at the mapping level, depending on class name presence.

nhibernate-mapping.xsd: still references xml entity mode (line 1435). And there is a number of embed-xml attributes which should be removed if they were for the removed embedded xml. (I do not find any reference to those attributes, even in master.)

src/UpgradeLog2.htm: that file is probably an unexpected add.

@@ -429,7 +417,7 @@ protected void AddPropertyTypedValue(object value, IType type, IList list)
}
value = stringValue;
}
list.Add(new TypedValue(type, value, EntityMode.Poco));
list.Add(new TypedValue(type, value));
// TODO NH Different behavior: In H3.2 EntityMode is nullable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsolete code comment which should be removed.

@@ -2237,26 +2226,18 @@ public ISession GetSession(EntityMode entityMode)

if (rootSession != null)
{
return rootSession.GetSession(entityMode);
return rootSession.GetChildSession();
}

CheckAndUpdateSessionStatus();

ISession rtn = null;
Copy link
Member

@fredericDelaporte fredericDelaporte Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rtn should be removed, see below.

childSessionsByEntityMode.Add(entityMode, rtn);
log.Debug("Creating child session.");
rtn = new SessionImpl(this);
_childSession = rtn;
}

return rtn;
Copy link
Member

@fredericDelaporte fredericDelaporte Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should return _childSession instead of rtn. Otherwise, calling GetChildSession again would yield null instead of yielding previously created child session.

@@ -103,7 +100,7 @@ public interface IType : ICacheAssembler
/// <include file='IType.cs.xmldoc'
/// path='//members[@type="IType"]/member[@name="M:IType.DeepCopy"]/*'
/// />
object DeepCopy(object val, EntityMode entityMode, ISessionFactoryImplementor factory);
object DeepCopy(object val, ISessionFactoryImplementor factory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IType.cs.xmldoc file still refers to entityMode parameter.

/// <returns> boolean </returns>
bool IsEqual(object x, object y, EntityMode entityMode);
bool IsEqual(object x, object y);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicts with IVersionType.IsEqual. If their are supposed to have the same semantic (which I think is the case), IVersionType.IsEqual should be removed since it would then inherit it from IType.

if (pc == null)
{
use4Parameters = true;
pc = persisterClass.GetConstructor(CollectionPersisterConstructor2Args);
Copy link
Member

@fredericDelaporte fredericDelaporte Mar 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this removal be a breaking change? (Is it possible for NHibernate users to supply custom persister to NHibernate?)
If yes, they may not discover it only by compiling since this works by reflection.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, it needs to be deprecated through additional release of 4.x version

{
return FromXMLString(xml.Value, factory);
}

public object FromXMLString(string xml, IMapping factory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FromXMLString looks obsolete, no references found to it. A bit same for ToXMLString, only serves for ToLoggableString which could directly take ToXmlString implementation instead.

{
xml.InnerText = ToXMLString(value, factory);
}

public string ToXMLString(object value, ISessionFactoryImplementor pc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as corresponding methods of MetaType: looks obsolete.

@hazzik
Copy link
Member Author

hazzik commented Mar 24, 2017

Are we removing the dynamic-map mode altogether? I do not see how we are supposed to activate it since default_entity_mode parameter is removed. On Hibernate side, it looks like they are still supporting it.

The entity mode is supported only on a entity/component level, eg. entity/component has to be defined as dynamic-map, to be able to use it. Please see DynamicClassFixture.

Default entity mode was passed only to a SessionImpl constructor, so it's not needed and do not have any effect now.

The drivers for the changes are ComponentMetamodel and EntityMetamodel: replace EntityModeToTuplizerMapping with static ITuplizer and remove all unused EntityModes and you'll be in the current state.

src/UpgradeLog2.htm: that file is probably an unexpected add.

Sure.

@hazzik
Copy link
Member Author

hazzik commented Mar 24, 2017

nhibernate-mapping.xsd: still references xml entity mode (line 1435).

I'm not sure how shall we handle xsd schema changes.

@hazzik
Copy link
Member Author

hazzik commented Mar 24, 2017

And there is a number of embed-xml attributes which should be removed if they were for the removed embedded xml. (I do not find any reference to those attributes, even in master.)

Because the EntityMode.Xml was never actually implemented

@hazzik
Copy link
Member Author

hazzik commented Mar 24, 2017

Code issues addressed. I'll update documentation later

@fredericDelaporte
Copy link
Member

I'm not sure how shall we handle xsd schema changes.

Me too, but it looks to me your 2 commits have done it right. I guess changing the xsd namespace version would be a hassle for migration, requiring everyone to change it in their existing mappings.

Great work by the way, code base simplification is always welcome.

@hazzik hazzik force-pushed the NH-3722 branch 3 times, most recently from 7ed466c to 3c89e7e Compare March 25, 2017 06:21
@hazzik hazzik removed the needs work label Mar 25, 2017
@hazzik hazzik merged commit 7ba52d2 into nhibernate:master Mar 26, 2017
@fredericDelaporte
Copy link
Member

fredericDelaporte commented Mar 26, 2017

On the subject of methods to obsolete, I wonder if this is not a bit late to obsolete them in 4.x for suppressing them completely in 5.
Many users may step over last 4.x versions for upgrading directly to 5.
Maybe should we put them back in 5 but marked obsolete, and remove them only in 6. They may already no more be able of mimicking their old behavior, but at least the user will have a warning telling what to do instead of having a compilation error.

@fredericDelaporte fredericDelaporte added this to the 5.0.0 milestone Mar 26, 2017
@hazzik
Copy link
Member Author

hazzik commented Mar 26, 2017

I think we can do it for ISession.GetSession(EntityMode). For other methods this does not really make a lot of sense. The thing is, that we are now (in 5.0) in an unique position to reshuffle the API as we need to be able to add new features in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants