}
final DatabaseField rowId = descriptor.buildField(new DatabaseField(ROWID));
final List<DatabaseField> fields = new ArrayList<DatabaseField>();
fields.add(rowId);
// May already have the index if has inheritance.
CacheIndex existingIndex = descriptor.getCachePolicy().getCacheIndex(fields);
if (existingIndex == null) {
if (descriptor.isChildDescriptor()) {
existingIndex = descriptor.getInheritancePolicy().getRootParentDescriptor().getCachePolicy().getCacheIndex(fields);
}
if (existingIndex == null) {
existingIndex = new CacheIndex(fields);
existingIndex.setIsUpdateable(false);
existingIndex.setIsInsertable(false);
}
descriptor.getCachePolicy().addCacheIndex(existingIndex);
}
final CacheIndex index = existingIndex;
rowId.setInsertable(false);
rowId.setUpdatable(false);
rowId.setCreatable(false);
descriptor.getFields().add(rowId);
descriptor.getAllFields().add(rowId);