
Learn to use Spring Data JPA with Hibernate in Spring Boot apps, covering CRUD, derived queries, pagination, auditing, transactions, locking, mapping concepts, and repository inheritance, with hands-on labs.
Explore how Spring Data JPA simplifies the persistence layer, reduces boilerplate, and provides ready-to-use repositories with dynamic proxies for entities like student.
Persist a student entity with Spring Data JPA by building a Spring Boot project, configuring an in-memory H2 database, and using a repository to save the entity.
Understand how the save method persists a student using the entity manager's persist to convert a transient object with a null id into a persistent state. Return the persisted object.
Update a student entity with Spring Data JPA by using the save method; first persist inserts the object, then merge updates the database after loading the persisted state.
Explore updating an entity in Spring Data JPA as you create and persist a student, then determine the outcomes of lines 22 and 26 by selecting the correct option.
Discover how to find an entity by id using the find by id method, persist a student, and handle the optional result to retrieve and print the student.
Persist a student, then delete, which uses find to verify existence before removal; learn delete by id and exists by id for safe, conditional deletions.
Test CRUD operations for a student entity using a Spring Boot test and a student repository. Validate create, read, update, and delete flows in the persistence layer.
Explore Spring Data Commons and its repository hierarchy, including JPA, CRUD, paging and sorting repositories, and how Spring Data JPA and MongoDB share a common data access model.
Learn how to create a custom spring data repository by extending the repository interface to combine crud, jpa, and paging and sorting methods, with runtime proxy generation.
Discover derived queries in spring data by deriving methods from names like find by enrollment ID and name, then extend with like, starting with, and annotation-driven or named queries.
Explore how Spring Data JPA prioritizes three query options—SQL via the query annotation, a named query, and a derived query—with the annotation taking precedence.
Learn basic derived queries in Spring Data JPA by using repository keywords such as find by and order by to filter and sort user data.
Write derived queries in Spring Data JPA to order users by level descending, return first two and top user, and filter by first level or inactive or email containing else.
Learn to paginate results with Spring Data by using the Pageable interface and PageRequest to fetch pages of users, and sort by level, registration date, and username.
This lab teaches pageable query methods in a user repository to find users by level, sorted by registration date ascending, and discusses page, slice, and unpaged or unsorted options.
Explore query by example (QBE) by using a probe entity and an example matcher to find matching users; learn how ignore paths and string matching influence results.
Apply query by example (QBE) in Spring Data JPA Fundamentals (with Hibernate) to find matching users. Use an example on the users table and determine the line 31 result.
Enable Spring Data JPA auditing to track creation and modification times and users who created or modified entities, using created date, last modified date, created by, and last modified by.
Explore how Spring's transactional annotation wraps service methods in a transaction, ensuring atomic, consistent, isolated, and durable operations. See a ticket booking example illustrating commit versus rollback and data integrity.
Learn how to delay database connection acquisition in a Spring Boot application using a connection pool, enabling Hibernate to obtain a connection just before the first database operation.
Explore how read-write and read-only transactions differ in spring data jpa, focusing on automatic dirty checking, persistence context management, and the impact on updates to entity fields like salary.
Learn how Spring transaction propagation works, starting with the default required behavior, and explore supports, not supported, requires new, never, mandatory, and nested rules, with JDBC versus Hibernate considerations.
Explore propagation rules in spring transactional methods through quiz-style questions, examining how existing transactions affect bar method execution versus starting new transactions, with scenarios and seven-option choices.
Explore optimistic locking with versioning to prevent lost updates in a multi-user environment, using a version column and Hibernate's checks to raise optimistic lock exceptions on conflicts.
Use pessimistic locking to ensure data consistency when multiple queries run within a single transaction. It uses a pessimistic read lock, preventing updates until commit, with potential performance trade-offs.
Explore the four standard isolation levels—serializable, repeatable read, read committed, and read uncommitted—and learn how to control transaction behavior with Spring's transactional annotation to maintain data integrity and accurate reports.
Explore how read committed isolation affects a salary update by loading a guide and applying a new salary, and note it prevents dirty reads but not repeatable or phantom reads.
Use the modifying annotation with the query annotation to perform updates or deletes within a transaction. Bulk deletions run directly on the database, bypassing the persistence context and callbacks.
Explore deleting inactive users in bulk with a modifying query, following the find by is active approach, and examine persistence context, post remove callbacks, flush and clear automatically.
demonstrates how to use the versioned keyword with a modifying jpql query in Spring Data JPA and Hibernate to maintain optimistic locking during bulk updates.
Learn to fetch only name and salary data for the first three guides with salary over 2000 using spring data jpa projections and read-only transactions.
Practice using spring data JPA projections to fetch only staff id, name, and salary for the first three guides earning over 2000, via manual query aliasing and derived queries.
Learn to map and call stored procedures from the entity manager in a spring data jpa app, using named stored procedure queries, input and output parameters, and result mapping.
Learn how to call a database stored procedure directly from a service method using an entity manager, registering input and output parameters for simple queries, and compare with named queries.
Call stored procedures with Spring Data JPA's procedure annotation to count employees by department, find department employees, and return name and salary via a projection interface.
Map a uni directional many-to-one relationship between student and guide with a join column and a foreign key, and optimize data access by cascading persist and lazy fetching.
Explore a student-guide many-to-one relation to see that cascade persist updates only the student, while enabling cascade merge also persists the associated guide, and examine lazy loading behavior.
Learn how to implement a bidirectional one-to-many relationship between guide and students in Spring Data JPA, manage ownership with mappedBy, cascade persists, and synchronize both sides with helper methods.
Disassociate all students from a guide by loading the guide, calling a helper to remove students, nullifying their guide references, syncing sides of the one-to-many relationship, and enabling orphan removal.
Explore entity graphs in spring data jpa to eagerly load associated data, such as a guide and its students, without changing mappings, using named and ad hoc graphs.
Learn to use entity subgraphs to eagerly load student hostels when loading guides, without changing lazy mappings, via named graphs and a hostel subgraph.
Explore entity graph loading in Spring Data JPA by comparing EntityGraphType.load and EntityGraphType.fetch, showing how load eagerly fetches students and hostels, while fetch loads only configured paths.
Load a student with its associated guide and hostel data eagerly by using EntityGraphType.LOAD versus EntityGraphType.FETCH, adding guide and hostel to the attribute paths and observing two left outer joins.
Explore bidirectional one-to-one mappings in Spring Data JPA with Hibernate, covering owner vs mappedBy, join column with unique constraint, and lazy fetching for customer and passport.
Analyze why a lazy 1-to-1 mapping in Hibernate may trigger a second select when loading a passport by id, to fetch an existing customer.
Map a bidirectional many-to-many relationship using a join table with foreign keys. Declare the owner with mapped by and synchronize both sides with helper methods to cascade persists.
Explore bi-directional many-to-many relationships between movies and actors, using a join table and a service method, and determine the outcomes of code lines 18–20 through a guided exercise.
Use getReferenceById to add a new student to an existing guide, using a proxy that carries only the id to avoid extra selects and improve performance.
Explores inheritance mapping and polymorphic queries in spring data jpa fundamentals, comparing single table, join, and table-per-class strategies, noting not null constraints and performance.
Explore how the single table inheritance strategy maps a book hierarchy with ebook and paperback subclasses, revealing how non-null constraints and the non-null validation annotation affect persistence.
Explore the mapped superclass annotation, letting subclasses inherit id, title, and isbn without a base table, enabling efficient inserts and reads while preventing polymorphic queries on the mapped base class.
Revise mapped superclass and single-table inheritance in spring data jpa, with abstract base mapped superclass, abstract person entity, and concrete employee and customer with department and membership level attributes.
Explore repository inheritance in a single table inheritance mapping, using a base repository to avoid query duplication and enable polymorphic find by title across book, e-book, and paperback.
Explore repository inheritance in Spring Data JPA by writing a manual query that returns a type by ISBN, handling book, e-book, and paperback via single table inheritance.
Celebrate completing the spring data jpa course and recap the most used features and revisited concepts from the quizzes and lab exercises, while promising more future lectures.
Learn how Spring Data JPA, built on the JPA spec and using Hibernate, uses an entity manager to transition the four states of an entity.
Install and configure MySQL on Windows using the MSI installer, select server-only, set a root password, run the service, and create the Mydb database on port 3306.
Understand how the sequence strategy uses a database sequence to generate primary keys before insert, enabling pre insert identifier generation when persisting and batched inserts on commit.
Persist three students with the sequence strategy and pre-insert generation to see ids generated before insert. Trigger the post-persist callback 'foo' to print ids after insert as the transaction commits.
Explore how the persistence context in Hibernate tracks changes with automatic dirty checking, flushes updates during commit or with explicit flush, and contrasts application managed with container managed entity managers.
The first level cache, via the persistence context and entity manager, caches entities within a transaction; repeatable reads ensure consistent results, and refresh, detach, and clear manage state.
Understand how a proxy serves as an uninitialized placeholder for an entity, retrieved with getReference, and how it initializes only after calling data methods other than its identity getter.
Learn how to undo deletions in spring data jpa with hibernate by using persist to recover a removed entity, and optionally convert to transient with identifier rollback before re-persist.
Learn how the persistence context flushes by default at transaction commit and before queries, using dirty checking, with optional explicit flush via the entity manager, synchronizing changes with the database.
Reinforce core Spring Data JPA concepts with a sequence-generated student id, persisting, finding by id, and executing a SQL query, then committing the transaction and closing the entity manager.
Explore how detached objects behave across persistence contexts, highlighting Java identity versus database identity, and learn why overriding equals and hashCode on your entities prevents duplicates in sets and maps.
Learn to implement hashCode and equals with a business key like enrollment ID or ISBN, avoiding database IDs for transient objects to prevent hash code changes that break sets.
Participate in a lab exercise on equals() and hashCode(), using a staff-id key, to explore how overriding equals without hashCode affects set containment and quiz outcomes.
Explore merging a detached object in Hibernate, moving state to a new persistence context with merge, and leveraging dynamic update to affect only changed columns.
If you’re a Spring/Java programmer who wants to learn the essentials and some of the advanced topics of Spring Data JPA with Hibernate, then you’re the one this course is designed for.
It uses Hibernate as the JPA provider for this course, which is also the default JPA provider of Spring Data JPA. You'll be learning the fundamentals and some of the advanced Spring Data JPA features covering Repositories, Derived Queries, Paging & Sorting, Query-By-Example (QBE), Auditing, Transactions & Concurrency, Modifying Queries, Projections, Mapping Associations and Mapping Inheritance.
It'll be discussing some of the Best Practices and Performance Optimizations as well.
Spring Data JPA provides an abstraction layer built on top of the JPA API specification, so JPA is important for this course, but even if you have just some basic experiences with JPA/Hibernate, you should not find it difficult to complete this course successfully, as it also covers the most essential topics of JPA at the end of the course in Appendix A.
The course also discusses the SQL at runtime every step of the way, and the performance implications of it. There will also be Lab-Exercises and Quizzes throughout the course, to challenge you, and also to help you revise the concepts learnt in the previous sessions.
MySQL and H2 in-memory database are the two RDBMS that the used in the course.