From the course: Java Persistence API (JPA): 1 The Basics

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Managing transactions overview

Managing transactions overview - Java Tutorial

From the course: Java Persistence API (JPA): 1 The Basics

Start my 1-month free trial

Managing transactions overview

- [Instructor] Have you notice that you don't have to explicitly write commits or roll-backs? Transactions are handled automatically thanks to the Java Transaction API. Or JTA for short. The container manages everything for us. Let's uncover how this is possible. Let's look at managing transactions using the Java transaction API, and the @Transactional annotation. Transactions help keep data in a consistent state. Allowing you to group several operations as a single unit, that will all either succeed or fail together as a group. In this example, using the entity transaction from the entity manager. The developer has to programmatically manage the transaction. But there is an easier way, using the Java transaction API. JTA is a general API for managing transactions in Java. It allows you to start, commit, and roll-back transactions seamlessly. This is because the entity manager cooperates with the JTA transaction manager transparently for us. We don't need to programmatically manage…

Contents