
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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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.
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.