This content has been marked as final.
Show 1 reply
-
1. Re: access to old data when updating with Home component
i92jurir Oct 19, 2012 8:09 AM (in response to i92jurir)I think the first post it´s a bit confusing.
The idea was reread the original data from a row in a update operation. I was trying override the update method of the Home component to read the data from the table. Finally It´s working.
@Override public String update() { // save modified data from instance MyEntity modifiedEntity = new Entity(); modifiedEntity.setAttrib1(instance.getAttrib1()); ....... ....... // recover row from database MyEntity currentEntity = new Entity(); currentEntity.setId(modifiedEntity.getId()); currentEntity = entityManager.merge(currentEntity); entityManager.refresh(currentEntity); // create audit row with current data MyEntityAudit entityAudit = new MyEntityAudit(currentEntity); entityManager.persist(entityAudit); // record modified data to database currentEntity.setAttrib1(modifiedEntity.getAttrib1) ....... ....... return super.update(); }
Other better method to do the same thing? Thanks.