Skip to content

Commit 65b2c9f

Browse files
committed
Automated deployment: Sun Nov 17 15:36:13 UTC 2024 506c06a
1 parent 5bb4cbf commit 65b2c9f

File tree

1 file changed

+29
-0
lines changed
  • news/2024-09-15-mapstruct-1_6_1_bug-fix-released

1 file changed

+29
-0
lines changed

news/2024-09-15-mapstruct-1_6_1_bug-fix-released/index.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,35 @@ <h3 id="linkedhashset-and-linkedhashmap-factory-method"><a class="ms-header-link
179179
Set&lt;TargetFoo&gt; set = LinkedHashSet.newLinkedHashSet( foos.size() );
180180
</pre>
181181
</p>
182+
<h3 id="behaviour-change"><a class="ms-header-link" href="#behaviour-change"><i class="fa fa-link"></i></a>Behaviour change</h3>
183+
<h4 id="inverse-inheritance-strategy-not-working-for-ignored-mappings-only-with-target"><a class="ms-header-link" href="#inverse-inheritance-strategy-not-working-for-ignored-mappings-only-with-target"><i class="fa fa-link"></i></a>Inverse Inheritance Strategy not working for ignored mappings only with target</h4>
184+
<p>Prior to this fix <code>@Mapping(target = &quot;myProperty&quot;, ignore = true)</code> was being ignored when using <code>@InheritInverseConfiguration</code>.</p>
185+
<p>e.g.</p>
186+
<pre class="prettyprint linenums lang-java">
187+
@Mapper
188+
public interface ModelMapper {
189+
190+
@Mapping(target = &#34;creationDate&#34;, ignore = true)
191+
Entity toEntity(Model model);
192+
193+
@InheritInverseConfiguration
194+
Model toModel(Entity entity);
195+
}
196+
</pre>
197+
198+
<p>In the example above prior 1.6.1 the <code>Model toModel(Entity entity)</code> was going to map the <code>id</code> property. In order to keep that behavior you&rsquo;ll need to explicitly do the mapping for it.</p>
199+
<pre class="prettyprint linenums lang-java">
200+
@Mapper
201+
public interface ModelMappe {
202+
@Mapping(target = &#34;creationDate&#34;, ignore = true) // NOTE: Handled by JPA.
203+
Entity toEntity(Model model);
204+
205+
@InheritInverseConfiguration
206+
@Mapping(target = &#34;creationDate&#34;, source = &#34;creationDate&#34;) // Allow reading from Entity
207+
Model toModel(Entity entity);
208+
}
209+
</pre>
210+
182211
<h3 id="thanks"><a class="ms-header-link" href="#thanks"><i class="fa fa-link"></i></a>Thanks</h3>
183212
<p>Thanks to our entire community for reporting these errors.</p>
184213
<p>In alphabetic order this are all the contributors that contributed to the 1.6.1 release of Mapstruct:</p>

0 commit comments

Comments
 (0)