Hibernate.
1 package cz.frantovo.nekurak.ejb;
3 import cz.frantovo.nekurak.dto.Podnik;
4 import java.util.Collection;
5 import javax.ejb.Stateless;
6 import javax.persistence.EntityManager;
7 import javax.persistence.PersistenceContext;
8 import javax.persistence.Query;
15 public class PodnikHibernateDAO implements PodnikHibernateDAORemote {
17 private static final String PU = "nekurak.net-PU";
19 @PersistenceContext(unitName = PU)
20 private EntityManager em;
22 public Collection<Podnik> getPodniky() {
23 Query dotaz = em.createQuery("FROM " + t(Podnik.class) + " o ORDER BY nazev");
24 return dotaz.getResultList();
28 private static String t(Class trida) {
29 return trida.getSimpleName();