What is the correct approach to using GWT with persistent objects?
        Posted  
        
            by dankilman
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by dankilman
        
        
        
        Published on 2010-04-04T16:29:56Z
        Indexed on 
            2010/04/04
            16:33 UTC
        
        
        Read the original article
        Hit count: 254
        
Hi,
I am currently working on a simple web application through Google App engine using GWT. It should be noted that this is my first attempt at such a task.
I have run into to following problem/dilema:
I have a simple Class (getters/setters and nothing more. For the sake of clarity I will refer to this Class as DataHolder) and I want to make it persistent. To do so I have used JDO which required me to add some annotations and more specifically add a Key field to be used as the primary key.
The problem is that using the Key class requires me to import com.google.appengine.api.datastore.Key which is ok on the server side, but then I can't use DataHolder on the client side, because GWT doesn't allow it (as far as I know).
So I have created a sister Class ClientDataHolder which is almost identical, though it doesn't have all the JDO annotations nor the Key field. 
Now this actually works but It feels like I'm doing something wrong. Using this approach would require maintaining to separate classes for each entity I wish to have.
So my question is: Is there a better way of doing this?
Thank you.
© Stack Overflow or respective owner