I am not sure if this is a known issue. But I recently tried to map some JPA2 
Entities to ValueProxy's and run into a weird issue. 

In the database I have a table (Term) which references itself using an 
intermediate/mapping table (basically building a graph like structure). 

Term ---> Term2Term.parent
Term <--- Term2Term.child 

Basically a record from table A can have n childrin and exactly one parent 
(DAG). 

The ValueProxy's look like this: 


@ProxyForName(value="xxxxx")
public interface TermProxy extends ValueProxy {
    public Integer getId();
    ......
    public Set<Term2TermProxy> getParents();
    public Set<Term2TermProxy> getChilds();
}


@ProxyForName(value="xxxx")
public interface Term2TermProxy extends ValueProxy {

    public Integer getId();
    public TermProxy getParent();

    public TermProxy getChild();

}

Furthermore I have an EntityProxy in which one Term is embedded: 


@ProxyForName(xxx)
public interface SomeEntityProxy extends EntityProxy{
    TermProxy getTraitOntologyTerm();

}

When I load the SomeEntityProxy object and also load the TermProxy I run 
into an infinite loop on the backend/server when serializing the payload 
with following exception: 

java.lang.reflect.UndeclaredThrowableException
    at $Proxy118.hashCode(Unknown Source)
    at 
com.google.web.bindery.autobean.vm.impl.ShimHandler.hashCode(ShimHandler.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at 
com.google.web.bindery.autobean.vm.impl.ShimHandler.invoke(ShimHandler.java:76)
    at $Proxy118.hashCode(Unknown Source)
    at java.util.HashMap.hash(HashMap.java:351)
    at java.util.HashMap.put(HashMap.java:471)
    at java.util.HashSet.add(HashSet.java:217)
    at 
com.google.web.bindery.requestfactory.server.Resolver.resolveClientValue(Resolver.java:637)
    at 
com.google.web.bindery.requestfactory.server.Resolver.access$400(Resolver.java:51)
    at 
com.google.web.bindery.requestfactory.server.Resolver$PropertyResolver.visitReferenceProperty(Resolver.java:140)
    at 
com.google.web.bindery.autobean.shared.AutoBeanVisitor.visitCollectionProperty(AutoBeanVisitor.java:229)
    at 
com.google.web.bindery.autobean.vm.impl.ProxyAutoBean.traverseProperties(ProxyAutoBean.java:300)
    at 
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:166)
    at 
com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:101)
    at 
com.google.web.bindery.requestfactory.server.Resolver.resolveClientValue(Resolver.java:414)

I suspect that this is due to the fact that ValueProxy's don't have an 
identity and on the backend it traverse through all properties of my 
entity. However by having a reference from Term2Term back to Term I can end 
up with a cyclic dependency. 

i.e. Term A -> Term2Term.parent -> Term B -> Term2Term.child -> Term A 

If I break one of the relationships (parent or child) from Term to 
Term2Term it serializes fine. However when I adda nother ValueProxy (Term A 
-> SomeValueProxy -> Term A ) that contains a property which maps back to 
the Term, I again get a stackoverflow however this time on the client. 

I guess switching to EntityProxy would solve the problem as the properties 
don't automatically get serialized and for identity the stableId is used. 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/-nbC2sCdmFsJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to