Hi, i am experimenting with the Google App Engine, and the persist option JDO. I would like to know if it is possible to map a transient object to a persist object? Or something to update the persistent object with the use of an transient object?
I the coding examples i see the following piece of code to update objects:
public void updateEmployeeTitle(User user, String newTitle) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Employee e = pm.getObjectById(Employee.class, user.getEmail());
if (titleChangeIsAuthorized(e, newTitle) {
e.setTitle(newTitle);
} else {
throw new UnauthorizedTitleChangeException(e, newTitle);
}
} finally {
pm.close();
}
}
But this is not what i want, does anybody know if i can update the whole object like JPA does: object.update();
So i would like something like this:
public User update(User u) {
PersistenceManager pm = PMF.get().getPersistenceManager();
User usr;
try {
usr = pm.getObjectById(User.class, u.getId());
// copy transient object u to persist object usr.
// on update of usr all changes in object u are persistent.
} finally {
pm.close();
}
return u;
}