Sunday, 14 April 2019

What’s Transaction Management In Hibernate? How It Works?

Transaction management is the process of managing a set of statements or commands. In hibernate; transaction management is done by transaction interface as shown in below code:

  1. Session s = null;  
  2.   
  3. Transaction tr = null;  
  4.   
  5. try {  
  6.   
  7. s = sessionFactory.openSession();  
  8.   
  9. tr = s.beginTransaction();  
  10.   
  11. doTheAction(s);  
  12.   
  13. tr.commit();  
  14.   
  15. catch (RuntimeException exc) {  
  16.   
  17. tr.rollback();  
  18.   
  19. finally {  
  20.   
  21. s.close();  
  22.   
  23. }  

No comments:

Post a Comment

Spring Boot @ConfigurationProperties and Properties File

 In this tutorial, you will learn to use @ConfigurationProperties to map properties files to POJO classes in Spring Boot application. Let’s ...