Grails 3.x- GORM - inList does not work, participants start with underscores (_)

I have this class

class ScanRequest4Command implements Validateable {

    String _ScanType

    static constraints = {
        pScanType inList:["a", "b"]
    }
}

this code worked fine in grails 2.4.4 recently we started upgrading to grails 3.1.16

now when i try to run the code if it fails and throws the following exception:

java.lang.IllegalArgumentException: object is not an instance of declaring class
    at com.evercompliant.commands.v4.ScanRequest4Command$__clinit__closure9.doCall(ScanRequest4Command.groovy:151)
    at com.evercompliant.commands.v4.ScanRequest4Command$__clinit__closure9.doCall(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command$__clinit__closure9.call(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command$__clinit__closure9.call(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command.validate(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command.validate(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.Base4Command.validateWithErrors(Base4Command.groovy:98)
    at com.evercompliant.commands.v4.PortfolioManagementBase4Command.validateWithErrors(PortfolioManagementBase4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command.super$2$validateWithErrors(ScanRequest4Command.groovy)
    at com.evercompliant.commands.v4.ScanRequest4Command.validateWithErrors(ScanRequest4Command.groovy:164)
    at com.evercompliant.commands.v4.ScanRequest4Command$validateWithErrors.call(Unknown Source)
    at com.evercompliant.data.Merchant.withTransaction(Merchant.groovy)
    at com.evercompliant.data.Merchant$withTransaction.call(Unknown Source)
    at com.evercompliant.utils.CorsFilter.doFilterInternal(CorsFilter.java:35)

that didn't help much. if I remove the restriction inList, the code passes, which means the problem is in inList.

so after checking and failing, I found that if I change the member name to pScanType, the code passes.

so my question is this:

Is underlining unacceptable in a member name prefix? if so documented anywhere? if not, what is the problem with the code?

+4
source share

Source: https://habr.com/ru/post/1691746/


All Articles