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.

Reply via email to