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
I have a situation when my DTO has a val field declared in its constructor and my Entity has the same val field but it is not defined in its constructor.
The problem is, that field is being omitted and not handled in any way.
The problem is that the result implementation of the converter doesn't handle that field at all, it fills only constructor properties:
@Component
publicobject EntityConverterImpl : EntityConverter {
@GeneratedKonverter(priority =5_000)
overridefunconvertToEntity(dto:DTO): Entity=Entity(
a = dto.a,
b = dto.b,
)
}
I believe the problem is that field is immutable (val) but what do we do in such cases?
Is there any functionality like MapStruct's AfterMapping?
Or is there a way to fill that field using .addAll()?
The text was updated successfully, but these errors were encountered:
But it seems to be redundant since the whole interface has 2 available functions and it would confuse people.
I'd prefer to have something like:
@Konverter
@KComponent
interfaceEntityConverter {
@Konvert(
mappings = [
Mapping(target ="field", expression ="doSomething()"),
],
afterKonvert ="it.fillCollections(dto)", // <-- where `it` is a result Entity and `dto` is the function's param
)
funconvertToEntity(dto:DTO): Entityfun Entity.fillCollections(dto:DTO): Unit {
this.field.addAll(dto.field)
}
}
I have a situation when my
DTO
has aval field
declared in its constructor and myEntity
has the sameval field
but it is not defined in its constructor.The problem is, that field is being omitted and not handled in any way.
The problem is that the result implementation of the converter doesn't handle that
field
at all, it fills only constructor properties:I believe the problem is that
field
is immutable (val
) but what do we do in such cases?Is there any functionality like MapStruct's
AfterMapping
?Or is there a way to fill that field using
.addAll()
?The text was updated successfully, but these errors were encountered: