dave08
12/12/2022, 10:13 AMKomapperColumnOverride
for embedded fields? Or can I just annotate the embedded class with a regular KomapperColumn
?Toshihiro Nakamura
12/12/2022, 11:23 AMKomapperColumn
for embedded class properties. We believe that embedded classes should be free from Komapper’s annotations.dave08
12/12/2022, 11:24 AMdave08
12/12/2022, 11:25 AMdave08
12/12/2022, 11:27 AM@KomapperEmbeddedClass
annotation or ``KomapperEmbeddedClassDef` that would automatically make it embedded into any class that has it as a field. On the data layer, that wouldn't make total sense?dave08
12/12/2022, 11:28 AMToshihiro Nakamura
12/12/2022, 11:38 AMdave08
12/12/2022, 11:42 AMToshihiro Nakamura
12/12/2022, 11:58 AM@KomapperColumn
is allowed in embedded classes, users will mistakenly think that other annotations such as @KomapperVersion
are also available in embedded classes. However, we would like to avoid that.
The refactoring problem may be solved by using constants (const val
) for column names.dave08
12/12/2022, 12:06 PMThe refactoring problem may be solved by using constants (Not really, since if once renames) for column names.const val
class Foo(val prop1: String)
to prop2
the constant val
won't automatically change itself... I don't think even Intellij's refactoring would know that...dave08
12/12/2022, 12:07 PMdave08
12/12/2022, 12:08 PMusers will mistakenly think that other annotations such asYeah, that would probably be one thing that's confusing here.are also available in embedded classes. However, we would like to avoid that.@KomapperVersion
Toshihiro Nakamura
12/12/2022, 12:17 PMThe refactoring problem may be solved by using constants (The following code represents what I am trying to say:) for column names.const val
// embedded value
data class Money(val amount: BigDecimal, val currency: String)
// column name for Money.amount
const val amount = "AMT"
@KomapperEntity
data class Employee(
@KomapperId
val id: Int,
@KomapperColumnOverride("amount", KomapperColumn(amount)) // use the above constant
val salary: Money
)
@KomapperEntity
data class Person(
@KomapperId
val id: Int,
@KomapperColumnOverride("amount", KomapperColumn(amount)) // use the above constant
val salary: Money
)
dave08
12/12/2022, 12:20 PM@KomapperColumnOverride("amount"...
"amount"
could have been @KomapperColumnOverride(Money::amount,...
? I'm not sure if that's valid in an annotation, but otherwise, if the property is renamed, then it would break.dave08
12/12/2022, 12:21 PMToshihiro Nakamura
12/12/2022, 1:05 PM@KomapperColumnOverride(Money::amount,…
is invalid annotation.
if the property is renamed, then it would break.
I guess it would get picked up by your ksp parser thoughYes. Komapper`s KSP processor detects that break at compile-time.