I have followed a working JPA example to retrieve Category objects as such:
return (ArrayList<Category>) getEntityManager().createQuery("from Category").getResultList();
The query is very shorthand - and I can t find the rules for what is optional and what isn t in any of the guides. Is this brevity acceptable?
Secondly, I want to now implement this in a generic DAO, something such as:
public interface DAO<E, K>
{
List<E> getAll();
}
How can I rewrite the first query to work for all types as I can t hardcode the "from Category"..?