Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
  2. public Status newTransactionTest() {
  3. logger.info("newTransactionTest() INNER");
  4. Company company = companyDAO.findOne(10000013);
  5. company.setName(company.getName() + "X");
  6.  
  7. return Status.OK;
  8. }
  9.  
  10. @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
  11. public Status test() {
  12. logger.info("test() BEFORE");
  13. Company company1 = companyDAO.findOne(10000013);
  14. String before = company1.getName();
  15.  
  16. // run in a new transaction
  17. applicationContext.getBean(beanName, AdminService.class).newTransactionTest();
  18.  
  19. logger.info("test() AFTER");
  20. Company company2 = companyDAO.findOne(10000013);
  21. String after = company2.getName();
  22.  
  23. logger.info("COMPANY NAME BEFORE: " + before);
  24.  
  25. logger.info("COMPANY NAME AFTER: " + after);
  26.  
  27. return Status.OK;
  28. }
  29.  
  30. test() BEFORE
  31. connection: 122 select company0_.name as name7_4_0_ ... where company0_.id=5000062
  32. newTransactionTest() INNER
  33. connection: 123 select company0_.name as name7_4_0_ ... where company0_.id=5000062
  34. connection: 123 update Company set name='TestorexX' where id=5000062
  35. connection: 123 commit
  36. test() AFTER
  37. connection: 122 select company0_.name as name7_4_0_ ... where company0_.id=5000062
  38. COMPANY NAME BEFORE: Testorex
  39. COMPANY NAME AFTER: Testorex
  40.  
  41. SHOW VARIABLES WHERE Variable_name ='tx_isolation'
  42.  
  43. <property name="hibernate.connection.isolation">2</property>
  44.  
  45. 1: READ UNCOMMITTED
  46. 2: READ COMMITTED
  47. 4: REPEATABLE READ
  48. 8: SERIALIZABLE
  49.  
  50. SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement