List of usage examples for org.hibernate Query setDate
@Deprecated @SuppressWarnings("unchecked") default Query<R> setDate(String name, Date val)
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public List queryList(String namedQuery, Map<String, Object> params) { HibernateUtility.getSession().clear(); Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }// ww w . jav a2 s. c om if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } return query.list(); }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public void queryNoResult(String namedQuery, Map<String, Object> params) { Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }/*from w ww . ja va 2 s .c o m*/ if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } query.executeUpdate(); HibernateUtility.getSession().flush(); HibernateUtility.getSession().clear(); }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public Object queryUnique(String namedQuery, Map<String, Object> params) { HibernateUtility.getSession().clear(); Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }//www . j av a 2 s . c o m if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } return query.uniqueResult(); }
From source file:br.com.livraria.dao.VendaDAO.java
public List<Venda> buscar(VendaFilter filtro) { List<Venda> vendas = null; StringBuilder sql = new StringBuilder(); sql.append("SELECT venda FROM Venda venda "); if (filtro.getDataInicial() != null & filtro.getDataFinal() != null) { sql.append("WHERE venda.horario BETWEEN :dataInicial AND :dataFinal "); }//from w ww. java2 s. c o m sql.append("ORDER BY venda.horario"); Session sessao = HibernateUtil.getSessionFactory().openSession(); try { Query consulta = sessao.createQuery(sql.toString()); if (filtro.getDataInicial() != null & filtro.getDataFinal() != null) { consulta.setDate("dataInicial", filtro.getDataInicial()); consulta.setDate("dataFinal", filtro.getDataFinal()); } vendas = consulta.list(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return vendas; }
From source file:br.com.ln.dao.PlanoContaDao.java
public static LnSaldoconta grabSaldoAtualConta(Integer ctaInCodigo) { Session session = null;/* w w w. j ava 2 s. c om*/ Transaction tx; LnSaldoconta lnSaldoconta = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Date sacDtData = grabBuscaUltimoSaldo(ctaInCodigo); Query query = session.getNamedQuery("LnSaldoconta.findByCtaInCodigoSacDtData"); query.setInteger("ctaInCodigo", ctaInCodigo); query.setDate("sacDtData", sacDtData); List list = query.list(); tx.commit(); if (list != null && list.size() > 0) { lnSaldoconta = (LnSaldoconta) list.get(0); } } finally { if (session != null && session.isOpen()) { session.close(); } } return lnSaldoconta; }
From source file:br.com.ln.dao.PlanoContaDao.java
public static LnSaldoconta grabSaldoAtualConta(Integer ctaInCodigo, Date sacDtData) { Session session = null;/*from ww w. j a va 2s . co m*/ Transaction tx; LnSaldoconta lnSaldoconta = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnSaldoconta.findByCtaInCodigoSacDtData"); query.setInteger("ctaInCodigo", ctaInCodigo); query.setDate("sacDtData", sacDtData); List list = query.list(); tx.commit(); if (list != null && list.size() > 0) { lnSaldoconta = (LnSaldoconta) list.get(0); } } finally { if (session != null && session.isOpen()) { session.close(); } } return lnSaldoconta; }
From source file:br.com.ln.dao.TabelaDao.java
public static synchronized List<LnTabela> grabLnTabelaDate(Integer ttbInCodigo, Date tabDtInicio, Date tabDtFinal) {// w w w .j a v a 2 s . c o m Session session = null; Transaction tx; List<LnTabela> listaTabela = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.createQuery( "select l from LnTabela l where l.ttbInCodigo = :ttbInCodigo and l.tabDtFinal >= :tabDtFinal"); query.setInteger("ttbInCodigo", ttbInCodigo); query.setDate("tabDtFinal", tabDtFinal); listaTabela = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listaTabela; }
From source file:br.eti.sw.pontocerto.dao.impl.PontoDoDiaDAOHibernate.java
@Override public PontoDoDia buscarPontoDoDia(Date data, Usuario usuario) { String hql = "from PontoDoDia ponto where ponto.dataRealizacao = :data and ponto.usuario = :usuario"; Query consulta = this.session.createQuery(hql); consulta.setDate("data", data); consulta.setInteger("usuario", usuario.getId()); return (PontoDoDia) consulta.uniqueResult(); }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<DpPessoa> consultarAtivasNaDataOrgao(final Date dt, final CpOrgaoUsuario org) { final Query query; query = getSessao().getNamedQuery("consultarAtivasNaDataOrgao"); query.setLong("idOrgaoUsu", org.getIdOrgaoUsu()); query.setDate("dt", dt); return query.list(); }
From source file:br.gov.jfrj.siga.ex.gsa.ExAdaptor.java
License:Open Source License
protected void pushDocIds(DocIdPusher pusher, Date date) throws InterruptedException { try {// ww w . jav a2 s . c o m BufferingPusher outstream = new BufferingPusher(pusher); ExDao dao = ExDao.getInstance(); Query q = dao.getSessao().createQuery(getIdsHql()); q.setDate("dt", date); @SuppressWarnings("rawtypes") Iterator i = q.iterate(); while (i.hasNext()) { DocId id = new DocId("" + i.next()); outstream.add(id); } outstream.forcePush(); } finally { ExDao.freeInstance(); } }