gpt4 book ai didi

hibernate - Grails 领域类事件

转载 作者:行者123 更新时间:2023-12-02 14:29:38 24 4
gpt4 key购买 nike

我是 Grails 的新手,我对 beforeinsert() 之类的域类 Hook 很好奇, beforeupdate() , ... ETC。
但是我找不到有关如何使用此功能的良好资源/文档。

有人可以给我一个很好的资源或向我解释这件事是如何工作的吗?

最佳答案

这些方法是连接到域实例生命周期的一种方式。

grails gorm documentation非常干净和精确,所以我将引用那里的定义,但我创建了一个状态图来描绘图片:

enter image description here

  • beforeInsert - Executed before an object is initially persisted to the database. If you return false, the insert will be cancelled.
  • beforeUpdate - Executed before an object is updated. If you return false, the update will be cancelled.
  • beforeDelete - Executed before an object is deleted. If you return false, the delete will be cancelled.
  • beforeValidate - Executed before an object is validated
  • afterInsert - Executed after an object is persisted to the database
  • afterUpdate - Executed after an object has been updated
  • afterDelete - Executed after an object has been deleted
  • onLoad - Executed when an object is loaded from the database

关于hibernate - Grails 领域类事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43466328/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com