Datasets:
ArXiv:
License:
File size: 1,686 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
package br.dsw.dao;
import br.dsw.pojo.Promocao;
import br.dsw.pojo.SiteVendas;
import java.util.List;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
public class SiteVendasDAO extends GenericDAO<SiteVendas, String> {
@Override
public SiteVendas get(String id) {
EntityManager em = this.getEntityManager();
SiteVendas site = em.find(SiteVendas.class, id);
em.close();
return site;
}
@Override
public void save(SiteVendas site) throws EntityExistsException {
EntityManager em = this.getEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.persist(site);
tx.commit();
em.close();
}
@Override
public void update(SiteVendas site) throws EntityExistsException {
EntityManager em = this.getEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.merge(site);
tx.commit();
em.close();
}
@Override
public List<SiteVendas> getAll() {
EntityManager em = this.getEntityManager();
List<SiteVendas> siteVendas = em.createNamedQuery("SiteVendas.findAll", SiteVendas.class).getResultList();
em.close();
return siteVendas;
}
@Override
public void delete(SiteVendas site) {
EntityManager em = this.getEntityManager();
EntityTransaction tx = em.getTransaction();
site = em.getReference(SiteVendas.class, site.getNome());
tx.begin();
em.remove(site);
tx.commit();
em.close();
}
}
|