Skip to content

NH-2534 - Join-fetching a many-to-one with property-ref results in se… #1460

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

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
00d78cb
NH-2534 - Join-fetching a many-to-one with property-ref results in se…
kfedorchenko Nov 29, 2017
b967fc0
NH-2534 - Join-fetching a many-to-one with property-ref results in se…
kfedorchenko Nov 29, 2017
8c0d711
NH-2534 - Join-fetching a many-to-one with property-ref results in se…
kfedorchenko Nov 29, 2017
ef86fdf
Fix merging of 5.0.2
fredericDelaporte Nov 29, 2017
63dee05
Fix disposing SessionIdLoggingContext if CheckAndUpdateSessionStatus …
hazzik Nov 30, 2017
942b61b
Release 5.0.3
hazzik Nov 30, 2017
4edbbed
Merge tag '5.0.3'
hazzik Nov 30, 2017
338a827
Fix a null reference case in session context
fredericDelaporte Nov 30, 2017
7af6f4c
Obsolete an unused method.
fredericDelaporte Nov 30, 2017
dfe5dec
Obsolete EqualsHelper
hazzik Nov 30, 2017
524d06a
Obsolete EnumerableExtensions (#1465)
hazzik Dec 1, 2017
196a1c4
Fix generating coalesce for Boolean expressions
hazzik Dec 3, 2017
970e9fa
Fix ProxyFactory cache (#1454)
hazzik Dec 5, 2017
a058d38
Logging refactoring (#1377)
ngbrown Dec 6, 2017
433921a
Upgrade AsyncGenerator to 0.7.0
gliljas Dec 6, 2017
293c2eb
NH-3787 - Decimal truncation in Linq ternary expression (#707)
fredericDelaporte Dec 7, 2017
bf7e34d
Document expiration constraint on UpdateTimestampsCache region.
fredericDelaporte Dec 7, 2017
73797df
Reduce the number of calls to UpdateTimestampsCache (#1467)
gliljas Dec 8, 2017
c4eb6f4
Reuse the same generic EmptyMapClass instance across the project (#1477)
bahusoid Dec 10, 2017
f6db500
Reformated test case, to be squashed.
fredericDelaporte Dec 11, 2017
bcad8ba
Removed unneeded id assignation.
fredericDelaporte Dec 11, 2017
f61fa8b
Cache the unique key from entity property when the entity comes from …
fredericDelaporte Dec 11, 2017
3921f6c
Support entity not yet fully loaded and un-associated.
fredericDelaporte Dec 11, 2017
bc30eb4
Implement new StaticProxyFactoryFactory (#1451)
hazzik Dec 13, 2017
906c692
Fix regression caused by logging refactoring (#1479)
ngbrown Dec 13, 2017
c48b4fd
Add timeouts support to MultiCriteria
hazzik Dec 13, 2017
6d8d5d9
Fix default types (#1484)
fredericDelaporte Dec 13, 2017
aada800
Refactored DefaultEntityAliases to avoid unnecessary calculations (#1…
bahusoid Dec 15, 2017
418d35a
Optimize empty arrays usages (#1490)
hazzik Dec 16, 2017
7e440bf
Fix IsModified so that null equates empty components
druidroad Dec 16, 2017
8ffa874
Forgotten async generation for #1487
fredericDelaporte Dec 16, 2017
92bae88
Adjustment for Join-fetching with property-ref results in n+1 select
fredericDelaporte Dec 16, 2017
a9e3698
NH-2534 - Join-fetching a many-to-one with property-ref results in se…
kfedorchenko Nov 29, 2017
946e054
Merge remote-tracking branch 'origin/GH1226' into GH1226
kfedorchenko Dec 17, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Tools/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.2" targetFramework="net461" />
<package id="CSharpAsyncGenerator.CommandLine" version="0.7.0" targetFramework="net461" />
<package id="vswhere" version="2.1.4" targetFramework="net461" />
</packages>
2 changes: 1 addition & 1 deletion build-common/NHibernate.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor Condition="'$(VersionMajor)' == ''">5</VersionMajor>
<VersionMinor Condition="'$(VersionMinor)' == ''">0</VersionMinor>
<VersionPatch Condition="'$(VersionPatch)' == ''">2</VersionPatch>
<VersionPatch Condition="'$(VersionPatch)' == ''">3</VersionPatch>
<VersionSuffix Condition="'$(VersionSuffix)' == ''"></VersionSuffix>

<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
Expand Down
4 changes: 2 additions & 2 deletions build-common/common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

<!-- This is used only for build folder -->
<!-- TODO: Either remove or refactor to use NHibernate.props -->
<property name="project.version" value="5.0.2" overwrite="false" />
<property name="project.version.numeric" value="5.0.2" overwrite="false" />
<property name="project.version" value="5.0.3" overwrite="false" />
<property name="project.version.numeric" value="5.0.3" overwrite="false" />

<!-- properties used to connect to database for testing -->
<include buildfile="nhibernate-properties.xml" />
Expand Down
19 changes: 14 additions & 5 deletions doc/reference/modules/performance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -943,11 +943,20 @@ sessionFactory.EvictCollection("Eg.Cat.Kittens");]]></programlisting>
<para>
This setting causes the creation of two new cache regions - one holding cached query
result sets (<literal>NHibernate.Cache.StandardQueryCache</literal>), the other
holding timestamps of the most recent updates to queryable tables
(<literal>NHibernate.Cache.UpdateTimestampsCache</literal>). Note that the query
cache does not cache the state of any entities in the result set; it caches
only identifier values and results of value type. So the query cache should always be
used in conjunction with the second-level cache.
holding timestamps of the most recent updates to queryable tables
(<literal>UpdateTimestampsCache</literal>). Those region names will be prefixed by the
cache region prefix if <literal>cache.region_prefix</literal> setting is configured.
</para>
<para>
If you use a cache provider handling an expiration for cached entries, you should set
the <literal>UpdateTimestampsCache</literal> region expiration to a value greater than
the expiration of query cache regions. (Or disable its expiration.) Otherwise the query
cache may yield stale data.
</para>
<para>
Note that the query cache does not cache the state of any entities in the result set;
it caches only identifier values and results of value type. So the query cache should
always be used in conjunction with the second-level cache.
</para>

<para>
Expand Down
10 changes: 9 additions & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Build 5.0.2
Build 5.0.3
=============================

Release notes - NHibernate - Version 5.0.3

** Bug
* #1462 Fix disposing SessionIdLoggingContext if CheckAndUpdateSessionStatus is failed

Build 5.0.2
=============================

Release notes - NHibernate - Version 5.0.2
Expand Down
10 changes: 8 additions & 2 deletions src/AsyncGenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
applyChanges: true
analyzation:
methodConversion:
- conversion: Ignore
hasAttributeName: ObsoleteAttribute
- conversion: Ignore
name: PostProcessInsert
containingTypeName: HqlSqlWalker
Expand Down Expand Up @@ -96,6 +94,9 @@
- conversion: Ignore
name: Exists
containingTypeName: AbstractCollectionPersister
- conversion: Ignore
name: QuoteTableAndColumns
containingTypeName: SchemaMetadataUpdater
- conversion: ToAsync
name: ExecuteReader
containingTypeName: IBatcher
Expand All @@ -119,6 +120,8 @@
- name: GetFieldValue
- name: IsDBNull
- name: WriteLine
ignoreAsyncCounterparts:
- rule: Obsolete
callForwarding: true
cancellationTokens:
guards: true
Expand Down Expand Up @@ -259,6 +262,9 @@ methodRules:
- containingType: NHibernate.Tool.hbm2ddl.SchemaValidator
- containingType: NHibernate.Tool.hbm2ddl.SchemaExport
name: PubliclyExposedType
- filters:
- hasAttributeName: ObsoleteAttribute
name: Obsolete
typeRules:
- filters:
- containingAssemblyName: NHibernate
Expand Down
5 changes: 3 additions & 2 deletions src/NHibernate.DomainModel/Async/CustomPersister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using NHibernate.Tuple.Entity;
using NHibernate.Type;
using NHibernate.Util;
using Array = System.Array;

namespace NHibernate.DomainModel
{
Expand All @@ -37,7 +38,7 @@ public Task<int[]> FindDirtyAsync(object[] currentState, object[] previousState,
{
try
{
if (!EqualsHelper.Equals(currentState[0], previousState[0]))
if (!Equals(currentState[0], previousState[0]))
{
return Task.FromResult<int[]>(new int[] { 0 });
}
Expand All @@ -56,7 +57,7 @@ public Task<int[]> FindModifiedAsync(object[] old, object[] current, object enti
{
try
{
if (!EqualsHelper.Equals(old[0], current[0]))
if (!Equals(old[0], current[0]))
{
return Task.FromResult<int[]>(new int[] { 0 });
}
Expand Down
2 changes: 1 addition & 1 deletion src/NHibernate.DomainModel/Baz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public void SetDefaults()
StringArray = StringSet.ToArray();
StringList = new List<string>(StringArray);
IntArray = new int[] {1, 3, 3, 7};
FooArray = new Foo[0];
FooArray = Array.Empty<Foo>();

Customs = new List<string[]>();
Customs.Add(new String[] {"foo", "bar"});
Expand Down
9 changes: 5 additions & 4 deletions src/NHibernate.DomainModel/CustomPersister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NHibernate.Tuple.Entity;
using NHibernate.Type;
using NHibernate.Util;
using Array = System.Array;

namespace NHibernate.DomainModel
{
Expand Down Expand Up @@ -130,12 +131,12 @@ public bool[] PropertyInsertability

public ValueInclusion[] PropertyInsertGenerationInclusions
{
get { return new ValueInclusion[0]; }
get { return Array.Empty<ValueInclusion>(); }
}

public ValueInclusion[] PropertyUpdateGenerationInclusions
{
get { return new ValueInclusion[0]; }
get { return Array.Empty<ValueInclusion>(); }
}

public bool[] PropertyCheckability
Expand Down Expand Up @@ -254,7 +255,7 @@ public IType GetPropertyType(string propertyName)

public int[] FindDirty(object[] currentState, object[] previousState, object entity, ISessionImplementor session)
{
if (!EqualsHelper.Equals(currentState[0], previousState[0]))
if (!Equals(currentState[0], previousState[0]))
{
return new int[] { 0 };
}
Expand All @@ -266,7 +267,7 @@ public int[] FindDirty(object[] currentState, object[] previousState, object ent

public int[] FindModified(object[] old, object[] current, object entity, ISessionImplementor session)
{
if (!EqualsHelper.Equals(old[0], current[0]))
if (!Equals(old[0], current[0]))
{
return new int[] { 0 };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class AppSessionFactory

public AppSessionFactory(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)
{
NHibernate.LoggerProvider.SetLoggersFactory(new NHibernateToMicrosoftLoggerFactory(loggerFactory));
NHibernate.NHibernateLogger.SetLoggersFactory(new NHibernateToMicrosoftLoggerFactory(loggerFactory));

var mapper = new ModelMapper();
mapper.AddMapping<ItemMap>();
Expand Down
127 changes: 18 additions & 109 deletions src/NHibernate.Example.Web/Infrastructure/NHibernateToMicrosoftLogger.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Internal;

namespace NHibernate.Example.Web.Infrastructure
{
public class NHibernateToMicrosoftLogger : IInternalLogger
public class NHibernateToMicrosoftLogger : INHibernateLogger
{
private readonly ILogger _msLogger;

Expand All @@ -12,122 +14,29 @@ public NHibernateToMicrosoftLogger(ILogger msLogger)
_msLogger = msLogger ?? throw new ArgumentNullException(nameof(msLogger));
}

public void Error(object message)
private static readonly Dictionary<NHibernateLogLevel, LogLevel> MapLevels = new Dictionary<NHibernateLogLevel, LogLevel>
{
if (IsErrorEnabled)
{
_msLogger.LogError(message.ToString());
}
}

public void Error(object message, Exception exception)
{
if (IsErrorEnabled)
{
_msLogger.LogError(exception, message.ToString());
}
}

public void ErrorFormat(string format, params object[] args)
{
if (IsErrorEnabled)
{
_msLogger.LogError(format, args);
}
}

public void Fatal(object message)
{
if (IsFatalEnabled)
{
_msLogger.LogCritical(message.ToString());
}
}

public void Fatal(object message, Exception exception)
{
if (IsFatalEnabled)
{
_msLogger.LogCritical(exception, message.ToString());
}
}

public void Debug(object message)
{
if (IsDebugEnabled)
{
_msLogger.LogDebug(message.ToString());
}
}
{ NHibernateLogLevel.Trace, LogLevel.Trace },
{ NHibernateLogLevel.Debug, LogLevel.Debug },
{ NHibernateLogLevel.Warn, LogLevel.Warning },
{ NHibernateLogLevel.Error, LogLevel.Error },
{ NHibernateLogLevel.Fatal, LogLevel.Critical },
{ NHibernateLogLevel.None, LogLevel.None },
};

public void Debug(object message, Exception exception)
public void Log(NHibernateLogLevel logLevel, NHibernateLogValues state, Exception exception)
{
if (IsDebugEnabled)
{
_msLogger.LogDebug(exception, message.ToString());
}
_msLogger.Log(MapLevels[logLevel], 0, new FormattedLogValues(state.Format, state.Args), exception, MessageFormatter);
}

public void DebugFormat(string format, params object[] args)
public bool IsEnabled(NHibernateLogLevel logLevel)
{
if (IsDebugEnabled)
{
_msLogger.LogDebug(format, args);
}
return _msLogger.IsEnabled(MapLevels[logLevel]);
}

public void Info(object message)
private static string MessageFormatter(object state, Exception error)
{
if (IsInfoEnabled)
{
_msLogger.LogInformation(message.ToString());
}
return state.ToString();
}

public void Info(object message, Exception exception)
{
if (IsInfoEnabled)
{
_msLogger.LogInformation(exception, message.ToString());
}
}

public void InfoFormat(string format, params object[] args)
{
if (IsInfoEnabled)
{
_msLogger.LogInformation(format, args);
}
}

public void Warn(object message)
{
if (IsWarnEnabled)
{
_msLogger.LogWarning(message.ToString());
}
}

public void Warn(object message, Exception exception)
{
if (IsWarnEnabled)
{
_msLogger.LogWarning(exception, message.ToString());
}
}

public void WarnFormat(string format, params object[] args)
{
if (IsWarnEnabled)
{
_msLogger.LogWarning(format, args);
}
}

public bool IsErrorEnabled => _msLogger.IsEnabled(LogLevel.Error);
public bool IsFatalEnabled => _msLogger.IsEnabled(LogLevel.Critical);
public bool IsDebugEnabled => _msLogger.IsEnabled(LogLevel.Debug);
public bool IsInfoEnabled => _msLogger.IsEnabled(LogLevel.Information);
public bool IsWarnEnabled => _msLogger.IsEnabled(LogLevel.Warning);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace NHibernate.Example.Web.Infrastructure
{
public class NHibernateToMicrosoftLoggerFactory : NHibernate.ILoggerFactory
public class NHibernateToMicrosoftLoggerFactory : INHibernateLoggerFactory
{
private readonly Microsoft.Extensions.Logging.ILoggerFactory _loggerFactory;

Expand All @@ -11,16 +11,16 @@ public NHibernateToMicrosoftLoggerFactory(Microsoft.Extensions.Logging.ILoggerFa
_loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
}

public IInternalLogger LoggerFor(string keyName)
public INHibernateLogger LoggerFor(string keyName)
{
var msLogger = _loggerFactory.CreateLogger(keyName);
return new NHibernateToMicrosoftLogger(msLogger);
}

public IInternalLogger LoggerFor(System.Type type)
public INHibernateLogger LoggerFor(System.Type type)
{
return LoggerFor(
Microsoft.Extensions.Logging.Abstractions.Internal.TypeNameHelper.GetTypeDisplayName(type));
}
}
}
}
2 changes: 2 additions & 0 deletions src/NHibernate.Example.Web/NHibernate.Example.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading