When you say it doesn't work, do you mean that it does not retrieve the
entity? Can you try creating a Key with the id instead of passing the ID
directly?

http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/KeyFactory.html

That is, try KeyFactory.createKey(myEntity.class.getName(), keyId);

On Tue, Dec 15, 2009 at 11:39 AM, a.maza <[email protected]> wrote:

> According to the documentation on
>
> http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys
> it should be possible to retrieve an entity using a different key type
> than the key field in the class.
>
> Assuming the following entity having a key (encoded string) and a
> keyId like
>
>    @PrimaryKey
>    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>    @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> value="true")
>    private String encodedKey;
>
>    @Persistent
>    @Extension(vendorName="datanucleus", key="gae.pk-id",
> value="true")
>    private Long keyId;
>
> it should be possible to retrieve the entity by both
>
> pm.getObjectById(myEntity.class, encodedKey);
> and
> pm.getObjectById(myEntity.class, keyId);
>
> do I understand that correctly? - (since it does not work out for my
> code)
>
> thanks,
> andr
>
> --
>
> 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
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to