Example #1
0
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
 public boolean crearRegistrosEstados(int periodo) {
   try {
     if (em.isOpen()) {
       // em.getTransaction().begin();
       StoredProcedureQuery storedProcedure =
           em.createStoredProcedureQuery("fn_calcular_registro_estado_default");
       // set parameters
       storedProcedure.registerStoredProcedureParameter(
           "id_periodo", Integer.class, ParameterMode.IN);
       storedProcedure.registerStoredProcedureParameter(
           "result", Boolean.class, ParameterMode.OUT);
       storedProcedure.setParameter("id_periodo", periodo);
       // execute SP
       storedProcedure.execute();
       // get result
       Boolean result = (Boolean) storedProcedure.getOutputParameterValue("result");
       System.out.println("result is: " + result);
       return result;
     }
   } catch (Exception e) {
     e.printStackTrace();
     ;
   }
   return false;
 }
 @Override
 public StoredProcedureQuery createStoredProcedureQuery(String arg0, String... arg1) {
   // TODO Auto-generated method stub
   return myEntityManager.createStoredProcedureQuery(arg0, arg1);
 }