SHARE
TWEET

Untitled

a guest May 19th, 2017 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. switch(Transaction.instance().getStatus()) {                   
  2.     case Status.STATUS_COMMITTED:
  3.         log.info("transaction committed");
  4.     break;
  5.     case Status.STATUS_ACTIVE:
  6.         log.info("transaction active");
  7.     break;
  8.     case Status.STATUS_COMMITTING:
  9.         log.info("transaction committing");
  10.     break;
  11.     case Status.STATUS_MARKED_ROLLBACK:
  12.         log.info("transaction marked rollback");
  13.     break;
  14.     case Status.STATUS_NO_TRANSACTION:
  15.         log.info("transaction no transaction");
  16.     break;
  17.     case Status.STATUS_PREPARED:
  18.     log.info("transaction prepared");
  19.         break;
  20.     case Status.STATUS_PREPARING:
  21.     log.info("transaction preparing");
  22.     break;
  23.     case Status.STATUS_ROLLEDBACK:
  24.     log.info("transaction rolledback");
  25.     break;
  26.     case Status.STATUS_ROLLING_BACK:
  27.         log.info("transaction rolling back");
  28.     break;
  29.     case Status.STATUS_UNKNOWN:
  30.         log.info("transaction status unknown");
  31.     break;
  32.     default:
  33.         log.error("transaction in other status: #0", Transaction.instance().getStatus());
  34.     break;
  35. }
  36.                    
  37. Transaction.instance().begin();
  38.                    
  39. if(!Transaction.instance().isActive()) {
  40.     log.error("Transaction not active after Transaction.instance().begin()");
  41. } else {
  42.     log.info("Transaction is active after Transaction.instance().begin()");
  43. }
  44.  
  45. try {
  46.     Query q = entityManager.createNamedQuery("programProcessor.markTriplesForRoundById");
  47.     q.setParameter("round", round);
  48.     q.setParameter("tripleIds", ids);
  49.     modified = q.executeUpdate();
  50.     log.info("XXXXXXX setRound() transaction commit");
  51.     Transaction.instance().commit();
  52. } catch(IllegalStateException e) {
  53.     log.info("XXXXXXX setRound() transaction rollback");
  54.     Transaction.instance().rollback();
  55.     e.printStackTrace();
  56. } catch(TransactionRequiredException e) {
  57.     log.info("XXXXXXX setRound() transaction rollback");
  58.     Transaction.instance().rollback();
  59.     e.printStackTrace();
  60. }
RAW Paste Data
Want to get better at Java?
Learn to code Java in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top