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