public List searchObjects(Class type, String queryString, String[] queryParams) {
        List items = new ArrayList();

        if (em != null) {
            try {
                Query query = em.createQuery("SELECT o FROM " + type.getName() + " o "
                        + (queryString == null || queryString.isEmpty() ? "" : " WHERE " + queryString));
                if (queryString != null && !queryString.isEmpty()) {
                    int i = 0;
                    for (String queryParam : queryParams) {
                        query.setParameter(++i, queryParam);
                    }
                }
                items = query.getResultList();
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            } finally {
                em.close();
            }
        }
        return items;
    }