Thanks for this. But is there a way to get a specific entity using the
"ID/Name" value generated by the data-store?

On Wed, Apr 6, 2011 at 8:19 AM, Ian Marshall <ianmarshall...@gmail.com> wrote:
> I use the following code to define my persistent entity classes in
> JDO.
>
> I have find my persistent entities by encoded key string or ID - my
> choice.
>
> Enjoy?
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION,
>  detachable = "true")
> public class MyPersistentClass implements Serializable
> {
>  private static final long serialVersionUID = 1L;
>
>  @PrimaryKey
>  @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>  @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> value="true")
>  private String sEncodedKey;
>
>  @Persistent
>  @Extension(vendorName="datanucleus", key="gae.pk-id", value="true")
>  private Long loID;
>
>  //
>  // Other persistent data members...
>  //
>
>  public String getEncodedKey()
>  {
>    return sEncodedKey;
>  }
>
>  public Long getID()
>  {
>    return loID;
>  }
>
>  //
>  // Getter and setter methods for
>  // the other persistent data members...
>  //
> }
>
>
> On Apr 5, 3:44 pm, Luca Matteis <lmatt...@gmail.com> wrote:
>> To identify my JDO objects in Google App Engine I use the Key type. It
>> works fine but when I need to pass this through urls it gets sort of
>> long.
>>
>> For 
>> example:http://mysite.com/user/aghtaWx1LWFwcHIZCxIGTXlVc2VyGAMMCxIHTXlJbWFnZR...
>>
>> When viewing my entities in my admin viewer I can see that the
>> data-store also sets an "id" for my entity object, which seems to be
>> an incremental numeric value, which is quite short compared to the Key
>> string. Can I use this to grab information on my object? How do I do
>> this? I tried using getObjectbyId() with the id instead of the key...
>> it doesn't work.
>>
>> Also, should I be using a Long type to identify objects instead of Key types?
>
> --
> 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.
>
>

-- 
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