/**
  * トランザクションをコミットまたはロールバックします。
  *
  * <p>現在のスレッドに関連づけられているトランザクションがアクティブな場合は、 トランザクションをコミットします。 それ以外の場合はトランザクションをロールバックします。
  *
  * @throws Exception トランザクションマネージャで例外が発生した場合にスローされます
  * @see javax.transaction.TransactionManager#commit()
  * @see javax.transaction.TransactionManager#rollback()
  */
 protected void end() throws Exception {
   if (userTransaction.getStatus() == STATUS_ACTIVE) {
     userTransaction.commit();
   } else {
     userTransaction.rollback();
   }
 }
  public void testLoggingAutoActivate() throws Throwable {
    assertFalse(
        "Auto-logging of misuse of the wrapper should be off",
        BorrowedConnectionProxy.isCallStackTraced());

    UserTransaction txn = transactionService.getUserTransaction();
    Connection connection;
    try {
      txn.begin();
      // Dig the proxy out of ... somewhere
      ConnectionHolder conHolder =
          (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
      connection = conHolder.getConnection();
      txn.commit();
    } catch (Throwable e) {
      try {
        txn.rollback();
      } catch (Throwable ee) {
      }
      throw e;
    }
    // Now mess with the connection, which is protected by the Hibernate wrapper
    try {
      connection.commit();
      fail("Use case should have generated a HibernateException");
    } catch (HibernateException e) {
      // Expected
    }
    assertTrue(
        "Auto-logging of misuse of the wrapper should now be on",
        BorrowedConnectionProxy.isCallStackTraced());

    // Now start a new transaction and we should see logging
    txn = transactionService.getUserTransaction();
    try {
      txn.begin();
      // Dig the proxy out of ... somewhere
      ConnectionHolder conHolder =
          (ConnectionHolder) TransactionSynchronizationManager.getResource(dataSource);
      connection = conHolder.getConnection();
      txn.commit();
    } catch (Throwable e) {
      try {
        txn.rollback();
      } catch (Throwable ee) {
      }
      throw e;
    }
    // Now mess with the connection, which is protected by the Hibernate wrapper
    try {
      connection.commit();
      fail("Use case should have generated a HibernateException");
    } catch (HibernateException e) {
      // Expected
    }
    // Check for error logs
  }
  public void edit(TipoComparacion tipoComparacion)
      throws NonexistentEntityException, RollbackFailureException, Exception {
    EntityManager em = null;
    try {
      utx.begin();
      em = getEntityManager();

      tipoComparacion = em.merge(tipoComparacion);

      utx.commit();
    } catch (Exception ex) {
      try {
        utx.rollback();
      } catch (Exception re) {
        throw new RollbackFailureException(
            "An error occurred attempting to roll back the transaction.", re);
      }
      String msg = ex.getLocalizedMessage();
      if (msg == null || msg.length() == 0) {
        String id = tipoComparacion.getIdComparador();
        if (findTipoComparacion(id) == null) {
          throw new NonexistentEntityException(
              "The tipoComparacion with id " + id + " no longer exists.");
        }
      }
      throw ex;
    } finally {
      if (em != null) {
        em.close();
      }
    }
  }
Exemplo n.º 4
0
 public String guardarCargaFamiliar(GthCargasFamiliares carga) {
   EntityManager manejador = fabrica.createEntityManager();
   try {
     utx.begin();
     manejador.joinTransaction();
     // Guarda o modifica
     if (carga.getIdeGtcaf() == null) {
       long idegtcaf =
           new Long(utilitario.getConexion().getMaximo("GTH_CARGAS_FAMILIARES", "IDE_GTCAF", 1));
       Integer conertideaspvh = (int) idegtcaf;
       carga.setIdeGtcaf(conertideaspvh);
       manejador.persist(carga);
     } else {
       manejador.merge(carga);
     }
     utx.commit();
   } catch (Exception e) {
     try {
       utx.rollback();
     } catch (Exception e1) {
     }
     return e.getMessage();
   } finally {
     manejador.close();
   }
   return "";
 }
Exemplo n.º 5
0
  public String guardarTelefono(GthTelefono telefono) {
    EntityManager manejador = fabrica.createEntityManager();
    try {
      utx.begin();
      if (telefono.getIdeGttel() == null) {
        // asignar maximo

        long ideaspvh =
            new Long(utilitario.getConexion().getMaximo("GTH_TELEFONO", "IDE_GTTEL", 1));
        System.out.println("guardar telefono " + ideaspvh);
        Integer conertideaspvh = 1; // (int) ideaspvh;
        telefono.setIdeGttel(conertideaspvh); // maximo de utilitario
        System.out.println("telefono " + telefono);
        manejador.persist(telefono);
      } else {
        manejador.merge(telefono);
      }
      utx.commit();
    } catch (Exception e) {
      try {
        utx.rollback();
      } catch (Exception e1) {
      }
      return e.getMessage();
    } finally {
      manejador.close();
    }
    return "";
  }
 public void destroy(BitacoraId id)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     Bitacora bitacora;
     try {
       bitacora = em.getReference(Bitacora.class, id);
       bitacora.getId();
     } catch (EntityNotFoundException enfe) {
       throw new NonexistentEntityException(
           "The bitacora with id " + id + " no longer exists.", enfe);
     }
     em.remove(bitacora);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
 public void create(Bitacora bitacora)
     throws PreexistingEntityException, RollbackFailureException, Exception {
   if (bitacora.getId() == null) {
     bitacora.setId(new BitacoraId());
   }
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     em.persist(bitacora);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     if (findBitacora(bitacora.getId()) != null) {
       throw new PreexistingEntityException("Bitacora " + bitacora + " already exists.", ex);
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
Exemplo n.º 8
0
  @Test
  @InSequence(1)
  @Ignore
  public void testTransactionRollback() throws Throwable {
    userTx.begin();

    HazelcastConnection c = getConnection();
    try {
      TransactionalMap<String, String> m = c.getTransactionalMap("testTransactionRollback");
      m.put("key", "value");
      assertEquals("value", m.get("key"));
      doSql();
    } finally {
      c.close();
    }

    userTx.rollback();

    HazelcastConnection con2 = getConnection();

    try {
      assertEquals(null, con2.getMap("testTransactionRollback").get("key"));
      validateSQLdata(false);
    } finally {
      con2.close();
    }
  }
 public void edit(IsCssEnquiry isCssEnquiry)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     isCssEnquiry = em.merge(isCssEnquiry);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     String msg = ex.getLocalizedMessage();
     if (msg == null || msg.length() == 0) {
       IsCssEnquiryPK id = isCssEnquiry.getIsCssEnquiryPK();
       if (findIsCssEnquiry(id) == null) {
         throw new NonexistentEntityException(
             "The isCssEnquiry with id " + id + " no longer exists.");
       }
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
 public void create(IsCssEnquiry isCssEnquiry)
     throws PreexistingEntityException, RollbackFailureException, Exception {
   if (isCssEnquiry.getIsCssEnquiryPK() == null) {
     isCssEnquiry.setIsCssEnquiryPK(new IsCssEnquiryPK());
   }
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     em.persist(isCssEnquiry);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     if (findIsCssEnquiry(isCssEnquiry.getIsCssEnquiryPK()) != null) {
       throw new PreexistingEntityException(
           "IsCssEnquiry " + isCssEnquiry + " already exists.", ex);
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
  /**
   * Removes a SchoolClassMember(placement) and its attached ResourceClassMembers (resource
   * placements)
   *
   * @param schoolClassMemberPK
   */
  public void removeSchoolClassMember(Integer schoolClassMemberPK) {
    UserTransaction trans = null;
    try {
      trans = getSessionContext().getUserTransaction();
      trans.begin();

      SchoolClassMember schClMember =
          getSchoolClassMemberHome().findByPrimaryKey(schoolClassMemberPK);
      ResourceClassMemberHome rcmHome =
          (ResourceClassMemberHome) IDOLookup.getHome(ResourceClassMember.class);
      // Remove resource placements
      Collection rscPlacements = rcmHome.findAllByClassMemberId(schoolClassMemberPK);
      for (Iterator iter = rscPlacements.iterator(); iter.hasNext(); ) {
        ResourceClassMember element = (ResourceClassMember) iter.next();
        element.remove();
      }

      // Remove placement
      schClMember.remove();

      trans.commit();
    } catch (Exception e) {
      try {
        trans.rollback();
      } catch (IllegalStateException e1) {
        log(e1);
      } catch (SecurityException e1) {
        log(e1);
      } catch (SystemException e1) {
        log(e1);
      }
    }
  }
 public void destroy(Integer id)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     Usuario usuario;
     try {
       usuario = em.getReference(Usuario.class, id);
       usuario.getIdusuario();
     } catch (EntityNotFoundException enfe) {
       throw new NonexistentEntityException(
           "The usuario with id " + id + " no longer exists.", enfe);
     }
     em.remove(usuario);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
 public void edit(Usuario usuario)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     usuario = em.merge(usuario);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     String msg = ex.getLocalizedMessage();
     if (msg == null || msg.length() == 0) {
       Integer id = usuario.getIdusuario();
       if (findUsuario(id) == null) {
         throw new NonexistentEntityException("The usuario with id " + id + " no longer exists.");
       }
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
Exemplo n.º 14
0
 public String create() {
   try {
     utx.begin();
   } catch (Exception ex) {
   }
   try {
     Exception transactionException = null;
     getJpaController().create(plataforma);
     try {
       utx.commit();
     } catch (javax.transaction.RollbackException ex) {
       transactionException = ex;
     } catch (Exception ex) {
     }
     if (transactionException == null) {
       JsfUtil.addSuccessMessage("Plataforma was successfully created.");
     } else {
       JsfUtil.ensureAddErrorMessage(transactionException, "A persistence error occurred.");
     }
   } catch (Exception e) {
     try {
       utx.rollback();
     } catch (Exception ex) {
     }
     JsfUtil.ensureAddErrorMessage(e, "A persistence error occurred.");
     return null;
   }
   return listSetup();
 }
Exemplo n.º 15
0
 public String remove() {
   String idAsString = JsfUtil.getRequestParameter("jsfcrud.currentPlataforma");
   java.math.BigDecimal id = new java.math.BigDecimal(idAsString);
   try {
     utx.begin();
   } catch (Exception ex) {
   }
   try {
     Exception transactionException = null;
     getJpaController().remove(getJpaController().find(id));
     try {
       utx.commit();
     } catch (javax.transaction.RollbackException ex) {
       transactionException = ex;
     } catch (Exception ex) {
     }
     if (transactionException == null) {
       JsfUtil.addSuccessMessage("Plataforma was successfully deleted.");
     } else {
       JsfUtil.ensureAddErrorMessage(transactionException, "A persistence error occurred.");
     }
   } catch (Exception e) {
     try {
       utx.rollback();
     } catch (Exception ex) {
     }
     JsfUtil.ensureAddErrorMessage(e, "A persistence error occurred.");
     return null;
   }
   return relatedOrListOutcome();
 }
 public void destroy(IsCssEnquiryPK id)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     IsCssEnquiry isCssEnquiry;
     try {
       isCssEnquiry = em.getReference(IsCssEnquiry.class, id);
       isCssEnquiry.getIsCssEnquiryPK();
     } catch (EntityNotFoundException enfe) {
       throw new NonexistentEntityException(
           "The isCssEnquiry with id " + id + " no longer exists.", enfe);
     }
     em.remove(isCssEnquiry);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
Exemplo n.º 17
0
  /** Test deleting group. */
  @Test
  public void testDeleteGroup() throws Exception {
    System.out.println(">>> Deleting group");
    UserTransaction tx = getUserTransaction();
    try {
      AdminEJBLocal instance = (AdminEJBLocal) getEJBInstance(AdminEJB.class.getSimpleName());
      tx.begin();
      // Get group
      Group group = instance.getGroup(GROUP_ID);
      tx.commit();

      assertNotNull("Failed to get group", group);

      group.setEntityAction(EntityAction.DELETE);

      tx.begin();
      Group deltedGroup = instance.saveGroup(group);
      tx.commit();

      assertNull("Failed to delete group", deltedGroup);

      System.out.println(">>> Group has been deleted!");

    } catch (Exception e) {
      tx.rollback();
      fail(e.getMessage());
    }
  }
  private void testStartProcess(RuntimeEngine runtime) throws Exception {

    synchronized (
        (SingleSessionCommandService)
            ((CommandBasedStatefulKnowledgeSession) runtime.getKieSession()).getRunner()) {
      UserTransaction ut =
          (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
      try {
        ut.begin();
        logger.debug("Starting process on ksession {}", runtime.getKieSession().getIdentifier());
        Map<String, Object> params = new HashMap<String, Object>();
        DateTime now = new DateTime();
        now.plus(1000);

        params.put("x", "R2/" + wait + "/PT1S");
        ProcessInstance processInstance =
            runtime.getKieSession().startProcess("IntermediateCatchEvent", params);
        logger.debug(
            "Started process instance {} on ksession {}",
            processInstance.getId(),
            runtime.getKieSession().getIdentifier());
        ut.commit();
      } catch (Exception ex) {
        ut.rollback();
        throw ex;
      }
    }
  }
Exemplo n.º 19
0
  /** Test deleting user. */
  @Test
  public void testDeleteUser() throws Exception {
    System.out.println(">>> Deleting user");
    UserTransaction tx = getUserTransaction();
    try {
      AdminEJBLocal instance = (AdminEJBLocal) getEJBInstance(AdminEJB.class.getSimpleName());
      tx.begin();
      // Get user
      User user = instance.getUser(USER_NAME);
      tx.commit();

      assertNotNull("Failed to get user", user);

      user.setEntityAction(EntityAction.DELETE);

      tx.begin();
      User deltedUser = instance.saveUser(user);
      tx.commit();

      assertNull("Failed to delete user", deltedUser);

      System.out.println(">>> User has been deleted!");

    } catch (Exception e) {
      tx.rollback();
      fail(e.getMessage());
    }
  }
Exemplo n.º 20
0
  public String guardarConducta(EquivalenciaConducta iconducta) {
    EquivalenciaConducta conducta = iconducta;
    try {
      utx.begin();
      manejador.joinTransaction();
      // nombre tabla y atributo
      if (conducta.getEqcCodigo() == null) {
        long lon_codigo =
            utilitario.getConexion().getMaximo("Equivalencia_conducta", "eqc_codigo", 1);
        conducta.setEqcCodigo(new Integer(String.valueOf(lon_codigo)));
        System.out.println("ide " + lon_codigo);
        conducta.setEqcCodigo(new Integer(String.valueOf(lon_codigo)));
        manejador.persist(conducta);
      } else {
        manejador.merge(conducta);
      }

      utx.commit();
    } catch (Exception e) {
      try {
        utx.rollback();
      } catch (Exception e1) {
      }
      e.printStackTrace();
      return e.getMessage();
    }
    return "";
  }
  public String processRequest(String strActionValue) throws ProcessingException {
    FrameworkDefaultLogger.debug("Inside S_FrameWork_Query_OperationWorkerBean::processRequest().");

    String sReturnValue = null;
    javax.transaction.UserTransaction userTransaction = UserTransactionService.getUserTransaction();

    try {
      userTransaction.begin();
      sReturnValue = callProcessRequest(strActionValue);
      userTransaction.commit();
    } catch (Exception exc) {
      try {
        userTransaction.rollback();
      } catch (Exception ex) {
        sReturnValue = "DATA_VALIDATION_ERROR";
        FrameworkDefaultLogger.error(
            "Inside S_FrameWork_Query_OperationWorkerBean:" + ErrorService.errorStackToString(ex));
      }

      FrameworkDefaultLogger.error(
          "Inside S_FrameWork_Query_OperationWorkerBean:" + ErrorService.errorStackToString(exc));
      throw new ProcessingException(
          "S_FrameWork_Query_OperationWorkerBean:processRequest() - " + exc);
    }

    return sReturnValue;
  }
 public void edit(Bitacora bitacora)
     throws NonexistentEntityException, RollbackFailureException, Exception {
   EntityManager em = null;
   try {
     utx.begin();
     em = getEntityManager();
     bitacora = em.merge(bitacora);
     utx.commit();
   } catch (Exception ex) {
     try {
       utx.rollback();
     } catch (Exception re) {
       throw new RollbackFailureException(
           "An error occurred attempting to roll back the transaction.", re);
     }
     String msg = ex.getLocalizedMessage();
     if (msg == null || msg.length() == 0) {
       BitacoraId id = bitacora.getId();
       if (findBitacora(id) == null) {
         throw new NonexistentEntityException("The bitacora with id " + id + " no longer exists.");
       }
     }
     throw ex;
   } finally {
     if (em != null) {
       em.close();
     }
   }
 }
 public void tearDown() throws Exception {
   try {
     txn.rollback();
   } catch (Throwable e) {
     e.printStackTrace();
   }
 }
  @Override
  public void updateComment(Comment comment)
      throws NonExistingEntityException, IllegalArgumentException {

    if (comment == null) {
      throw new IllegalArgumentException("Comment is null.");
    }

    if (comment.getId() == null) {
      throw new IllegalArgumentException("Comment id is null.");
    }

    commentCache = provider.getCacheContainer().getCache("commentcache");

    if (!commentCache.containsKey(comment.getId())) {
      throw new NonExistingEntityException("Comment does not exist in cache.");
    }

    try {
      userTransaction.begin();
      commentCache.put(comment.getId(), comment);
      userTransaction.commit();
      logger.info("Comment with id: " + comment.getId() + " was updated in cache store.");
    } catch (Exception e) {
      if (userTransaction != null) {
        try {
          userTransaction.rollback();
        } catch (Exception e1) {
          e1.printStackTrace();
        }
      }
      logger.error("Error while updating comment.", e);
      throw new CacheException(e);
    }
  }
  public void create(TipoComparacion tipoComparacion)
      throws PreexistingEntityException, RollbackFailureException, Exception {

    EntityManager em = null;
    try {
      utx.begin();
      em = getEntityManager();
      em.persist(tipoComparacion);
      utx.commit();
    } catch (Exception ex) {
      try {
        utx.rollback();
      } catch (Exception re) {
        throw new RollbackFailureException(
            "An error occurred attempting to roll back the transaction.", re);
      }
      if (findTipoComparacion(tipoComparacion.getIdComparador()) != null) {
        throw new PreexistingEntityException(
            "TipoComparacion " + tipoComparacion + " already exists.", ex);
      }
      throw ex;
    } finally {
      if (em != null) {
        em.close();
      }
    }
  }
Exemplo n.º 26
0
 public String guardarDireccion(GthDireccion direccion) {
   EntityManager manejador = fabrica.createEntityManager();
   try {
     utx.begin();
     manejador.joinTransaction();
     // Guarda o modifica direccion
     if (direccion.getIdeGtdir() == null) {
       long idegtdir =
           new Long(utilitario.getConexion().getMaximo("GTH_DIRECCION", "IDE_GTDIR", 1));
       Integer conertideaspvh = (int) idegtdir;
       direccion.setIdeGtdir(conertideaspvh); // maximo de utilitario
       manejador.persist(direccion);
     } else {
       manejador.merge(direccion);
     }
     utx.commit();
   } catch (Exception e) {
     try {
       utx.rollback();
     } catch (Exception e1) {
     }
     return e.getMessage();
   } finally {
     manejador.close();
   }
   return "";
 }
  public void destroy(String id)
      throws NonexistentEntityException, RollbackFailureException, Exception {
    EntityManager em = null;
    try {
      utx.begin();
      em = getEntityManager();
      TipoComparacion tipoComparacion;
      try {
        tipoComparacion = em.getReference(TipoComparacion.class, id);
        tipoComparacion.getIdComparador();
      } catch (EntityNotFoundException enfe) {
        throw new NonexistentEntityException(
            "The tipoComparacion with id " + id + " no longer exists.", enfe);
      }

      em.remove(tipoComparacion);
      utx.commit();
    } catch (Exception ex) {
      try {
        utx.rollback();
      } catch (Exception re) {
        throw new RollbackFailureException(
            "An error occurred attempting to roll back the transaction.", re);
      }
      throw ex;
    } finally {
      if (em != null) {
        em.close();
      }
    }
  }
  /**
   * Get the stored MD4 hashed password for the user, or null if the user does not exist
   *
   * @param userName String
   * @return MD4 hash or null
   */
  protected String getMD4Hash(String userName) {
    String md4hash = null;

    // Wrap the auth component calls in a transaction
    UserTransaction tx = transactionService.getUserTransaction();
    try {
      tx.begin();

      // Get the stored MD4 hashed password for the user, or null if the user does not exist
      md4hash = nltmAuthenticator.getMD4HashedPassword(userName);
    } catch (Throwable ex) {
      if (getLogger().isDebugEnabled()) getLogger().debug(ex);
    } finally {
      // Rollback/commit the transaction if still valid
      if (tx != null) {
        try {
          // Commit or rollback the transaction
          if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK
              || tx.getStatus() == Status.STATUS_ROLLEDBACK
              || tx.getStatus() == Status.STATUS_ROLLING_BACK) {
            // Transaction is marked for rollback
            tx.rollback();
          } else {
            // Commit the transaction
            tx.commit();
          }
        } catch (Throwable ex) {
          if (getLogger().isDebugEnabled()) getLogger().debug(ex);
        }
      }
    }

    return md4hash;
  }
Exemplo n.º 29
0
  public static void main(String[] args) {
    UserTransaction ut = null;
    try {
      boolean abort = false;
      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      System.setProperty(Context.PROVIDER_URL, "t3://localhost:7001");

      ut = getUserTransaction();
      ut.begin();

      MessagePublisher mp =
          new MessagePublisher("jms/JTATestJMSConnectionFactory", "jms/JTATestJMSQueue", false);
      mp.publishMessage("Hello JMS2");
      mp.publishMessage("Hello again JMS2");

      new AmitkJTADao("jdbc/JTATestDataSource")
          .updateRecord(1, new Date(System.currentTimeMillis()));

      if (abort) throw new Exception("Forcefully aborting transaction");

      ut.commit();

    } catch (Exception e) {
      e.printStackTrace();
      try {
        if (null != ut) ut.rollback();
      } catch (SystemException se) {
        se.printStackTrace();
      } finally {
        ut = null;
      }
    }
  }
Exemplo n.º 30
-1
  public String eliminarConyugue(String ideGtemp) {
    EntityManager manejador = fabrica.createEntityManager();
    try {
      GthConyuge conygue = getConyuque(ideGtemp);
      if (conygue != null) {
        utx.begin();
        manejador.joinTransaction();
        // Borra telefono de conyugue
        List<GthTelefono> telefonos = getListaTelefonoConyugue(conygue.getIdeGtcon().toString());
        if (telefonos != null && !telefonos.isEmpty()) {
          for (GthTelefono telefonoActual : telefonos) {
            manejador.remove(telefonoActual);
          }
        }
        // Borra datos de union
        GthUnionLibre union = getUnionLibre(conygue.getIdeGtcon().toString());
        if (union != null) {
          manejador.remove(union);
        }
        manejador.remove(conygue);
        utx.commit();
      }

    } catch (Exception e) {
      try {
        utx.rollback();
      } catch (Exception e1) {
      }
      return e.getMessage();
    } finally {
      manejador.close();
    }
    return "";
  }