(快速參考)

getPersistentValue

目的

擷取網域類別實例的欄位原始值。

範例

def b = Book.get(1)
someMethodThatMightModifyTheInstance(b)

if (b.isDirty('name')) {
    def currentName = b.name
    def originalName = b.getPersistentValue('name')
    if (currentName != originalName) {
        ...
    }
}

說明

此方法主要用於稽核記錄或其他在beforeUpdate 事件回呼中執行的作業。Hibernate 會快取所有已載入實例的原始狀態,以便在清除期間進行髒資料檢查,而此方法會公開該資料,讓您可以將其與目前狀態進行比較。