Skip to content

Commit 506c06a

Browse files
committed
Add 1.6.1 behaviour change
1 parent ba342d6 commit 506c06a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

content/news/2024-09-15-mapstruct-1_6_1_bug-fix-released.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,40 @@ Map<AuctionDto, AuctionDto> map = LinkedHashMap.newLinkedHashMap( auctions.size(
2929
Set<TargetFoo> set = LinkedHashSet.newLinkedHashSet( foos.size() );
3030
{{< /prettify >}}
3131

32+
### Behaviour change
33+
34+
#### Inverse Inheritance Strategy not working for ignored mappings only with target
35+
36+
Prior to this fix `@Mapping(target = "myProperty", ignore = true)` was being ignored when using `@InheritInverseConfiguration`.
37+
38+
e.g.
39+
40+
{{< prettify java >}}
41+
@Mapper
42+
public interface ModelMapper {
43+
44+
@Mapping(target = "creationDate", ignore = true)
45+
Entity toEntity(Model model);
46+
47+
@InheritInverseConfiguration
48+
Model toModel(Entity entity);
49+
}
50+
{{< /prettify >}}
51+
52+
In the example above prior 1.6.1 the `Model toModel(Entity entity)` was going to map the `id` property. In order to keep that behavior you'll need to explicitly do the mapping for it.
53+
54+
{{< prettify java >}}
55+
@Mapper
56+
public interface ModelMappe {
57+
@Mapping(target = "creationDate", ignore = true) // NOTE: Handled by JPA.
58+
Entity toEntity(Model model);
59+
60+
@InheritInverseConfiguration
61+
@Mapping(target = "creationDate", source = "creationDate") // Allow reading from Entity
62+
Model toModel(Entity entity);
63+
}
64+
{{< /prettify >}}
65+
3266
### Thanks
3367

3468
Thanks to our entire community for reporting these errors.

0 commit comments

Comments
 (0)