I followed a working JPA example to retrieve category objects as such:
return (ArrayList<Category>) getEntityManager().createQuery("from Category").getResultList();
The request is very short - and I cannot find the rules for what is optional and what is not in any of the manuals. Is this brevity acceptable?
Secondly, I want to implement this in a general DAO, for example:
public interface DAO<E, K>
{
List<E> getAll();
}
How can I rewrite the first query to work for all types, since I can’t hardcode "from the category" ..?
source
share