https://kotlinlang.org logo
#spring
Title
# spring
a

Arjan van Wieringen

08/19/2022, 8:06 AM
Hello, I am a big fan of Spring, but an even bigger fan of Kotlin Multiplatform, especially the common code part. However, for entities and persistence this is not possible, since the annotations are JVM-world only. What would be an optimal way to share the entities between platforms? One way would be to just accept it and write
fromDataEntity
and
toDataEntity
helper functions for every common data class which is to be persisted. But that is a lot of boilerplate I suppose. Any other ideas?
r

Robert Jaros

08/19/2022, 8:10 AM
You can use `expect`/`actual` for annotations in common code.
a

Arjan van Wieringen

08/19/2022, 8:16 AM
Great! This is exactly what I need
r

Robert Jaros

08/19/2022, 8:25 AM
Note there are some minor issues with this apprach (e.g. default values in
Table
annotation don't work - you need to use e.g.
@Table("articles", "articles", "")
)
a

Arjan van Wieringen

08/19/2022, 8:41 AM
Yeah, that makes sense. However I always prefer to be explicit with table naming anyway.
3 Views