So you have 2 tables mapped to the same persistence class?
Or do you have 1 persistent class for archived, and 1 for current?
If you use the last approach (with 2 persistent classes that are basically the same.), then this could be done by something like this:
public void updateCurrent(Current c, SomeProperty toBeUpdated) {
//open session, get transaction, etc Archived a = new Archived(); a.setSomeProperty1(c.getSomeProperty1); a.setSomeProperty2(c.getSomeProperty2); //do this for all properties c.setSomeProperty(toBeUpdated); session.saveOrUpdate(c); session.save(a); //commit, close transaction etc. }
Might not be the most elegant way to do it, but kinda hard when you don't specify exactly what you want to do..
|