Grails 4:保存在前缀为 'set' 的服务方法中不起作用

Grails 4: Save doesn't work in service method with prefix 'set'

使用 Grails 4.0.11 和 OpenJDK 11,我遇到了一个非常奇怪的行为,我能够将其提取到一个独立项目中,我确保它与插件无关:

给定一个控制器:

def updateOrder() { 
  def order = Order.get(params.id)
  def result = shopService.setOrderPrintFileChecked(order)
  redirect(action: "detailOrder", id: order.id)
}

和服务

@Transactional
class ShopService {
    def setOrderPrintFileChecked(Order order) {
        order.printFileChecked = new Date()
        println("Validate: " + order.validate())
        println("Errors: " + order.errors)
        println("Dirty: " + order.isDirty())
        def r = order.save(failOnError: true)
        println("Result: " + r.printFileChecked)
        return true
    }
}

这不会将我的值保存到数据库中(已尝试 MySQL+H2 默认数据库)。 如果显示:

Validate: true
Errors: org.grails.datastore.mapping.validation.ValidationErrors: 0 errors
Dirty: true
Result: Sun Nov 21 15:58:17 CET 2021

如果我将 ShopService 的方法从 setOrderPrintFileChecked() 更改为 setorderPrintFileChecked() 甚至 test() 它会工作并且值会被正确保存。**

前缀 + 驼峰式“setXyz”似乎有不同的行为。我想知道它是什么以及如何 fix/prevent 这种情况。可以提供具有行为的完整演示应用程序。

** 更新** 这是反编译的服务 class,具有非 setter 名称:

    public Object updateMyValue(final Order order) {
        final Reference order2 = new Reference((Object)order);
        final CustomizableRollbackTransactionAttribute $transactionAttribute = new CustomizableRollbackTransactionAttribute();
        $transactionAttribute.setName("ch.pacdesigner.ShopService.updateMyValue");
        final GrailsTransactionTemplate $transactionTemplate = new GrailsTransactionTemplate(this.getTransactionManager(), $transactionAttribute);
        return $transactionTemplate.execute((Closure)new ShopService._updateMyValue_closure1((Object)this, (Object)this, order2));
    }

这是编译好的方法

    public Object setOrderPrintFileChecked(final Order order) {
        final CallSite[] $getCallSiteArray = $getCallSiteArray();
        ScriptBytecodeAdapter.setGroovyObjectProperty($getCallSiteArray[0].callConstructor((Object)Date.class), (Class)ShopService.class, (GroovyObject)order, (String)"printFileChecked");
        $getCallSiteArray[1].call((Object)order, (Object)ScriptBytecodeAdapter.createMap(new Object[] { "failOnError", true }));
        return true;
    }

正如@Jeff Scott Brown 所说,这种行为是由于: https://github.com/grails/grails-data-mapping/blob/c69add974963a3a1fcab27271d7ab4fa7c1faee2/grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/transform/AbstractMethodDecoratingTransformation.groovy#L113