Hello,
I have an object LoginService with three audit fields:
It works great on initial creation, after calling save on the repository the three fields are populated on the object and populated in the DB.
But on update, the values are updated in the DB, but not updated in the object, i have to re-retrieve the object from the DB to see the changed.
Should the instance of the object in memory get updated, just as it get initially populated on save?
Thanks for a great product BTW.
I have an object LoginService with three audit fields:
Code:
@CreatedDate
@Column(name = "CREATE_TS")
DateTime createTs;
@LastModifiedDate
@Column(name = "LST_UPD_TS")
DateTime lstUpdTs;
@LastModifiedBy
@Column(name = "LST_UPD_BY")
String lstUpdBy;
But on update, the values are updated in the DB, but not updated in the object, i have to re-retrieve the object from the DB to see the changed.
Code:
// create a new record. created and last update should be the same
LoginService ls = new LoginService(d, "a", "a", "a");
lsr.save(ls);
assertThat(ls.getCreateTs(), equalTo(ls.getLstUpdTs()));
LoginService actual = lsr.findOne(serviceId);
assertThat(actual.getCreateTs(), equalTo(actual.getLstUpdTs()));
// update the record, last update should be greater than created ts.
Thread.sleep(20);
actual.setPppUsername("b");
actual.setPppPassword("b");
lsr.save(actual);
//This one fails, LstUpdTs has not been updated in the object
assertThat(actual.getCreateTs(), lessThan((ReadableInstant) actual.getLstUpdTs()));
//But it has been updated in the DB so this one passes
actual = lsr.findOne(serviceId);
assertThat(actual.getCreateTs(), lessThan((ReadableInstant) actual.getLstUpdTs()));
Thanks for a great product BTW.