Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package br.com.dasa.siscan; import br.com.hibernate.utils.OracleHelper; import br.com.hibernate.utils.SessionFactoriByDBName; import br.com.wservice.StaticsQuery; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; /** * * @author f12684146896 */ public class SqlDaoSiscan { public List<ExameColoUtero> buscaCitopatologico(String uniStCodigo, String strDbName) { List<ExameColoUtero> listExame = new ArrayList<ExameColoUtero>(); Session session = null; 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; } }