On Jan 5, 10:39 pm, Freewind <
nowind...@gmail.com> wrote:
> I have a class named `Question`, I want to save the changed fields
> when it saved.
Rob's response seems to suggest you want to get access to the original
values. Your thread title doesn't make that clear. So if all you want
to know is which fields are dirty you can do something like this. This
is my unit test for exploring Ebean's dirty field tracking:
Role role1 = SetupUtils.insertRole();
EntityBean eb = (EntityBean) role1;
EntityBeanIntercept ebi = eb._ebean_getIntercept();
assertFalse(ebi.isDirty());
String origName = role1.getName();
role1.setName(origName);
assertFalse(ebi.isDirty());
assertNull(ebi.getChangedProps()); // null if "clean"
role1.setName("dirty!");
assertTrue(ebi.isDirty());
assertTrue(ebi.getChangedProps().contains("name"));
role1.setName(origName); // setting it back to original doesn't
"clean" it
assertTrue(ebi.isDirty());
(Note that setting a value back to the original leaves it dirty. I
would like it to be clean.)
/Daryl