Solved it myself. I'll write it here for reference. I'll assume 
you've successfully written a Datastored object in JDO and sent some other 
object through RPC before.

First, make sure to follow the weakest links. In my case, RPC/GWT couldn't 
handle the URL-class objects and JDO/GAE couldn't handle the Date-class 
objects. So change them into some equivalent for storing. I used string and 
long, respectively. Like so:
@Persistent public String linkUrl; @Persistent public long releaseDate;

Second, this relates to the first: make sure your (Primary) Key object is 
serializable for RPC. I used a long instead of the Key-class. Like so:
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long key;

Third, if you want to keep it somewhere shared then you can use the /shared 
package. Make sure to add it to your *.gwt.xml-file. When you do that the 
implicitly defined <source path="client"/> will dissapear so you have to 
explicitly define it yourself. Like so:
  <source path='client'/>
  <source path='shared'/>

Fourth, the JDO annotation @PersistanceCapable needs to set identityType to 
Application and detachable to true. Not sure why the Application part is 
needed, maybe someone can elaborate? I did it like this:
@PersistenceCapable(identityType = IdentityType.APPLICATION, 
detachable="true")
public class GameData

Fifth, ties with the fourth and is the obvious implementation of 
IsSerializable for RPC. Like so:
public class GameData implements IsSerializable {

For your copy-paste convenience this is my whole file:
package net.seriema.calendar.game.shared;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.IdentityType;

import com.google.gwt.user.client.rpc.IsSerializable;

@PersistenceCapable(identityType = IdentityType.APPLICATION, 
detachable="true")
public class GameData implements IsSerializable {
@SuppressWarnings("unused")
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long key;
 @Persistent public String title;
@Persistent public String linkUrl;
@Persistent public long releaseDate;
}

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to