/*
(non-Javadoc)

@see javax.persistence.EntityManager#find(java.lang.Class, java.lang.Object)
548045
@Override
    public <T> T find(Class<T> entityClass, Object primaryKey)
    {
        try
        {
            return ivEm.find(entityClass, primaryKey);
        } finally
        {
            if (!inJTATransaction())
            {
                ivEm.clear();
            }
        }
    }
674987
public <T> T findAny(Class<T> classType, String uri) {
        assertNotEmpty(classType, "Class");
        assertNotEmpty(uri, "uri");
        return couchDbClient.get(URI.create(uri), classType);
    }
582054
public <E> List<E> find(Class<E> entityClass, Map<String, String> superColumnMap,
        CassandraDataHandler dataHandler) {
        List<E> entities = null;
        String entityId = null;
        try {
            EntityMetadata entityMetadata =
                KunderaMetadataManager.getEntityMetadata(kunderaMetadata, getPersistenceUnit(), entityClass);
            entities = new ArrayList<E>();
            for (String superColumnName : superColumnMap.keySet()) {
                entityId = superColumnMap.get(superColumnName);
                List<SuperColumn> superColumnList =
                    loadSuperColumns(entityMetadata.getSchema(), entityMetadata.getTableName(), entityId,
                        new String[] { superColumnName.substring(0, superColumnName.indexOf("|")) });
                E e = (E) dataHandler.fromThriftRow(entityMetadata.getEntityClazz(), entityMetadata,
                    new DataRow<SuperColumn>(entityId, entityMetadata.getTableName(), superColumnList));
                if (e != null) {
                    entities.add(e);
                }
            }
        } catch (Exception e) {
            log.error("Error while retrieving records from database for entity {} and key {}, Caused by: . ",
                entityClass, entityId, e);
            throw new KunderaException(e);
        }
        return entities;
    }
514597
@Override
  public <T> List<T> findAll(Class<T> entityClass) {
    return findAll(Util.determineCollectionName(entityClass));
  }
577635
private <T extends Annotation> T findAnnotation(Class<?> cls, Class<T> annotationClass, String name) {
    Class<?> curr = cls;
    T ann = null;
    while (ann == null && curr != null && !curr.equals(Object.class)) {
      ann = findAnnotationLocal(curr, annotationClass, name);
      curr = curr.getSuperclass();
    }
    return ann;
  }
202323
@Override
    public Object find(Class entityClass, Object key)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        Object e = r.db(entityMetadata.getSchema()).table(entityMetadata.getTableName()).get(key).run(connection,
                entityClass);

        PropertyAccessorHelper.setId(e, entityMetadata, key);

        return e;
    }
514408
public static Method findMethodWith(Class<?> searchClass, Class<? extends Annotation> annotationClass) {
		Method foundMethod = null;
		methodFinder: while (searchClass != null && searchClass != Object.class) {
			for (Method method : searchClass.getDeclaredMethods()) {
				if (method.isAnnotationPresent(annotationClass)) {
					foundMethod = method;
					break methodFinder;
				}
			}
			searchClass = searchClass.getSuperclass();
		}

		return foundMethod;
	}
864635
public function find($class, $id)
    {
        if (!isset($id)) {
            return;
        }

        if (null === $class) {
            return $this->dm->find(null, $id);
        }

        return $this->dm->getRepository($class)->find($id);
    }
260657
@Override
  protected Class<?> findClass(String name) throws ClassNotFoundException {
    if (!loadedClassFiles) {
      classFileMap = extractClassFileMap();
      loadedClassFiles = true;
    }

    if (classFileMap == null) {
      throw new ClassNotFoundException(name);
    }

    String internalName = name.replace('.', '/');
    CompiledClass compiledClass = classFileMap.get(internalName);
    if (compiledClass == null) {
      throw new ClassNotFoundException(name);
    }

    // Make sure the class's package is present.
    String pkg = compiledClass.getPackageName();
    if (getPackage(pkg) == null) {
      definePackage(pkg, null, null, null, null, null, null, null);
    }

    byte[] bytes = compiledClass.getBytes();
    return defineClass(name, bytes, 0, bytes.length);
  }
1139640
public static Method findProperty(Class<?> clazz, String name) {
    	assert clazz != null;
    	assert name != null;
        Class<?> entityClass = clazz;
        while (entityClass != null) {
            Method[] methods = (entityClass.isInterface() ? entityClass.getMethods() : entityClass.getDeclaredMethods());
            for (Method method : methods) {
                if (method.getName().equals("get"+ StringUtils.capitalize(name)) ||
                    method.getName().equals("is"+ StringUtils.capitalize(name))) {
                    return method;
                }
            }
            entityClass = entityClass.getSuperclass();
        }
        return null;
    }
1019981
@Override
    public Object[] findIdsByColumn(String schemaName, String tableName, String pKeyName, String columnName,
            Object columnValue, Class entityClazz)
    {
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClazz);

        List<Object> primaryKeys = new ArrayList<Object>();

        DBCollection dbCollection = mongoDb.getCollection(tableName);
        BasicDBObject query = new BasicDBObject();

        query.put(columnName, MongoDBUtils.populateValue(columnValue, columnValue.getClass()));

        DBCursor cursor = dbCollection.find(query);
        KunderaCoreUtils.printQuery("Find id by column:" + query, showQuery);
        DBObject fetchedDocument = null;

        while (cursor.hasNext())
        {
            fetchedDocument = cursor.next();
            Object primaryKey = fetchedDocument.get(pKeyName);
            primaryKey = MongoDBUtils.getTranslatedObject(primaryKey, primaryKey.getClass(), metadata.getIdAttribute()
                    .getJavaType());
            primaryKeys.add(primaryKey);
        }

        if (primaryKeys != null && !primaryKeys.isEmpty())
        {
            return primaryKeys.toArray(new Object[0]);
        }
        return null;

    }
499807
@Override
    public <E> List<E> findAll(Class<E> entityClass, String[] columnsToSelect, Object... rowIds)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        if (rowIds == null)
        {
            return null;
        }
        List results = new ArrayList<E>();

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(entityClass);

        List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();
        try
        {
            if (!subManagedType.isEmpty())
            {
                for (AbstractManagedType subEntity : subManagedType)
                {
                    EntityMetadata subEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                            subEntity.getJavaType());
                    results = handler.readAll(subEntityMetadata.getSchema(), subEntityMetadata.getEntityClazz(),
                            subEntityMetadata, Arrays.asList(rowIds), subEntityMetadata.getRelationNames());
                    // Result will not be empty for match sub entity.
                    if (!results.isEmpty())
                    {
                        break;
                    }
                }
            }
            else
            {

                results = handler.readAll(entityMetadata.getSchema(), entityMetadata.getEntityClazz(), entityMetadata,
                        Arrays.asList(rowIds), entityMetadata.getRelationNames());
            }
        }
        catch (IOException ioex)
        {
            log.error("Error during find All , Caused by: .", ioex);
            throw new KunderaException(ioex);
        }

        return results;
    }
459128
@Override
    public Object find(Class entityClass, Object key)
    {
        EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        GetResponse get = null;

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                .getMetamodel(metadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(metadata.getEntityClazz());

        String keyAsString = getKeyAsString(key, metadata, metaModel);
        try
        {
            get = txClient.prepareGet(metadata.getSchema().toLowerCase(), metadata.getTableName(), keyAsString)
                    .setOperationThreaded(false).execute().get();
        }
        catch (InterruptedException iex)
        {
            logger.error("Error while find record of {}, Caused by :.", entityClass.getSimpleName(), iex);
            throw new PersistenceException(iex);
        }
        catch (ExecutionException eex)
        {
            logger.error("Error while find record of {}, Caused by :.", entityClass.getSimpleName(), eex);
            throw new PersistenceException(eex);
        }

        Map<String, Object> results = get.getSource();

        Object result = null;

        if (get.isExists())
        {
            result = KunderaCoreUtils.createNewInstance(entityClass);
            PropertyAccessorHelper.setId(result, metadata, key);
            result = esResponseReader.wrapFindResult(results, entityType, result, metadata, true);
        }

        return result;
    }
1109257
def find_by(cls, **kwargs) -> 'Entity':
        
        logger.debug(f'Lookup `{cls.__name__}` object with values '
                     f'{kwargs}')

        # Find this item in the repository or raise Error
        results = cls.query.filter(**kwargs).limit(1).all()

        if not results:
            raise ObjectNotFoundError(
                f'`{cls.__name__}` object with values {[item for item in kwargs.items()]} '
                f'does not exist.')

        # Return the first result
        return results.first
686536
@Override
    public Object find(Class entityClass, Object key)
    {
        GraphDatabaseService graphDb = null;
        if (resource != null)
        {
            graphDb = getConnection();
        }

        if (graphDb == null)
            graphDb = factory.getConnection();

        EntityMetadata m = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        Object entity = null;
        Node node = mapper.searchNode(key, m, graphDb, true);

        if (node != null && !((Neo4JTransaction) resource).containsNodeId(node.getId()))

        {
            entity = getEntityWithAssociationFromNode(m, node);
        }

        return entity;
    }
1012402
@SuppressWarnings("unchecked")
    public static boolean findClass(String className) {
        try {
            return getClassLoader().loadClass(className) != null;
        } catch (ClassNotFoundException e) {
            return false;
        } catch (NoClassDefFoundError e) {
            return false;
        }
    }
1140911
@Override
    public <E> List<E> findAll(Class<E> entityClass, String[] columnsToSelect, Object... keys)
    {
        List results = new ArrayList();
        for (Object key : keys)
        {
            Object object = find(entityClass, key);
            if (object != null)
            {
                results.add(object);
            }
        }
        return results;
    }