开发者

GWT / RequestFactory: when retrieving a given list of entities, n +1 SQL calls are executed [duplicate]

开发者 https://www.devze.com 2023-03-24 05:42 出处:网络
This question already has an answer here: Closed 11 years ago. Possible Duplicate: requestfactory and findEntity method in GWT
This question already has an answer here: Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号