(Quick Reference)

getPersistentValue

目的
Purpose

Retrieve the original value of a field for a domain class instance.

使用例
Examples

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

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

詳細
Description

This method is useful mostly for audit logging or other work done in a beforeUpdate event callback. Hibernate caches the original state of all loaded instances for dirty checking during a flush and this method exposes that data so you can compare it with the current state.