Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error in JavaGenerator generated code when <pojosAsJavaRecordClasses> is active and a table references a UDT #16039

Closed
lukaseder opened this issue Jan 9, 2024 · 1 comment

Comments

@lukaseder
Copy link
Member

lukaseder commented Jan 9, 2024

With this schema:

CREATE TYPE monetary_amount AS (amount numeric, currency CHAR(3));

CREATE TABLE transaction (
    transaction_id bigint NOT NULL,
    value_date timestamp without time zone NOT NULL,
    amount monetary_amount NOT NULL,
    last_update timestamp without time zone DEFAULT now() NOT NULL
);

There's a POJO (record) accepting constructor in the generated TransactionRecord class like this:

    public TransactionRecord(org.jooq.demo.java.db.tables.pojos.Transaction value) {
        super(Transaction.TRANSACTION);

        if (value != null) {
            setTransactionId(value.transactionId());
            setValueDate(value.valueDate());
            setAmount(value.getAmount() == null ? null : new MonetaryAmountRecord(value.amount()));
            //              ^^^^^^^^^^^ compilation error here
            setLastUpdate(value.lastUpdate());
            resetChangedOnNotNull();
        }
    }

There is no getter called getAmount() in a Java record for a property called amount. Instead, we should call the method amount() based on the property name, directly. Curiously, this is being done in the constructor for MonetaryAmountRecord !

3.20 Other improvements automation moved this from To do to Done Jan 9, 2024
lukaseder added a commit that referenced this issue Jan 9, 2024
<pojosAsJavaRecordClasses> is active and a table references a UDT
lukaseder added a commit that referenced this issue Jan 9, 2024
<pojosAsJavaRecordClasses> is active and a table references a UDT
lukaseder added a commit that referenced this issue Jan 9, 2024
<pojosAsJavaRecordClasses> is active and a table references a UDT
lukaseder added a commit that referenced this issue Jan 9, 2024
<pojosAsJavaRecordClasses> is active and a table references a UDT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant