Hi, I see a couple issues here. 1) Java generics use run-time type erasure in order to preserve run-time compatibility with older JVMs when generics were introduced into the language. So at run-time, unparameterized List and List<String> are in fact ambiguous, although I don't see where findPage(int, int, List, List) is declared anywhere, which is probably your question.
2) It looks like you're trying to extend a service interface on the client (TestService extends BaseEntityService). This is currently not supported in RequestFactory. For inherited methods, the RF client sends the name of the class in which the method is declared, so it will attempt to invoke inherited methods on the base service rather than the subclass. There is an issue filed on this and a code review to make it possible to extend service impls on the server, but not yet on the client, as it's more involved. On the client side, this means that for now, any inherited service methods must be repeated in each service interface. http://code.google.com/p/google-web-toolkit/issues/detail?id=5807 http://gwt-code-reviews.appspot.com/1370803/ HTH, /dmc On Wed, Mar 9, 2011 at 7:00 PM, TULC <[email protected]> wrote: > Hi all, > > I am using RequestFactory with JPA and am attempting to abstract some > of the common methods. However, whenever I abstract a method that > takes a List or Set parameter, I get errors such as: > > Line 3: The type BaseEntityServiceImpl must implement the inherited > abstract method BaseEntityService.findPage(int, int, List, List) > Line 16: Name clash: The method findPage(int, int, List<String>, > List<Boolean>) of type BaseEntityServiceImpl has the same erasure as > findPage(int, int, List, List) of type BaseEntityService but does not > override it > > I am having trouble seeing what I'm doing wrong, since those errors > relate to GWT-generated code. > > I have: > > public class BaseEntity { > ... > public <T extends BaseEntity> List<T> findPage(int start, int > length) { > return JPAImpl.getEntities(this.getClass(), start, length); > } > public <T extends BaseEntity> List<T> findPage(int start, int > length, List<String> sortFields, List<Boolean> sortDirs) { > // code to create Map<String, Boolean> sort using [sortFields: > sortDirs] > return JPAImpl.getEntities(this.getClass(), start, length, > sort); > } > ... > } > > @ProxyFor (value = BaseEntity.class, locator = > BaseEntityLocator.class) > public interface BaseEntityProxy extends EntityProxy { > ... > } > > @Service (value = BaseEntity.class, locator = > BaseEntityServiceLocator.class) > public interface BaseEntityService<E extends BaseEntityProxy> extends > RequestContext { > ... > public Request<List<E>> findPage(int start, int length); > public Request<List<E>> findPage(int start, int length, > List<String> sortFields, List<Boolean> sortDirs); > ... > } > > public class TestEntity extends BaseEntity {...} > > @ProxyFor (value = TestEntity.class, locator = > BaseEntityLocator.class) > public interface TestProxy extends BaseEntityProxy {...} > > @Service (value = TestEntity.class, locator = > BaseEntityServiceLocator.class) > public interface TestService extends BaseEntityService<TestProxy> > {...} > > If I comment out the second method from the service interface, it all > works fine. I can call findPage(int, int) and get my list of entity > proxies, which are of the parameterised type. However, as soon as I > add the second method, I get the failure: > > Line 3: The type BaseEntityServiceImpl must implement the inherited > abstract method BaseEntityService.findPage(int, int, List, List) > Line 16: Name clash: The method findPage(int, int, List<String>, > List<Boolean>) of type BaseEntityServiceImpl has the same erasure as > findPage(int, int, List, List) of type BaseEntityService but does not > override it > > Looking at the generated code snapshot, it all looks ok (to me): > > public class BaseEntityServiceImpl extends > com.google.gwt.requestfactory.shared.impl.AbstractRequestContext > implements sandbox.server.BaseEntityService { > public > > BaseEntityServiceImpl(com.google.gwt.requestfactory.shared.impl.AbstractRequestFactory > requestFactory) {super(requestFactory);} > ... > public > > com.google.gwt.requestfactory.shared.Request<java.util.List<sandbox.shared.TestProxy>> > findPage(final int arg0,final int arg1,final > java.util.List<java.lang.String> arg2,final > java.util.List<java.lang.Boolean> arg3) { > class X extends > > com.google.gwt.requestfactory.shared.impl.AbstractRequest<java.util.List<sandbox.shared.TestProxy>> > implements > > com.google.gwt.requestfactory.shared.Request<java.util.List<sandbox.shared.TestProxy>> > { > public X() { super(BaseEntityServiceImpl.this);} > @Override public X with(String... paths) {super.with(paths); > return this;} > @Override protected > com.google.gwt.requestfactory.shared.impl.RequestData > makeRequestData() { > return new > > com.google.gwt.requestfactory.shared.impl.RequestData("sandbox.server.EntityService::findPage", > new Object[] {arg0,arg1,arg2,arg3}, propertyRefs, > java.util.List.class, sandbox.shared.TestProxy.class); > } > } > X x = new X(); > addInvocation(x); > return x; > } > ... > } > > In fact, any method in an abstracted service with a List or Set > parameter gives me this error. If I write the method directly into > the concrete service (i.e. into TestService without parameterisation), > it works fine. The abstracted methods without List or Set work fine, > however, which leads me to believe what I'm trying to do is possible, > I'm just missing something. > > Java is not my strongest language so I can't tell where I'm failing, > as the parameterisation doesn't seem ambiguous to me. However, I'm > struggling to debug because so much of the request factory framework > is generated code. Can anyone see where my error is? Is it as simple > as the generated code not including the @Override annotation, or am I > missing something bigger? > > Any help would be greatly appreciated!! > > -- > 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. > > -- David Chandler Developer Programs Engineer, Google Web Toolkit w: http://code.google.com/ b: http://googlewebtoolkit.blogspot.com/ t: @googledevtools -- 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.
