Jeff,
I am using UUID with timestamp to generate unique Id strings. They are ordered by time, work very well and quite generic. It seems like a common requirement, for people to have naturally ordered entity ids.
Here is a class I use as base, to autogenerate such id strings. it is very reusable. I think it will be useful for people with similar requirements, if we can add such a class to Ofy ?
public abstract class BaseTimeKeyIdModel {
@Id
@Getter
@Setter
private String name;
@OnSave
public void generateId() {
long ts = System.currentTimeMillis();
setIdTimeStamp(ts);
}
public void setIdTimeStamp(long ts) {
synchronized (this) {
if (Strings.isNullOrEmpty(name)) {
this.name = ts + "-" + UUID.randomUUID().toString();
}
}
}
}