Hi,
I am using the requestFactory, with the ServiceLocator and JDO, but I
think I have miss some things. My task is to delete a user from the
datastore. When I try to using request factory with locator and
serviceLocator, I get an error message saying that I cannot delete
transient objects.
This message shows that I should use pm.getObjectById(clazz,id) during
delete task. I did it, using the following code in my service, and its
ok:

        public void remove(UserDAO dao) {
                PersistenceManager pm = persistenceManager();
                try {
                        UserDAO mydao = 
pm.getObjectById(UserDAO.class,dao.getId());
                        pm.deletePersistent(mydao);
                } finally {
                        pm.close();
                }
        }

But, I cannot understand something. In the UserLocator, there is this
method:

        @Override
        public UserDAO find(Class<? extends UserDAO> clazz, Long id) {

                 if (id == null) {
                      return null;
                    }
                 PersistenceManager pm = persistenceManager();
                 try {
                 return pm.getObjectById(clazz,id);
                 } finally {
                         pm.close();
                 }
        }

which I thought is called, when ever a UserDao object is passed from
userProxy to userService. So in my case, at the above public void
remove(UserDAO dao) procedure, the dao object should be returned from
the public UserDAO find(Class<? extends UserDAO> clazz, Long id) , and
so I should not use the UserDAO mydao =
pm.getObjectById(UserDAO.class,dao.getId()) command but instead I
should only delete the object.
Maybe this happens because pm is closed, so the object is not attached
to the datastore, but I am not sure. If someone knows it will be
helpful for me to better understand how request factory works.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to