Thanks for your report. I've created an issue here: https://github.com/jOOQ/jOOQ/issues/18793
On Wed, Jul 16, 2025 at 1:27 PM Dominik Hirt <dominik.tod...@gmail.com> wrote: > compile error in generated code > > For my latest project I slicely differ my JOOQ maven codegen setup: > > 1) I create a UDT for my Postgresql database: > > CREATE TYPE monetary_value AS ( > amount NUMERIC, > currency VARCHAR > ); > > 2) Using this type for price columns > > create table inventory ( > name text, > price_amount monetary_value > ) > > 3) using JOOQ to force a type conversion to Java Money API MoneyAmount > > <forcedType> > <userType>javax.money.MonetaryAmount</userType> > <converter>de.hub28.MonetaryValueConverter</converter> > <includeExpression>.*_amount</includeExpression> > <objectType>COLUMN</objectType> > </forcedType> > > with a usual implementation of org.jooq.Converter. > Due to the UDT from above and <includeUDTs>true</includeUDTs> I can base > the converter implementaion on the generated MonetaryValueRecord. > > public class SimpleMonetaryValueConverter implements > Converter<MonetaryValueRecord, MonetaryAmount> { > > @Override > public MonetaryAmount from(MonetaryValueRecord databaseObject) { > try { > BigDecimal amount = databaseObject.getAmount() != null ? > databaseObject.getAmount() : BigDecimal.ZERO; > String currencyStr = databaseObject.getCurrency(); > return Money.of(amount, currencyStr); > } catch (Exception e) { > throw new RuntimeException("Failed to parse monetary value: " > + databaseObject, e); > } > } > > But with this setup, there is a compile error in the JOOQ generated > InventoryRecord.java. > > /** > * Create a detached, initialised InventoryRecord > */ > public InventoryRecord(de.hub28.generated.tables.pojos.Inventory > value) { > super(Inventory.INVENTORY); > > if (value != null) { > setName(value.getName()); > setPriceAmount(value.getPriceAmount() == null ? null : new > MonetaryAmount(value.getPriceAmount())); // <-- wrong constructor > resetTouchedOnNotNull(); > } > } > } > > Surprisingly, that in other projects I successfully use <forcedType> to > convert into javax.money.Money. > In those setups, I do not use a UDT. I use a numeric column only, without > any currency column due to pure EUR projects. > In this cases, the generated JOOQ record reads > ``` > setPriceAmount(value.getPriceAmount()) > ``` > > How can configure my project setup in order to use the money_value UDT DB > column and convert those values into javax.money.MonetaryAmount ? > > Kind regards > Dominik > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to jooq-user+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/jooq-user/ed8c79ac-490e-4566-8c49-658379a67902n%40googlegroups.com > <https://groups.google.com/d/msgid/jooq-user/ed8c79ac-490e-4566-8c49-658379a67902n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO57LJSA%3D1_Le9GHoG%2BnJWPryCS6Dqe8grNtr6MKwnQ-YA%40mail.gmail.com.