List of usage examples for org.hibernate Session doWork
void doWork(Work work) throws HibernateException;
From source file:br.com.ateliens.controller.RelatorioServicosBean.java
public void emitir() { Map<String, Object> parametros = new HashMap<>(); parametros.put("data_inicio", this.dataInicio); parametros.put("data_fim", this.dataFim); ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/servicosrealizados.jasper", response, parametros, "Relatrios de Servios.pdf"); Session session = manager.unwrap(Session.class); session.doWork(executor); if (executor.isRelatorioGerado()) { facesContext.responseComplete(); } else {//from w w w. j a v a 2s . c o m FacesUtil.addErrorMessage("A execuo do relatrio no retornou dados."); } }
From source file:br.com.gartech.nfse.integrador.dao.GenericDAOImpl.java
@SuppressWarnings("unchecked") public List<T> findByCriteria(DetachedCriteria detachedCriteria, int firstResult, int maxResults) { Session session = getSession(); session.doWork(new Work() { @Override//from w ww .j a va 2 s . c o m public void execute(Connection cnctn) throws SQLException { cnctn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } }); Criteria criteria = detachedCriteria.getExecutableCriteria(session); criteria.setFirstResult(firstResult); if (maxResults > 0) { criteria.setMaxResults(maxResults); } // criteria.setLockMode(LockMode.READ); //linha adicionada para no fazer LOCK nas consulta j que apenas consulta. List<T> result = criteria.list(); return result; }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioEstatisticaIncritos(Concurso concurso, String status, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor;/* w w w . jav a 2s . c om*/ if (status.equals("CONFIRMADA")) { executor = new ExecutorRelatorio("/relatorios/estatistica_inscritos.jasper", response, parameters, "estatistica_inscritos_confirmados_" + concurso.getId() + ".pdf"); } else { executor = new ExecutorRelatorio("/relatorios/estatistica_inscritos_confirmados.jasper", response, parameters, "estatistica_inscritos_" + concurso.getId() + ".pdf"); } Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); } }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioInscritos(Concurso concurso, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/inscritos_grupo.jasper", response, parameters, "relacao_inscritos_" + concurso.getId() + ".pdf"); Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); }/*from w w w . j av a 2s . c o m*/ }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioInscritosDeferidos(Concurso concurso, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/inscritos_grupo_deferidos.jasper", response, parameters, "relacao_inscritos_deferidos_" + concurso.getId() + ".pdf"); Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); }//from ww w .j a v a 2 s . c o m }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioInscritosDeferidosPNE(Concurso concurso, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor = new ExecutorRelatorio( "/relatorios/inscritos_grupo_confirmada_deficiente.jasper", response, parameters, "relacao_inscritos_deferidos_pne_" + concurso.getId() + ".pdf"); Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); }/* w w w . j a v a 2s. c o m*/ }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioListaPresenca(Concurso concurso, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/inscritos_presenca.jasper", response, parameters, "inscritos_presenca_" + concurso.getId() + ".pdf"); Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); }/*from w ww.j ava 2s .c om*/ }
From source file:br.ufac.sion.service.ConcursoService.java
public void geraRelatorioInscritosIndeferidos(Concurso concurso, HttpServletResponse response) throws NegocioException { Map<String, Object> parameters = new HashMap<>(); InputStream logo = getClass().getResourceAsStream("/relatorios/topo.jpg"); parameters.put("id_concurso", concurso.getId()); parameters.put("logo", logo); ExecutorRelatorio executor = new ExecutorRelatorio("/relatorios/inscritos_grupo_indeferidos.jasper", response, parameters, "relacao_inscritos_indeferidos_" + concurso.getId() + ".pdf"); Session session = em.unwrap(Session.class); session.doWork(executor); if (!executor.isRelatorioGerado()) { throw new NegocioException("A execuo do relatrio no retornou dados."); }//from ww w . jav a2 s. c o m }
From source file:com.acme.spring.hibernate.HibernateTestHelper.java
License:Apache License
/** * <p>Executes a sql script.</p> * * @param session the hibernate session//from w w w . ja va 2 s.com * @param fileName the file name * * @throws java.io.IOException if any error occurs */ public static void runScript(Session session, String fileName) throws IOException { // retrieves the resource from class path InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName); BufferedReader inputReader = new BufferedReader(new InputStreamReader(input)); // loads the entire file StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = inputReader.readLine()) != null) { if (!line.startsWith("--")) { stringBuilder.append(line); } } // splits the commands by semicolon String[] commands = stringBuilder.toString().split(";"); for (final String command : commands) { session.doWork(new Work() { public void execute(Connection connection) throws SQLException { connection.prepareStatement(command).execute(); } }); } }
From source file:com.axelor.db.JPA.java
License:Open Source License
/** * Perform JDBC related work using the {@link Connection} managed by the current * {@link EntityManager}./* w w w. j av a 2 s . c o m*/ * * @param work * The work to be performed * @throws PersistenceException * Generally indicates wrapped {@link SQLException} */ public static void jdbcWork(final JDBCWork work) { Session session = (Session) em().getDelegate(); try { session.doWork(new org.hibernate.jdbc.Work() { @Override public void execute(Connection connection) throws SQLException { work.execute(connection); } }); } catch (HibernateException e) { throw new PersistenceException(e); } }