-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Migration notes
This page lists breaking changes (either API or behavioral changes) in MapStruct releases.
Starting from 1.2.0.Beta3. All the migration notes can be found at releases
- See information in the releases for more information.
- MapStruct now uses the
unmappedTargetPolicywhen generating matching methods (see #1104). - MapStruct now inherits
@InheritInverseConfigurationfrom config prototype methods (see #1065).
-
MapStruct from now on starts to generate methods when property names match between source and target and there is no matching method available. This was already done for Map - and Iterable mapping methods. Prior to this release, one had to define an mapping method or to have a qualifying method in one of the mappers in the 'uses' field in
@Mapper. MapStruct will generate an error when its not able to do so. -
The generated code for nested target mappings has been altered in relation to issue #1011.
- No migration concerns compared to 1.1.0.CR2.
There are two behavioural changes regarding the handling of null values:
-
Nested mappings that refer to a primitive type source property and map to a target property that inherits from
java.lang.Objectwill be mapped tonullif one of the parent beans of the source property isnull.Example:
@Mapping( target = "targetObjectProperty", source = "sourceObjectProperty.primitiveProperty" )setstargetObjectPropertytonullifsourceObjectProperty == null.More info: issue #931.
-
There were once two null checks on the source property in generated
java.lang.Collectiontojava.lang.Collectionmappings. The sequence was as such in pseudo code:null-check-outer-source-property { null-check-target-propety { null-check-inner-source-propety { mapping } } }Thenull-check-outer-source-propertyis removed, since it can be controlled with thenull-check-inner-source-propety. Please note:null-check-inner-source-propetyis either the same asnull-check-outer-source-propertywhen mapped direct or the result of a mapping method. In the latter case, the result of the mapping method can be controlled by the user.
- The method
getCollectionGetterNamein the SPIAccessorNamingStrategyhas been deprecated and won't be called by MapStruct anymore. See the reference documentation for more information about the SPI.
- No migration concerns
- Usage of
@Mappingfor enum mappings is deprecated and leads to a warning message. Please switch to the new annotation@ValueMappingin those cases.
- No migration concerns
- No migration concerns
- No migration concerns
- The annotation
@NullValueMappingwas removed. For method-level configuration of the NullValueMappingStrategy, the attributenullValueMappingStrategywas added to@BeanMapping,@IterableMappingand@MapMapping- this is now in alignment with the class level annotations@Mapperand@MapperConfig.
- Reverse mapping methods must explicitly be tagged as such via
@InheritInverseConfiguration - The attribute
@Mapping#target()is mandatory now; It was possible to specifyignore()anddateFormat()withsource()rather thantarget()(assuming both are the same), for consistency reasons now always the target of a mapping has to be specified - The processor options are prefixed with "mapstruct." now; I.e.
mapstruct.suppressGeneratorTimestamp, ,mapstruct.defaultComponentModelandmapstruct.unmappedTargetPolicyare to be used now rather thansuppressGeneratorTimestamp,unmappedTargetPolicyanddefaultComponentModel