java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/PodnikHibernateDAO.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 11 Feb 2010 10:06:39 +0100
changeset 28 0f037986bb6b
permissions -rw-r--r--
Hibernate.
     1 package cz.frantovo.nekurak.ejb;
     2 
     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;
     9 
    10 /**
    11  *
    12  * @author fiki
    13  */
    14 @Stateless
    15 public class PodnikHibernateDAO implements PodnikHibernateDAORemote {
    16 
    17     private static final String PU = "nekurak.net-PU";
    18 
    19     @PersistenceContext(unitName = PU)
    20     private EntityManager em;
    21 
    22     public Collection<Podnik> getPodniky() {
    23 	Query dotaz = em.createQuery("FROM " + t(Podnik.class) + " o ORDER BY nazev");
    24         return dotaz.getResultList();
    25     }
    26 
    27     
    28     private static String t(Class trida) {
    29         return trida.getSimpleName();
    30     }
    31 }