I'm using jOOQ 3.15 and faced weird generator behaviour Codegen generates little different copying constructor for Records if you using converter for custom data types. I'm trying to implement org.joda.money.Money integration with our entities
Some example entity
create type pg_money as (
amount numeric,
currency varchar
);
create table test_money(
id uuid primary key,
money pg_money not null
);
Our custom converter:
class PostgresMoneyConverter : Converter<PgMoneyRecord, Money> {
override fun from(t: PgMoneyRecord): Money {
return Money.of(CurrencyUnit.of(t.currency), t.amount)
}
override fun to(u: Money): PgMoneyRecord {
return PgMoneyRecord(u.amount, u.currencyUnit.code)
}
override fun fromType(): Class<PgMoneyRecord> {
return PgMoneyRecord::class.java
}
override fun toType(): Class<Money> {
return Money::class.java
}
}
Generated constructor in TestMoneyRecord.kt:
constructor(value: by.ivasiuk.testmoney.model.tables.pojos.TestMoney?): this() {
if (value != null) {
this.id = value.id
this.money = value.money?.let { Money(it) }
}
}
The problem is in Money(it) cause Money doesn't have such constructor, only with BigMoney as argument. And it's interesting that if I use any basic data type, even if it is not primitive, codegen puts just this.money = value.money without any copying constructors
I see in 3.16 there are some plans to customize constructors generation. Is there any solution in 3.15 to not generate constructors at all or force it to use this.money = value.money too?