This sounds a lot like a url sharing service like tinyurl, etc.
Perhaps investigate how they create their shortened urls.

Could you use String.hashcode()? I haven't worked with it before, but
it might generate the ints that you need.

On Aug 1, 1:32 am, Neo wrote:
> I have an Entity type say URLInfo which keeps info about URLs. The primary
> key of this entity is URL itself ( that makes sure that I always have
> unique URLs in the datastore). I also want unique integer id for each url
> so that sharing the id becomes easier. Though, I can use GUIDs, but that is
> not a preferred thing for me. How can I achieve this requirement? Integer
> Ids need not be sequential ( preferred, if they are). Entities can be
> generated at a faster rate (that means I can't keep a common counter to
> update each time I generate a new URL record). This is what I have tried so
> far - In the URLInfo class, I defined a field - Long Id and annotate it
> with @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) in the hope
> that it will get automatically generated with the unique value. But when I
> save the new entity (with id set as null), it saves the entity in the
> datastore but doesn't assign any value to this field.
>
> I am trying all this on a local machine. I am using Java/JDO.
>
> Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to