1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/PodnikDAO.java Thu Feb 25 02:41:57 2010 +0100
1.3 @@ -0,0 +1,32 @@
1.4 +package cz.frantovo.nekurak.dao;
1.5 +
1.6 +import cz.frantovo.nekurak.dto.Podnik;
1.7 +import cz.frantovo.nekurak.ejb.PodnikDAORemote;
1.8 +import java.util.Collection;
1.9 +import javax.ejb.LocalBean;
1.10 +import javax.ejb.Stateless;
1.11 +import javax.persistence.EntityManager;
1.12 +import javax.persistence.PersistenceContext;
1.13 +import javax.persistence.Query;
1.14 +
1.15 +/**
1.16 + *
1.17 + * @author fiki
1.18 + */
1.19 +@Stateless
1.20 +@LocalBean
1.21 +public class PodnikDAO implements PodnikDAORemote {
1.22 +
1.23 + private static final String PU = "nekurak.net-PU";
1.24 + @PersistenceContext(unitName = PU)
1.25 + private EntityManager em;
1.26 +
1.27 + public Collection<Podnik> getPodniky() {
1.28 + Query dotaz = em.createQuery("FROM " + t(Podnik.class) + " o ORDER BY nazev");
1.29 + return dotaz.getResultList();
1.30 + }
1.31 +
1.32 + private static String t(Class trida) {
1.33 + return trida.getSimpleName();
1.34 + }
1.35 +}