Skip to content

Commit 6cb478f

Browse files
maca88fredericDelaporte
authored andcommittedFeb 14, 2019
Port Hibernate's lazy attribute fetch groups (#1949)
1 parent fff0d08 commit 6cb478f

File tree

66 files changed

+1368
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1368
-173
lines changed
 

‎doc/reference/modules/basic_mapping.xml

+32-12
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@
16941694
<area id="property15" coords="16 55" />
16951695
<area id="property16" coords="17 55" />
16961696
<area id="property17" coords="18 55" />
1697+
<area id="property18" coords="19 55" />
16971698
</areaspec>
16981699
<programlisting><![CDATA[<property
16991700
name="propertyName"
@@ -1706,6 +1707,7 @@
17061707
optimistic-lock="true|false"
17071708
generated="never|insert|always"
17081709
lazy="true|false"
1710+
lazy-group="groupName"
17091711
not-null="true|false"
17101712
unique="true|false"
17111713
unique-key="uniqueKeyName"
@@ -1773,55 +1775,63 @@
17731775
<literal>lazy</literal> (optional - defaults to <literal>false</literal>):
17741776
specifies that this property is lazy. A lazy property is not loaded when
17751777
the object is initially loaded, unless the fetch mode has been overridden
1776-
in a specific query. Values for lazy properties are loaded when any lazy
1777-
property of the object is accessed. Having lazy properties causes instances
1778-
of the entity to be loaded as proxies. Theses proxies ignore the class
1779-
<literal>proxy</literal> setting and always derives from the persistent class,
1780-
requiring its members to be overridable.
1778+
in a specific query. Values for lazy properties are loaded per lazy-group.
1779+
</para>
1780+
<para>
1781+
Having lazy properties causes instances of the entity to be loaded as proxies.
1782+
Theses proxies ignore the class <literal>proxy</literal> setting and always
1783+
derives from the persistent class, requiring its members to be overridable.
1784+
</para>
1785+
</callout>
1786+
<callout arearefs="property11">
1787+
<para>
1788+
<literal>lazy-group</literal> (optional - defaults to <literal>DEFAULT</literal>):
1789+
if the property is lazy, its lazy-loading group. When a lazy property is accessed,
1790+
the other lazy properties of the lazy group are also loaded with it.
17811791
</para>
17821792
</callout>
1783-
<callout arearefs="property11">
1793+
<callout arearefs="property12">
17841794
<para>
17851795
<literal>not-null</literal> (optional - defaults to <literal>false</literal>):
17861796
sets the column nullability for DDL generation.
17871797
</para>
17881798
</callout>
1789-
<callout arearefs="property12">
1799+
<callout arearefs="property13">
17901800
<para>
17911801
<literal>unique</literal> (optional - defaults to <literal>false</literal>):
17921802
sets the column uniqueness for DDL generation. Use <literal>unique-key</literal>
17931803
instead if the value is unique only in combination with other properties.
17941804
</para>
17951805
</callout>
1796-
<callout arearefs="property13">
1806+
<callout arearefs="property14">
17971807
<para>
17981808
<literal>unique-key</literal> (optional):
17991809
a logical name for an unique index for DDL generation. The column will be included in
18001810
the index, along with other columns sharing the same <literal>unique-key</literal>
18011811
logical name. The actual index name depends on the dialect.
18021812
</para>
18031813
</callout>
1804-
<callout arearefs="property14">
1814+
<callout arearefs="property15">
18051815
<para>
18061816
<literal>index</literal> (optional):
18071817
a logical name for an index for DDL generation. The column will be included in
18081818
the index, along with other columns sharing the same <literal>index</literal> logical
18091819
name. The actual index name depends on the dialect.
18101820
</para>
18111821
</callout>
1812-
<callout arearefs="property15">
1822+
<callout arearefs="property16">
18131823
<para>
18141824
<literal>length</literal> (optional): if the type takes a length and does not
18151825
already specify it, its length.
18161826
</para>
18171827
</callout>
1818-
<callout arearefs="property16">
1828+
<callout arearefs="property17">
18191829
<para>
18201830
<literal>precision</literal> (optional): if the type takes a precision and does not
18211831
already specify it, its precision.
18221832
</para>
18231833
</callout>
1824-
<callout arearefs="property17">
1834+
<callout arearefs="property18">
18251835
<para>
18261836
<literal>scale</literal> (optional): if the type takes a scale and does not
18271837
already specify it, its scale.
@@ -2598,6 +2608,7 @@
25982608
<area id="component6" coords="7 60"/>
25992609
<area id="component7" coords="8 60"/>
26002610
<area id="component8" coords="9 60"/>
2611+
<area id="component9" coords="10 60"/>
26012612
</areaspec>
26022613
<programlisting><![CDATA[<component
26032614
name="propertyName"
@@ -2607,6 +2618,7 @@
26072618
access="field|property|nosetter|className"
26082619
optimistic-lock="true|false"
26092620
lazy="true|false"
2621+
lazy-group="groupName"
26102622
unique="true|false">
26112623
26122624
<property ... />
@@ -2660,6 +2672,14 @@
26602672
</para>
26612673
</callout>
26622674
<callout arearefs="component8">
2675+
<para>
2676+
<literal>lazy-group</literal> (optional - defaults to <literal>DEFAULT</literal>):
2677+
If the component is lazy, its lazy-loading group. When a lazy property is accessed
2678+
on an object, included when the property is a component, the other lazy properties
2679+
of the lazy group are also loaded with it.
2680+
</para>
2681+
</callout>
2682+
<callout arearefs="component9">
26632683
<para>
26642684
<literal>unique</literal> (optional - defaults to <literal>false</literal>): Specifies
26652685
that an unique constraint exists upon all mapped columns of the component.

‎src/NHibernate.DomainModel/Async/CustomPersister.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ public async Task<object> LoadAsync(object id, object optionalObject, LockMode l
8585
if (obj != null)
8686
{
8787
clone = (Custom)obj.Clone();
88-
TwoPhaseLoad.AddUninitializedEntity(session.GenerateEntityKey(id, this), clone, this, LockMode.None, false,
89-
session);
90-
TwoPhaseLoad.PostHydrate(this, id, new String[] {obj.Name}, null, clone, LockMode.None, false, session);
88+
TwoPhaseLoad.AddUninitializedEntity(session.GenerateEntityKey(id, this), clone, this, LockMode.None, session);
89+
TwoPhaseLoad.PostHydrate(this, id, new String[] {obj.Name}, null, clone, LockMode.None, session);
9190
await (TwoPhaseLoad.InitializeEntityAsync(clone, false, session, new PreLoadEvent((IEventSource) session),
9291
new PostLoadEvent((IEventSource) session), cancellationToken));
9392
}

0 commit comments

Comments
 (0)
Please sign in to comment.