Guest User

LancamentosRepository.java

a guest
Jun 28th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package com.ufop.financeiro.repository;
  2.  
  3. import java.io.Serializable;
  4. import java.util.List;
  5.  
  6. import javax.inject.Inject;
  7. import javax.persistence.EntityManager;
  8. import javax.persistence.EntityTransaction;
  9. import javax.persistence.TypedQuery;
  10.  
  11. import com.ufop.financeiro.model.Lancamento;
  12.  
  13. public class LancamentosRepository implements Serializable {
  14.  
  15.     private static final long serialVersionUID = 1L;
  16.    
  17.     private EntityManager manager;
  18.    
  19.     @Inject
  20.     public LancamentosRepository(EntityManager manager) {
  21.         this.manager = manager;
  22.     }
  23.    
  24.     public List<Lancamento> all() {
  25.         TypedQuery<Lancamento> query = manager.createQuery("from Lancamento", Lancamento.class);
  26.         return query.getResultList();
  27.     }
  28.    
  29.     public void adicionar(Lancamento lancamento) {
  30.         this.manager.persist(lancamento);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment