-
Notifications
You must be signed in to change notification settings - Fork 934
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
Conversation
hazzik
commented
Mar 23, 2017
- Ported from HHH-6330 hibernate/hibernate-orm@4a4f636
- ISession.GetSession is renamed to ISession.GetChildSession
953ad31
to
6932f76
Compare
@@ -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); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
src/NHibernate/Criterion/Example.cs
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
src/NHibernate/Impl/SessionImpl.cs
Outdated
@@ -2237,26 +2226,18 @@ public ISession GetSession(EntityMode entityMode) | |||
|
|||
if (rootSession != null) | |||
{ | |||
return rootSession.GetSession(entityMode); | |||
return rootSession.GetChildSession(); | |||
} | |||
|
|||
CheckAndUpdateSessionStatus(); | |||
|
|||
ISession rtn = null; |
There was a problem hiding this comment.
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.
src/NHibernate/Impl/SessionImpl.cs
Outdated
childSessionsByEntityMode.Add(entityMode, rtn); | ||
log.Debug("Creating child session."); | ||
rtn = new SessionImpl(this); | ||
_childSession = rtn; | ||
} | ||
|
||
return rtn; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/NHibernate/Type/MetaType.cs
Outdated
{ | ||
return FromXMLString(xml.Value, factory); | ||
} | ||
|
||
public object FromXMLString(string xml, IMapping factory) |
There was a problem hiding this comment.
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.
src/NHibernate/Type/NullableType.cs
Outdated
{ | ||
xml.InnerText = ToXMLString(value, factory); | ||
} | ||
|
||
public string ToXMLString(object value, ISessionFactoryImplementor pc) |
There was a problem hiding this comment.
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.
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 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.
Sure. |
I'm not sure how shall we handle xsd schema changes. |
Because the EntityMode.Xml was never actually implemented |
Code issues addressed. I'll update documentation later |
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. |
7ed466c
to
3c89e7e
Compare
* Ported from HHH-6330 hibernate/hibernate-orm@4a4f636 * ISession.GetSession is renamed to ISession.GetChildSession
…rsister * Ported HHH-7736 from hibernate/hibernate-orm@1a5bdd9
* Ported from HHH-10073 hibernate/hibernate-orm@1376b12
* Ported from HHH-10073 hibernate/hibernate-orm@47b8ed5
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. |
I think we can do it for |