public Category find(Long id) {
    active();

    Category category = categoryDAO.findById(id);

    commit();

    categoryDAO.getEntityManager().close();

    return category;
  }
  public Category[] all(CategoryFilter categoryFilter) {

    active();

    TypedQuery<Category> query =
        categoryDAO.getEntityManager().createNamedQuery("Category.findAll", Category.class);

    query.setFirstResult(categoryFilter.getStart());
    query.setMaxResults(categoryFilter.getSize());

    List<Category> categories = query.getResultList();

    commit();

    categoryDAO.getEntityManager().close();

    for (Category category : categories) LOGGER.info("Category with id " + category.getId());

    return categories.toArray(new Category[categories.size()]);
  }
 public CategoryRepository() {
   categoryDAO = new CategoryDAO();
   categoryDAO.setEntityManager(EntityManagerFactoryServlet.createEntityManager());
   super.setEntityTransaction(categoryDAO.getEntityManager().getTransaction());
 }