I've just created a small test GWT 2.1 application to play a bit with
the request factory. It works cool on the client side but I cannot
figure how it should work on the server side. I have an entity that is
decraled as @Service
@ProxyFor(PropertyType.class)
public interface PropertyTypeProxy extends EntityProxy{
....
}
@PersistenceCapable
public class PropertyType {
....
public static PropertyType findPropertyType(Long id){
PersistenceManager pm = PMF.get().getPersistenceManager();
PropertyType pt = null;
try {
pt = pm.getObjectById(PropertyType.class, id);
pt = pm.detachCopy(pt);
} catch (Exception e) {
e.printStackTrace();
}finally{
pm.close();
}
return pt ;
}
}
When I just call in the client:
PropertyTypeProxy a = req.edit(p);
a.setTitle(event.getValue());
req.persist().using(a).fire();
the function PropertyType.findPropertyType is called three times. They
all are called from JsonRequestProcessor.processJsonRequest(String
jsonRequestString):
....
// Construct beforeDataMap
constructBeforeDataMap(); // 1st
// Construct afterDvsDataMap.
constructAfterDvsDataMapAfterCallingSetters(); // 2nd
...
JSONObject sideEffects = getSideEffects(); // 3rd
So, in order to persist an entity, it executes 3 times DB select.
What's the reason of that? I would expect that I have a possibility to
persist an entity in a single transaction and in a single call. Am I
missing anything or it's really designed so?
Regards,
Alexei
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment