views:

15

answers:

1

why isn't it possible to define another key than @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; ?
If i try to define a @PrimaryKey as say, an Integer I get an Server Error... http://code.google.com/intl/de-DE/appengine/docs/java/datastore/dataclasses.html

+2  A: 

Yes, you can use a Long

@PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id;

or a String

@PrimaryKey private String name;

See http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html

dunelmtech
public class Commit { @PrimaryKey private String ip;}does not work
dayscott
Did you put @PersistenceCapable(identityType = IdentityType.APPLICATION) before the class. Otherwise you'll have to tell me exactly what error you're getting
dunelmtech
no. eclipse marks "APPLICATION" as error ( although it is in the api ... :/ )
dayscott