code: private final Object find(Class<?> clazz, EntityMetadata metadata, Object rowId, List<String> relationNames) {
  
          List<Object> result = null;
          try {
              MetamodelImpl metaModel =
                  (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
  
              EntityType entityType = metaModel.entity(clazz);
  
              List<ManagedType> subTypes = ((AbstractManagedType) entityType).getSubManagedType();
  
              if (!subTypes.isEmpty()) {
                  for (ManagedType subEntity : subTypes) {
                      EntityMetadata subEntityMetadata =
                          KunderaMetadataManager.getEntityMetadata(kunderaMetadata, subEntity.getJavaType());
                      result = populate(clazz, subEntityMetadata, rowId, subEntityMetadata.getRelationNames(), metaModel);
                      if (result != null && !result.isEmpty()) {
                          break;
                      }
                  }
              } else {
                  result = populate(clazz, metadata, rowId, relationNames, metaModel);
              }
          } catch (Exception e) {
              log.error("Error while retrieving records from database for entity {} and key {}, Caused by: .", clazz,
                  rowId, e);
  
              throw new PersistenceException(e);
          }
  
          return result != null && !result.isEmpty() ? result.get(0) : null;
      }
docs: Find.
  
  @param clazz
  the clazz
  @param metadata
  the metadata
  @param rowId
  the row id
  @param relationNames
  the relation names
  @return the object