Package br.com.colibri.dao

Source Code of br.com.colibri.dao.LocacaoHibernateDAO

package br.com.colibri.dao;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import br.com.colibri.modelo.Locacao;

@Repository(value="locacaoHibernateDAO")
public class LocacaoHibernateDAO {
 
  @Autowired
  private HibernateTemplate hibernateTemplate;

  @Transactional
  public void inserirLocacao(Locacao locacao) throws Exception {
    hibernateTemplate.save(locacao);
  }

  @Transactional
  public Locacao obterPorId(Long id) throws Exception {
    Locacao locacao = hibernateTemplate.get(Locacao.class, id);
    return locacao;
  }

  @Transactional
  public List<Locacao> obterTodasLocacoes() throws Exception {
    List<Locacao> listaLocacoes = this.hibernateTemplate.find("from Locacao");
    return listaLocacoes;
  }
 
  @Transactional
  public List<Locacao> obterLocacoesVencidas() throws Exception {   
    Date dataHoje = new Date();
    List<Locacao> listaLocacoes = this.hibernateTemplate.find("select locacao from Locacao as locacao where locacao.dtEntrega < ?", dataHoje);
    return listaLocacoes;   
 
 
}
TOP

Related Classes of br.com.colibri.dao.LocacaoHibernateDAO

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.