Possible Duplicate:
requestfactory and findEntity method in GWT
When I request a list of entities using RequestFactory with ServiceLocator and Locator constructs, GWT executes n+1 SQL calls.
//HcpcsDAOBean
@Singleton
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class HcpcsDAOBean {
@Inject
@DatasourceAnnotation
EntityManager em;
....
public Hcpcs find(Long id) {
return em.find(Hcpcs.class, id);
}
}
//BeanLocator
public class BeanLocator implements ServiceLocator {
@Override
public Object getInstance(Class<?> clazz) {
return lookupBean(clazz);
}
@SuppressWarnings({"unchecked", "CallToThreadDumpStack"})
public static <T> T lookupBean(Class<T> clazz) {
try {
return (T) InitialContext.doLookup("java:module/" + clazz.getSimpleName());
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
//RequestFactory and RequestContext
public interface AppRequestFactory extends RequestFactory{
@Service(value=HcpcsDAOBean.class, locator=BeanLocator.class)
interface HcpcsServiceRequest extends RequestContext{
Request<Void> persist(HcpcsProxy hcpcsProxy);
Request<Void> remove(HcpcsProxy hcpcsProxy);
Request<List<HcpcsProxy>> findEntries(i开发者_开发知识库nt firstResult, int maxResult );
Request<List<HcpcsProxy>> findAll();
}
HcpcsServiceRequest hcpcsServiceRequest();
}
I think this is the same question as here: requestfactory and findEntity method in GWT.
Altough, this also applies to constructs where no Locator or ServiceLocators are used.
I am having the same question and understand, that RequestFactory needs to check if an entity is live or not, but this is really unessesary for a call like findAll(), or am i missing something?
Is there a way to disable the isLive check for some service methods? I know i can override the isLive method in the Locator and return true for example, but this would disable the check for every service call, and i do not want to miss this feature for Persist or delete operations.
精彩评论