MapStruct Ambiguous constructors #3590
RodrigoMonterio
started this conversation in
General
Replies: 1 comment 1 reply
-
public record IdClient(Long id) { }
public record ClientEntity(Long id){} The Mapper would map automatically without you specifying the Mapping via See: Basic Mapping
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a problem using MapStruct. I created a record that has an id of type long and in my mapper I need to convert this object to the Long type, but the error below occurs. I will leave the code to make the problem clearer, sorry if any information is missing, it's my first question on the forum.
Ambiguous constructors found for creating java.lang.Long: Long(long), Long(java.lang.String). Either declare parameterless constructor or annotate the default constructor with an annotation named @default.
My code:
I solved it,
@Mapping(target = "idClient", source = "idClient.id")
but I'm not sure if this is the most appropriate way, considering that the record is of type long and my entity expects a long. I opened this topic to find out what would be the best approach for this case.Beta Was this translation helpful? Give feedback.
All reactions