List of usage examples for org.hibernate Query setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(String name, String val)
From source file:br.com.bibliotecasj.DAO.UsuarioDAO.java
@Override public Usuario buscar(String cpf) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Usuario usu = null;//from w w w . ja v a 2 s . c o m try { Query consulta = sessao.getNamedQuery("Usuario.BuscarCpf"); consulta.setString("cpf", cpf); usu = (Usuario) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return usu; }
From source file:br.com.construtora.dao.UsuarioDAO.java
public Usuario findByLogin(String login) { session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();//from w w w . j a v a 2 s . co m Query q = session.getNamedQuery("Usuario.findByDeLogi"); q.setString("deLogi", login); Usuario usuario = (Usuario) q.uniqueResult(); session.getTransaction().commit(); return usuario; }
From source file:br.com.dasa.hepic.SqlDaoHepic.java
public List<ExameEnvioHepic> buscaExameHepic(LabSistema sistema, String strDbName) { Session session = null;/*from w ww. j a v a 2s .co m*/ Transaction tx = null; List<ExameEnvioHepic> listExameEnvioHepic = new ArrayList<ExameEnvioHepic>(); try { session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery(StaticsQuery.SQLHEPICEXAME); query.setString("uniStCodigo", sistema.getUniStCodigo().getUniStCodigo()); query.setString("sisStCodigo", sistema.getSisStCodigo()); List list = query.list(); tx.commit(); if (list != null && !list.isEmpty()) { for (int i = 0; i < list.size(); i++) { ExameEnvioHepic exameEnvioHepic = new ExameEnvioHepic(); Object[] tupla = (Object[]) list.get(i); exameEnvioHepic.setReqStCodigo((String) tupla[0]); exameEnvioHepic.setExaStCodigo((String) tupla[1]); exameEnvioHepic.setSeqStCodigo((String) tupla[2]); exameEnvioHepic.setExaStDescricao((String) tupla[3]); exameEnvioHepic.setDerDtEntradaMat((Date) tupla[4]); exameEnvioHepic.setReqStCodigoAlt((String) tupla[5]); exameEnvioHepic.setPacStNome((String) tupla[6]); exameEnvioHepic.setDerDtAssinatura((Date) tupla[7]); exameEnvioHepic.setMatStCodigo((String) tupla[8]); exameEnvioHepic.setMatStDescricao((String) tupla[9]); exameEnvioHepic.setPacStProntuario((String) tupla[10]); exameEnvioHepic.setReq_bl_infoauxiliar((String) tupla[11]); exameEnvioHepic.setDepStCodigo((String) tupla[12]); // exameEnvioHepic.setExaChGrupo((String) tupla[13]); exameEnvioHepic.setDerInCodigo((BigDecimal) tupla[14]); listExameEnvioHepic.add(exameEnvioHepic); } } } finally { if (session != null && session.isOpen()) { session.close(); } } return listExameEnvioHepic; }
From source file:br.com.dasa.hepic.SqlDaoHepic.java
public List<AntibiogramaResultado> buscaResultadoTsa(String reqStCodigo, String strDbName) { List<AntibiogramaResultado> listResulTsa = null; Session session = null;//from www. ja v a 2s . co m Transaction tx = null; try { session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery(StaticsQuery.RESULTADOTSAHEPIC); query.setString("reqStCodigo", reqStCodigo); List list = query.list(); tx.commit(); if (list != null && !list.isEmpty()) { listResulTsa = new ArrayList<AntibiogramaResultado>(); for (int i = 0; i < list.size(); i++) { AntibiogramaResultado antibiogramaResultado = new AntibiogramaResultado(); Object[] tupla = (Object[]) list.get(i); antibiogramaResultado.setReqStCodigo((String) tupla[0]); antibiogramaResultado.setSeqStCodigo((String) tupla[1]); antibiogramaResultado.setResStIngresso((String) tupla[2]); antibiogramaResultado.setResStResultado((String) tupla[3]); listResulTsa.add(antibiogramaResultado); } } } finally { if (session != null && session.isOpen()) { session.close(); } } return listResulTsa; }
From source file:br.com.dasa.siscan.SqlDaoSiscan.java
public List<ExameColoUtero> buscaCitopatologico(String uniStCodigo, String strDbName) { List<ExameColoUtero> listExame = new ArrayList<ExameColoUtero>(); Session session = null;// w w w. j ava 2s.c om Transaction tx = null; try { session = SessionFactoriByDBName.getCurrentSession4FacesByDbName(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery(StaticsQuery.SQLSISCOLO); query.setString("uniStCodigo", uniStCodigo); List lst = query.list(); tx.commit(); if (lst != null && !lst.isEmpty()) { for (int i = 0; i < lst.size(); i++) { ExameColoUtero exameColoUtero = new ExameColoUtero(); Object[] tupla = (Object[]) lst.get(i); exameColoUtero.setPacInCodsus((BigDecimal) tupla[0]); exameColoUtero.setOriStCnes((String) tupla[1]); exameColoUtero.setUniStCnes((String) tupla[2]); exameColoUtero.setPacStNome((String) tupla[3]); exameColoUtero.setPacDtNascimento((Date) tupla[4]); exameColoUtero.setPacStSexo((Character) tupla[5]); exameColoUtero.setPacStResp((String) tupla[6]); // exameColoUtero.setPacStRaca("99");tupla[7] // exameColoUtero.setPacStRaca("99");tupla[8] exameColoUtero.setPacStProntuario((String) tupla[9]); exameColoUtero.setCinStCodigo((String) tupla[10]); exameColoUtero.setResStIngresso((String) tupla[11]); exameColoUtero.setReqDtCadastro((Date) tupla[12]); exameColoUtero.setDerDtAssinatura((Date) tupla[13]); exameColoUtero.setUsuStCodigoass((String) tupla[14]); exameColoUtero.setUsuStCpf((String) tupla[15]); exameColoUtero.setReqStDum((String) tupla[16]); exameColoUtero.setReqStCodigo((String) tupla[17]); listExame.add(exameColoUtero); } } } finally { if (session != null && session.isOpen()) { session.close(); } } return listExame; }
From source file:br.com.fatecmogidascruzes.saph.dao.UserDAO.java
@Override public User getUserByCredentials(Credential credential) { session = HSession.getSession();//from ww w . j a v a 2 s . c o m String hql = "from User usr WHERE :login = usr.credential.login AND :password = usr.credential.password"; Query q = session.createQuery(hql); q.setString("login", credential.getLogin()); q.setString("password", credential.getPassword()); User user = (User) q.uniqueResult(); return user; }
From source file:br.com.financeiro.dao.UsuarioDAOHibernate.java
@Override public Usuario buscaPorLogin(String login) { String hql = "select u from Usuario u where u.login = :login"; Query consulta = this.session.createQuery(hql); consulta.setString("login", login); return (Usuario) consulta.uniqueResult(); }
From source file:br.com.gvt.eng.vod.dao.AssetDAO.java
@SuppressWarnings("unchecked") public List<OnDemandContentVO> findByName(String c, LikeOperator like) { StringBuilder hql = new StringBuilder("select "); hql.append("a.title as title, "); hql.append("a.originalTitle as originalTitle, "); hql.append("'UNKNOWN' as genre, "); hql.append("c.description as category, "); hql.append("a.subtitles as subtitle, "); hql.append("a.country as country, "); hql.append("sc.description as subCategory, "); hql.append("a.assetId as assetId, "); hql.append("a.creationDate as creationDate, "); hql.append("a.description as description, "); hql.append("a.director as director, "); hql.append("a.actors as actors, "); hql.append("a.episode as episode, "); hql.append("a.billingID as billingID, "); hql.append("a.episodeName as episodeName, "); hql.append("a.licenseWindowEnd as licenseWindowEnd, "); hql.append("a.licenseWindowStart as licenseWindowStart, "); hql.append("a.price as price, "); hql.append("a.releaseYear as releaseYear, "); hql.append("a.season as season, "); hql.append("a.languages as languages, "); hql.append("a.assetInfo as assetInfo, "); hql.append("r.rating as rating, "); hql.append("r.adult as isAdult, "); hql.append("a.totalTime as totalTime, "); hql.append("a.product as product, "); hql.append("a.screenFormat as screenFormat, "); hql.append("a.audioType as audioType, "); hql.append("a.canResume as canResume, "); hql.append("a.isHD as isHD, "); hql.append("a.isRevised as isRevised, "); hql.append("a.fileSize as fileSize, "); hql.append("a.checksum as checksum, "); hql.append("a.bitrate as bitrate, "); hql.append("a.titleAlternative as titleAlternative, "); hql.append("at.description as assetType, "); hql.append("cp.providerId as contentProvider "); hql.append(//from w w w . ja v a 2 s . co m "from IpvodAsset as a left join a.ipvodCategory1 c left join a.ipvodCategory2 sc left join a.ipvodAssetType at left join a.ipvodContentProvider cp left join a.rating r "); hql.append("where upper(a.title) like upper(:param) order by a.title asc "); Query query = getSession().createQuery(String.valueOf(hql)); if (LikeOperator.CONDITION_ALL.equals(like)) { query.setString("param", "%" + c + "%"); } else if (LikeOperator.CONDITION_LEFT.equals(like)) { query.setString("param", c + "%"); } else { query.setString("param", "%" + c); } query.setResultTransformer(new AliasToBeanResultTransformer(OnDemandContentVO.class)); return query.list(); }
From source file:br.com.hslife.clickafacil.dao.FuncionarioDao.java
License:Open Source License
public boolean matriculaExiste(String numero) throws Exception { String hql = "from Funcionario where matricula = :numero"; Query q = HibernateUtil.getInstance().createQuery(hql); q.setString("numero", numero); if (q.list().size() == 0) { return false; } else {//www . ja v a2 s. c om return true; } }
From source file:br.com.hslife.clickafacil.dao.FuncionarioDao.java
License:Open Source License
public boolean cpfExiste(String numero) throws Exception { String hql = "from Funcionario where cpf = :numero"; Query q = HibernateUtil.getInstance().createQuery(hql); q.setString("numero", numero); if (q.list().size() == 0) { return false; } else {//from w w w. ja va 2s.c om return true; } }