How to combine static mappings when using Abstract classes on Domain Classes in Grails 5

36 Views Asked by At

We have a plugin that gives us an Abstract class called PaymentAbstract

It looks like this.

abstract class PaymentAbstract implements Serializable {

    static mapping = {
        tablePerHierarchy false  // avoid creating the base_domain table
        tablePerConcreteClass true
        token defaultValue: "-1"
        ...
    }

    String token
    Date authDate
    ...
}

In our apps we create a Payment that extends the abstract class like this.

class Payment extends PaymentAbstract {
    String foo
    ...
}

A problem arises when we want to add a mapping formula.

class Payment extends PaymentAbstract {

    static mapping = {
        bar formula: "..."
        ...
    }

    String token
    Date authDate
    ...
}

But this overwrites the original mapping and we lose a lot of details on the payment.

Is there any way to merge both of these static mappings?

0

There are 0 best solutions below