Persisting an object using JPA
Up to this point, we configured and used the persistence layer to connect and retrieve information from the database but have not tried to store data into it. This is a pretty straightforward procedure that involves the Entity Manager component—the same one we used in Chapter 3, Java EE Basics – Persistence, Query, and Presentation,—to read data from MySQL, and also a transaction, which is something we haven't seen yet.
The concept is pretty widespread nowadays, so there's no need to have painstaking explanations here but just a quick refresher. We use transactions to coordinate efforts on disparate resources—which obviously must support it—so we have a consistent unit of work. The ACID concept (atomicity, consistency, ...
Get Getting Started with Oracle WebLogic Server 12c: Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.