You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well, being in snapshot channel you have to be ready to see a red bar...
It does not build now.
Many of my simple DTO annotated like this
@JsonInclude(NON_DEFAULT)
@JsonAutoDetect(fieldVisibility = ANY)
@JsonDeserialize(builder = AddressDTOBuilder.class)
@Getter
@Setter
@Builder(toBuilder = true)
@Accessors(fluent = true)
@NoArgsConstructor
@AllArgsConstructor
public final class AddressDTO {
private Long id;
@NotBlank
private String town;
@NotNull
private Locale locale;
@NotBlank
private String street;
@NotBlank
private String zip;
@JsonPOJOBuilder(withPrefix = "")
public static final class AddressDTOBuilder {
}
}
Primarily this was done (adopted) to have a Mapstruct support.
And I may say that this become even comfortable for some cases, to have both builder and fluent accessors.
Now the build fails, saying Can't generate mapping method when @MappingTarget is supposed to be immutable (has a builder).
JPA by the way has same
JPA has some requirements as you know,
And as it were annotated pretty much the same way the mapping with mapstruct was very easy,
and know, how to map them? The DTO Ideally should become immutable with Value (but NOT nesseseraly, since they were not till now), but now as it fails, we'll have to rewrite anyway.
I feel you @soberich. What can you do is to use jitpack.io with this commit which is before the builder stuff.
In any case you are right we would need to fix something like this. At this moment there are 2 options that could be done:
You can still pass in a builder to provide the update mappings
We can relax that error and when we have a @MappingTarget we try to update that type and not do such strong assumption. (Can you open an issue for this?)
By the way fluent accessor would work now for non builders as well. As a method is considered as a setter when it returns itself, has a single parameter and does not start with get, is or set.
Activity
soberich commentedon Apr 5, 2018
Well, being in snapshot channel you have to be ready to see a red bar...
It does not build now.
Many of my simple DTO annotated like this
Primarily this was done (adopted) to have a Mapstruct support.
And I may say that this become even comfortable for some cases, to have both builder and fluent accessors.
Now the build fails, saying
Can't generate mapping method when @MappingTarget is supposed to be immutable (has a builder).
JPA by the way has same
JPA has some requirements as you know,
And as it were annotated pretty much the same way the mapping with mapstruct was very easy,
and know, how to map them? The DTO Ideally should become immutable with Value (but NOT nesseseraly, since they were not till now), but now as it fails, we'll have to rewrite anyway.
filiphr commentedon Apr 5, 2018
I feel you @soberich. What can you do is to use jitpack.io with this commit which is before the builder stuff.
In any case you are right we would need to fix something like this. At this moment there are 2 options that could be done:
@MappingTarget
we try to update that type and not do such strong assumption. (Can you open an issue for this?)By the way fluent accessor would work now for non builders as well. As a method is considered as a setter when it returns itself, has a single parameter and does not start with get, is or set.
mapstruct#1417 Add documentation about the builder support
#1417 Add documentation about the builder support