Opps! got it.

Key k = KeyFactory.createKey(Person.class.getSimpleName(),
String.valueOf(fullName.hashCode()));

instead of

Key k = KeyFactory.createKey(Person.class.getSimpleName(),
fullName.hashCode());


On Sep 19, 2:07 pm, Gaurav <ano...@gmail.com> wrote:
> I am facing the same Issue.
>
> Code:
> p = new Person(fullName);
> Key k = KeyFactory.createKey(Person.class.getSimpleName(),
> fullName.hashCode());
> p.setKey(k);
>
> Error:
> javax.jdo.JDOFatalUserException: Attempt was made to manually set the
> id component of a Key primary key. If you want to control the value of
> the primary key, set the name component instead.
>
> On Sep 18, 1:10 pm, Morgoth <nmarc...@yahoo.com> wrote:
>
>
>
> > Hi,
>
> > I'm trying to set the primary key in order to be able to read from DB
> > the exact object faster. Looking at that 
> > tutorialhttp://code.google.com/appengine/docs/java/datastore/creatinggettinga...
> > this should be possible. Nevertheless all my attempts using
> > Key k = KeyFactory.createKey(Unit.class.getSimpleName(), 11111);
> > or guessing with any other variations I always receive:
>
> > javax.jdo.JDOFatalUserException: Attempt was made to manually set the
> > id component of a Key primary key.  If you want to control the value
> > of the primary key, set the name component instead.
>
> > What I'm doing wrong? Is it possible at all to set my own part of the
> > primary key? What "set the name component" means? AFAIK the key
> > contains appID, object kind and ID, there is no name as part of the
> > key.
>
> > Sorry if my question is stupid, but I'm just starting with GWT.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to