Wednesday, October 27, 2010

RequestFactory binding exception 'getId() is overloeded on ...'

Hey all 1st post!

I'm building my 1st app with 2.1.0.RC1 (in eclipse helios) and using
the new RequestFactory to map my JPA (eclipselink) entities. Things
were going fine during my initial buildout until I added a "Long
getId()" method to each of my EntityProxy interfaces. After this I get
a RuntimeException("Deferred binding failed for '<my RequestFactory
interface>'") during onModuleLoad(). Looking at the development
console reveals messages like the following for each of my EntityProxy
interfaces...

"Method <EntityProxy class name>.getId() is overloaded on <JPA entity
classname>"

In troubleshooting this, it seems as though this error results from my
JPA entity class hierarchy. Basically, I have a base IEntity interface
that defines a getId() method to be implemented by my entity classes.
I also have a BaseEntity abstract class (that implements IEntity) from
which most all of my concrete entity classes inherit.

If I refactor my base interface+class to remove the getId() method
(e.g. all entity classes still inherit from BaseEntity, but have their
own getId() method), then the GWT module loads fine and everything
seems to just work.

Obviously, having a getId() method on a base-type allows for some nice
convenience methods and such. So, this seems like a very typical
design approach, but for some reason GWT doesn't like it. I'm assuming
it has something to do with how the binding code introspects my JPA
classes.

Maybe I'm missing something but it feels like having an abstract-base-
type getId() method should be supported. Also, I don't see these
errors with the getVersion() method that is defined in IEntity and
implemented in BaseEntity, so I'm thinking it's something specific to
the getId() method.

I could probably put together a test app for it, if necessary, but I
hope this explanation paints enough of a picture. Here is a basic
sample of the class structure I've got...

interface IEntity
{
Object getId();
Integer getVersion();
}

abstract class BaseEntity implements IEntity
{
Integer version;
public Integer getVersion() { return version; }
}

@Entity
class RealEntity extends BaseEntity
{
Long id;
public Long getId() { return id; }
}

TIA,
-matt

--
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