FetchGroup fetchGroup = new FetchGroup();
ClassDescriptor descriptor = context.getDescriptor(entityType);
List<DatabaseMapping> pkMappings = descriptor.getObjectBuilder().getPrimaryKeyMappings();
for (DatabaseMapping mapping: pkMappings){
fetchGroup.addAttribute(mapping.getAttributeName());
}
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(QueryHints.FETCH_GROUP, fetchGroup);
properties.put(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheOnly);
Object entity = context.find(null, entityType, id, properties);