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.
Syntax
public String getDocumentUrl(Object entity);
Parameters |
|
|
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. |
Example
public static class Comment {
private String author;
private String message;
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
session.advanced().getDocumentId(comment); // e.g. comments/1