/*
(non-Javadoc)

@see com.impetus.kundera.client.Client#findAll(java.lang.Class,
java.lang.String[], java.lang.Object[])
195687
@Override
    public <E> List<E> findAll(Class<E> entityClass, String[] columnsToSelect, Object... keys)
    {
        List entities = new ArrayList<E>();
        for (Object key : keys)
        {
            entities.add(find(entityClass, key));
        }
        return entities;
    }
900342
@Override
    public Object find(Class entityClass, Object key)
    {
        Object result = null;
        Object connection = getConnection();
        try
        {
            result = fetch(entityClass, key, connection, null);
        }
        catch (InstantiationException e)
        {
            logger.error("Error during find by key:", e);
            throw new PersistenceException(e);
        }
        catch (IllegalAccessException e)
        {
            logger.error("Error during find by key:", e);
            throw new PersistenceException(e);
        }
        finally
        {
            onCleanup(connection);
        }

        return result;
    }
350258
@Override
    public Object find(Class entityClass, Object key)
    {

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        JsonDocument doc;
        String id = generateJsonDocId(entityMetadata.getTableName(), key.toString());
        doc = bucket.get(id);
        LOGGER.debug("Found result for ID : " + key.toString() + " in the " + bucket.name() + " Bucket");

        if (doc == null)
        {
            return null;
        }
        else
        {
            MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                    .getMetamodel(entityMetadata.getPersistenceUnit());
            EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());
            return handler.getEntityFromDocument(entityClass, doc.content(), entityType);
        }
    }
1104310
@Override
	public List<CPDefinitionGroupedEntry> findAll() {
		return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
	}
862712
@Override
    public <E> List<E> findAll(Class<E> entityClass, String[] columnsToSelect, Object... keys)
    {
        Object connection = getConnection();
        List results = new ArrayList();
        try
        {
            for (Object key : keys)
            {
                Object result = fetch(entityClass, key, connection, null);
                if (result != null)
                {
                    results.add(result);
                }
            }
        }
        catch (InstantiationException e)
        {
            logger.error("Error during find by key:", e);
            throw new PersistenceException(e);
        }
        catch (IllegalAccessException e)
        {
            logger.error("Error during find by key:", e);
            throw new PersistenceException(e);
        }
        return results;
    }
317288
function findAll(predicate) {
        var key,
            elem,
            result = [];
        for (key in _idMap) {
            if (_idMap.hasOwnProperty(key)) {
                elem = _idMap[key];
                if (predicate(elem)) {
                    result.push(elem);
                }
            }
        }
        return result;
    }
1233428
@Override
    public List readAll(final String tableName, Class clazz, EntityMetadata m, final List<Object> rowKey,
            List<String> relationNames, String... columns) throws IOException
    {

        List output = null;

        Object entity = null;

        HTableInterface hTable = null;

        hTable = gethTable(tableName);

        // Load raw data from HBase
        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                m.getPersistenceUnit());

        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(m.getEntityClazz());
        // For secondary tables.
        List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation())
                .getSecondaryTablesName();
        secondaryTables.add(m.getTableName());
        List<HBaseData> results = new ArrayList<HBaseData>();
        for (String colTableName : secondaryTables)
        {
            List table = ((HBaseReader) hbaseReader).loadAll(hTable, rowKey, colTableName, columns);
            // null check for 'table'. addAll method throws exception if table
            // is null
            if (table != null)
            {
                results.addAll(table);
            }
        }

        output = onRead(tableName, clazz, m, output, hTable, entity, relationNames, results);
        return output;
    }
207379
public List<Entity> findAll(Connection conn, String tableName) throws SQLException{
		return findAll(conn, Entity.create(tableName));
	}
1252327
@Override
    public Object find(Class entityClass, Object key)
    {
        return find(entityClass, key, null);
    }
373136
@Override
	public Collection<T> find(final SearchTerm[] terms, JiteratorFilter<T> filter,
			Boolean orderDesc, String... orderFields)
			throws PersistenceException {

		PopulatorThread<T> populator;

		populator = new PopulatorThread<T>(new JiteratorPopulator<T>() {
			public void populate(Jiterator<T> iterator) throws PersistenceException {
				ResultSet rs = null;
				try {             
					String index = null;
					String[] values = new String[terms.length];
					FindOperator operator = null;

					for (int i = 0; i < terms.length; i++) {
						// since no other way to get index, just assume column
						index = terms[i].getColumn(); 
						values[i] = terms[i].getValue().toString();		
						
						switch (terms[i].getOperator()) {
							case EQUALS: operator = FindOperator.EQ; break;
							case GREATER_THAN: operator = FindOperator.GT; break;
							case GREATER_THAN_OR_EQUAL_TO: operator = FindOperator.GE; break;
							case LESS_THAN: operator = FindOperator.LT; break;
							case LESS_THAN_OR_EQUAL_TO: operator = FindOperator.LE; break;
							default: throw new PersistenceException("Operator " + operator + " not supported!");							
						}						
					}

					// open a session to retrieve the primary key of the table by the values of the specified index
					rs = getSession(index, getPrimaryKeyField()).find(values, operator, 1, 0);

					// for each row, get the object from cache
					while (rs.next()) {
						T object = get(getValue(getPrimaryKeyField(), 1, rs));
						if (object != null) {
							iterator.push(object);
						}
					}
				} catch (Exception e) {
					throw new PersistenceException(e.getMessage());
				} finally {
					try {
						rs.close();
					} catch (SQLException e) {
						throw new PersistenceException(e.getMessage());
					}
				}
			}
		});
		populator.populate();
		return populator.getResult();
	}
115432
public <T> ESDatas<T> searchAll(String index,  Class<T> type) throws ElasticSearchException{

		return searchAll(  index,    DEFAULT_FETCHSIZE , type) ;

	}
463377
private static List<Field> getAllFields(Class<?> clazz){
		if(!clazz.equals(Object.class)){
			List<Field> fields = new ArrayList<Field>(Arrays.asList(clazz.getDeclaredFields()));
			List<Field> fields2 = getAllFields(clazz.getSuperclass());
			if(fields2!=null){
				fields.addAll(fields2);
			}
			return fields;
		}else{
			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;

    }
514597
@Override
  public <T> List<T> findAll(Class<T> entityClass) {
    return findAll(Util.determineCollectionName(entityClass));
  }
1197591
@Override
    public <T extends WindupVertexFrame> Iterable<T> findAll(Class<T> clazz)
    {
        return service(clazz).findAll();
    }
255416
public <T> List<T> findAll(Class<T> entityClass, String privilegeKey) {
        return findAll(null, entityClass, privilegeKey).getContent();
    }
1259041
@Override
    public List<T> getAll(int firstResult, int maxResults) {
        return getDatabaseSupport().getAll(getEntityClass(), firstResult, maxResults);
    }