Also, it would be nice to have support for mapping...
# komapper
d
Also, it would be nice to have support for mapping to DTOs using annotations (not the entities themselves)... maybe that's an opportunity to rethink EntityStore for this too...
t
Why not just map entities to DTOs using programming code instead of annotations?
d
I guess if they're used only once you'd be right... but if it would be used many times, remapping could get to be error-prone. Especially, since most of the time, it's easy to deduce the correspondence between the fields in the entity and the DTO even w/o specially annotating the DTO...
And refactoring would make a compile-time error, whereas programmatical mapping would only fail at run time.
t
but if it would be used many times, remapping could get to be error-prone.
Why not make the mapping code common?
programmatical mapping would only fail at run time.
If mapping without reflection, you can detect errors at compile time. As a point of reference, parts of a query can be reused as common parts. https://github.com/komapper/komapper-examples/blob/v1.5.0/repository-pattern-jdbc/src/main/kotlin/org/komapper/example/ExampleRepository.kt
d
Yeah, I guess... for my current use-case, I just added a
@KomapperIgnore val foo: SomeEnum? = null
and then used:
Copy code
store.oneToOne(a, ia).map { it.key.copy(foo = it.value?.foo) }
To copy the field from the entitystore...