Open guitcastro opened 1 year ago
Hi @guitcastro , first thanks a lot for the kind words about Kotysa :slightly_smiling_face:
An issue was opened a few weeks ago, I think you can take a look the 2 solutions I gave at that time. I think they could solve your case without needing a new feature in Kotysa : #100
A custom converter could be a great feature for Kotysa, but Kotlin language has already very nice native features like the by
keyword so I am not sure this is needed.
If the solutions I gave in #100 drive you to a clean answer for your particular case, maybe you can reply in a new comment with the code you ended with ? It would provide an example that I can share in Kotysa documentation.
I've looked, and using the by
keyword in a extension enforces me to add a default value to my domain constructor, which is not desired. I tried to use noArg kotlin plugin, however the constructor is generated only for java Class
and not for KClass
. One option is to verify if the class has a java 0 args constructor and if so, use it and initialize all other properties later.
This would fill my needs, as I am adding a noArg but it only can be used by reflection. So the domain remains clean.
Hi @guitcastro
I am currently working on Kotysa 3.0, with nice and big technical changes. I will have a look at this issue after that :)
Hi! First of all thanks for the amazing project! I am evaluating it, and loving it =)
My goals is have a small orm to mapper tables entity to domain entities and vice-versa, and if possible without an intermediate entities. Per example, the following domain class:
Would be really coll if this was possible:
This does not work because getters are restricted to
KCallable
:I've done the follow workaround and it worked partially:
I mean partially, because it's possible to insert rows, but this breaks reading entities from database. The exception occur at:
callBy(args)
because:
kotysaTable.columns.indexOf(column)
is an UUID and not acolumn.columnClass.javaObjectType
So if we add a property to
KotysaColumnDb<T : Any, U : Any>
such as :public val rowToEntityConverter: (U -> T),
would be possible to use custom mapper (at least from row to entities) using:If this is in the scope of the project and I am in the right track to implement it, I can open a PR to fix it.