How to fetch/set ConcurrencyVersion of a model?
During programmatic read of any model using ModelDataService, ModelQueryComponent namely, ConcurrencyVersionRetrieval has to be used. Example:
public
Book getBook(
long
sysId){
ModelDataService mds = Services.get(ModelDataService.
class
);
Book book=
null
;
try
{
book = mds.readById(Book.
class
, sysId, getPlatformUserContext(), ModelQuery.concurrencyVersionRetrieval())
}
catch
(RuntimeException e) {
//book was not found... do something here!
}
return
book;
}
As shown in the example above, if ModelQuery.concurrencyVersionRetrieval() is used during read, concurrencyVersion transient fieldwill be set for Book model and its child-level models retrieved in this read operation.