I am experimenting with the Google App Engine and keep the JDO option. I would like to know if it is possible to map a transition object to a persist object? Or something to update a permanent object using a transition object?
In the coding examples, I see the following code fragment for updating 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 anyone know if I can update the whole object, for example JPA: 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; }
java google-app-engine jdo
Ojkaas
source share