Datasets:
ArXiv:
License:
| 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> { | |
| public SiteVendas get(String id) { | |
| EntityManager em = this.getEntityManager(); | |
| SiteVendas site = em.find(SiteVendas.class, id); | |
| em.close(); | |
| return site; | |
| } | |
| public void save(SiteVendas site) throws EntityExistsException { | |
| EntityManager em = this.getEntityManager(); | |
| EntityTransaction tx = em.getTransaction(); | |
| tx.begin(); | |
| em.persist(site); | |
| tx.commit(); | |
| em.close(); | |
| } | |
| public void update(SiteVendas site) throws EntityExistsException { | |
| EntityManager em = this.getEntityManager(); | |
| EntityTransaction tx = em.getTransaction(); | |
| tx.begin(); | |
| em.merge(site); | |
| tx.commit(); | |
| em.close(); | |
| } | |
| public List<SiteVendas> getAll() { | |
| EntityManager em = this.getEntityManager(); | |
| List<SiteVendas> siteVendas = em.createNamedQuery("SiteVendas.findAll", SiteVendas.class).getResultList(); | |
| em.close(); | |
| return siteVendas; | |
| } | |
| 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(); | |
| } | |
| } | |