franta-hg@39: package cz.frantovo.nekurak.dao; franta-hg@39: franta-hg@39: import cz.frantovo.nekurak.dto.Podnik; franta-hg@39: import cz.frantovo.nekurak.ejb.PodnikDAORemote; franta-hg@39: import java.util.Collection; franta-hg@39: import javax.ejb.LocalBean; franta-hg@39: import javax.ejb.Stateless; franta-hg@39: import javax.persistence.EntityManager; franta-hg@39: import javax.persistence.PersistenceContext; franta-hg@39: import javax.persistence.Query; franta-hg@39: franta-hg@39: /** franta-hg@39: * franta-hg@39: * @author fiki franta-hg@39: */ franta-hg@39: @Stateless franta-hg@39: @LocalBean franta-hg@39: public class PodnikDAO implements PodnikDAORemote { franta-hg@39: franta-hg@39: private static final String PU = "nekurak.net-PU"; franta-hg@39: @PersistenceContext(unitName = PU) franta-hg@39: private EntityManager em; franta-hg@39: franta-hg@39: public Collection getPodniky() { franta-hg@39: Query dotaz = em.createQuery("FROM " + t(Podnik.class) + " o ORDER BY nazev"); franta-hg@39: return dotaz.getResultList(); franta-hg@39: } franta-hg@39: franta-hg@40: public void uloz(Podnik p) { franta-hg@40: em.persist(p); franta-hg@40: } franta-hg@40: franta-hg@39: private static String t(Class trida) { franta-hg@39: return trida.getSimpleName(); franta-hg@39: } franta-hg@39: }