Session: How to get entity Id?

Entities does not have to contain Id property or field. In case of such an entity and a need of knowing under what Id it is stored on server getDocumentId method has been created.


public String getDocumentUrl(Object entity);
entity Object Instance of an entity for which Id will be returned
Return Value
String Returns Id for specified entity. Method may return null if entity is null, isn't tracked or Id will be generated on the server.


public static class Comment {
  private String author;
  private String message;
  public String getAuthor() {
    return author;
  public void setAuthor(String author) { = author;
  public String getMessage() {
    return message;
  public void setMessage(String message) {
    this.message = message;

session.advanced().getDocumentId(comment); // e.g. comments/1