
Explore the Java Persistence API with JPA and Hibernate, build a pure JPA app, map entities with annotations, perform CRUD, manage relationships, JPQL, and Spring Boot transactions.
Learn why JPA is essential for enterprise Java apps, offering a standard, easy way to connect to relational databases across Spring Boot, Jakarta EE, and microservices.
Follow along, write code, and build a project to maximize learning, while using Pro JPA 2 and Java Persistence with Hibernate to deepen understanding of JPA and Hibernate.
Explore how JPA enables object-relational mapping to connect a Java app with a relational database. See how annotations map Java objects to tables and handle relationships like addresses and managers.
Understand how JPA is the interface and Hibernate the implementation for Java ORM, mapping classes to tables and persisting data via Hibernate APIs.
Discover how JPA provides a standard API and requires an implementation. Learn to map classes to tables, perform CRUD with JPA APIs, and explore productivity and database independence.
Start a bare bones Java project, add JPA via Maven, configure a local database, map entities, and persist data with JPA—no frameworks, using the H2 database.
Set up the H2 relational database in server mode for a Java ORM project. Install, run, and connect to the H2 server using its browser UI for JPA development.
Set up a maven project in IntelliJ, add jpa and hibernate dependencies with the hibernate entitymanager, plus the h2 driver, then configure the database connection details.
Configure a JPA persistence context with persistence.xml in meta-inf, connect to an H2 database via Hibernate, and map an employee entity with @Entity, @Table, and @Id to persist data.
Create an entity manager factory from your persistence unit, obtain an entity manager, and persist an employee within a transaction to save data via JPA.
Learn how persistence.xml configures a JPA persistence unit, the provider, and connection properties to map entities with Hibernate. Explore how show SQL, dialect, and DDL auto settings control database interactions.
Learn how to map Java entity classes to database tables using JPA/Hibernate annotations, for both creating ideal schemas and aligning with existing tables and columns.
Use @Table to map a class to a table and customize the table name, schema, or catalog. Use @Column to rename, set length, and enforce uniqueness or nullability.
Discover how JPA maps primitive and wrapper types to database columns, including string to varchar, and how @Temporal stores date, time, or timestamp values.
Learn how JPA maps enums, why default ordinal storage can break with edits, and how to store string values with @Enumerated(EnumType.STRING) to avoid data mismatch while deciding a stable strategy.
Explore how to use the @Transient annotation to exclude non-persistent fields from JPA, and why the transient keyword is only for Java and not preferred for JPA purposes.
Learn how the @Id primary key maps a property to a unique, database-generated value, with supported types from int to string, and the trade-offs of sequences, tables, or identity strategies.
Explore hbm2ddl options like create drop, validate, update, create, and none, explaining how they affect schema creation, validation, and updates during the CRUD lifecycle.
Learn to read an entity with JPA using EntityManager.find, fetch an employee by ID, and see that reads don't require a transaction and return null if not found.
Modify a fetched entity and persist it within a transaction to trigger an update in the database, as JPA detects the record by its ID and updates the changed fields.
Delete an entity by locating the target row with a where clause, fetching the entity, and calling entity manager remove within a transaction to perform crud operations.
Create a new access card entity and annotate it as an entity with an auto-generated id, then persist two employees and two access cards while exploring relationship options between them.
Explore modeling a one-to-one relationship between employee and access card in both database and Java with JPA. Map the relationship using foreign keys and one-to-one annotation to enforce referential integrity.
Explore how JPA and Hibernate fetch strategies handle relationships and eager and lazy loading. Learn about left outer joins and fetch type settings affecting performance.
Explore the directionality of one-to-one relationships and the owning side with mappedBy. See bidirectional access between employee and access card and how to avoid redundant fetches.
Demonstrate one to many and many to one by linking pay stubs to employees, using a foreign key in the pay stub table and an owning side design.
Learn to model a reverse one-to-many relationship between employee and pay stubs, using mapped by to indicate the reverse link, with lazy loading by default and optional eager fetching.
Understand bidirectional relationships in JPA and Hibernate, including owning side between pay stub and employee, and why keeping both sides updated matters for consistent reads and reliable persistence.
Learn how to customize foreign key column names in JPA and Hibernate by using the join column annotation on a many-to-one relationship, replacing the default employee_id with a chosen name.
Explore many-to-many relationships with JPA, using a join table to map employees to email groups, and learn bidirectional persistence with mapped by.
Explore how fetch type governs many-to-many relationships in JPA and Hibernate, demonstrating lazy vs eager loading and practical tips to avoid cascading performance hits.
Learn how to customize join tables in JPA and Hibernate by setting the join table name and join columns, including inverse join columns, to control column names.
Learn how to update relationships in JPA by fetching an employee and an email group, updating their subscriptions, and letting Hibernate propagate join-table changes automatically; explore delete implications.
Examine delete behavior in JPA relationships, including referential integrity constraints and when to use cascade remove to delete pay stubs, while preserving subscriptions and access cards.
Explore how the persistence context acts as a first-level cache in Hibernate and JPA, controlling when inserts run and how the entity manager handles persistence and transactions.
Explore the persistence context as a first level cache and how transient and managed states determine when to persist or find and to save or retrieve from the database.
Discover how removing an entity moves it from managed to removed, how persisting can return it to managed, and how flush, detach, and merge govern database updates.
discover how to use entity manager's clear to detach all entities from the persistence context, and refresh to reload a managed entity from the database, discarding local changes.
Explains querying JPA entities with JPQL using the entity manager, including find by id, creating typed queries, and using where and order by clauses.
Discover how JPQL uses the like and between keywords for fuzzy name matching and age ranges, with practical examples of wildcards and translations from SQL.
Learn how to use joins to combine employee and access card data, filter by active cards, and leverage jpql for relationship-based queries in Java ORM.
Learn to craft freeform jpql queries and custom result types, fetching only needed fields such as employee names or ages and using object arrays for multiple fields.
Learn how to prevent SQL injection in JPQL by using named parameters (like :minAge) and setParameter, ensuring type safety and avoiding string concatenation when building queries.
Define and reuse queries with named queries in JPA by annotating the entity, enabling a single centralized JPQL such as select E from employee order by e.name; call via entitymanager.createNamedQuery.
Create a Spring Boot JPA project via Spring Initializr, add Spring Data JPA and H2 dependencies, and see how Spring Boot configures JPA with Hibernate behind the scenes.
Configure spring boot jpa with an h2 database through application.properties, setting url, username, password, driver, dialect, and hbm2ddl, while porting entity classes to use spring boot jpa API.
Configure a spring boot jpa app to connect to the database, inject an entity manager via a persistence unit, and persist an employee on startup using a post construct method.
Inject the entity manager directly via @PersistenceContext to access the persistence context, avoiding the entity manager factory; use the shared entity manager for reads and manage writes with transactions.
Declare a repository for an entity by extending CrudRepository, letting Spring Data JPA provide the implementation and offering built-in CRUD operations like findById, save, and findAll.
Discover declarative transactions in Spring Boot with the transactional annotation to automatically start, commit, and rollback JPA updates, reducing imperative transaction handling.
Coordinate updates to employee and access card in a single transaction, ensuring all-or-nothing behavior. Explore propagation types like required, requires new, and mandatory across JPA and Spring annotations.
Learn how to use read-only transactions in JPA with the @Transaction annotation to safely read multiple entities, avoid race conditions, and gain performance by not blocking unrelated writes.
Recap the essentials of JPA and ORM, including entity mapping, CRUD, relationships, persistence context, and JPQL, and compare plain JPA with Spring Boot repositories and declarative transactions.
Master Java Persistence API (JPA) and Hibernate in this comprehensive course designed for Java developers seeking to excel in enterprise database operations. Through 53 detailed video lessons spanning over 8 hours of content, you'll progress from JPA fundamentals to advanced concepts, learning how to effectively map Java objects to database tables, manage complex entity relationships, and optimize database operations.
Starting with the essentials, you'll learn why JPA has become the standard for Java enterprise development and how it simplifies database operations compared to traditional JDBC. The course takes a practical approach, guiding you through setting up a complete development environment with H2 database, configuring persistence.xml, and establishing database connections. You'll master critical concepts like object-relational mapping (ORM) while building a real-world application that demonstrates employee management systems.
The curriculum deep dives into essential topics that often appear in technical interviews, including:
- Implementation of One-to-One, One-to-Many, and Many-to-Many relationships with practical examples
- Mastery of CRUD operations with proper transaction management
- Advanced entity lifecycle management and persistence context optimization
- Protection against SQL injection using parameterized JPQL queries
- Integration with Spring Boot and leveraging Spring Data repositories
You'll learn industry best practices for performance optimization, including strategic use of fetch types, lazy loading, and read-only transactions. The course includes hands-on exercises and real-world scenarios that will help you understand common pitfalls and their solutions.
The final sections focus on Spring Boot integration, teaching you how to leverage Spring Data JPA repositories and implement declarative transaction management. By the end of this course, you'll be confident in implementing database operations using JPA and Hibernate, understanding performance optimization techniques, and troubleshooting common issues.
Whether you're preparing for technical interviews, working on enterprise applications, or transitioning to Java backend development, this course provides the comprehensive knowledge and practical skills needed to excel in Java persistence programming. Join thousands of developers who have mastered JPA and Hibernate through this structured, hands-on approach to learning.