
Arnold guides you through advanced Hibernate features and its Spring integration, tackling concurrency and query optimization with hands-on coding and practical use cases.
Discover the four hibernate entity states, including detached, new, and removed, and how transitions affect real-world use. Examine merge issues with the entity manager, transaction boundaries, and performance implications.
Explore the four entity states in Hibernate: managed, detached, new, and removed, and how dirty checking uses a snapshot to generate updates or deletes at transaction end.
Avoid using merge in Hibernate. Maintain entity state within a transaction, fetch by id, and update stock to prevent extra selects and ensure proper tracking of changes.
Avoid misusing merge for inserts; it may trigger an unnecessary select to check existence, so use the first state transition for inserting data with a single insert statement.
Explore hibernate entity states and transitions, including new and removed states, and learn when to use or avoid the merge operation to optimize transactions and data access.
Experiment with entity transitions in a spring boot gradle project by adjusting the product service or repository to satisfy the tests for attribute updates and minimal query counts.
Examine eagerly loaded and lazy loaded relationships, the SQL these generate, and how fetch joins and related strategies influence Hibernate and JPA queries, prepping for the next module.
The lecture explains eager fetching in a one-to-many relation, showing how loading a parent can fetch children, and warns about performance issues, urging careful use of lazy loading and projections.
Explore lazy loading in Hibernate, showing how the parent is retrieved first and the related products load only when accessed, via runtime proxies and subsequent select statements.
Diagnose lazy initialization exceptions by loading lazily loaded relationships outside a transaction, and explore fixes such as enabling temporary transactions, managing transactions, and rethinking transaction boundaries.
Explore strategies to handle lazy relationships in Hibernate, including initialize, fat joins, and ditto projections, to fetch only needed data and avoid the M plus 1 problem.
Explain the famous N+1 problem, showing how lazy loading causes multiple queries to fetch related products and degrade performance, and set up fed joints as the upcoming solution.
Use fetch joins to solve lazy initialization and the N+1 problem in Hibernate. Compare JPQL and criteria API approaches, and choose when to fetch related data eagerly.
Recap the module by reviewing how to load relationships in hibernate, including eager fetching, lazy loading, and lazy initialization exceptions, plus the AMP +1 problem and fetch joins.
Fix the underlying implementations in the lazy loading practice assignment to make all tests pass in a Spring Boot with H2 project, without changing tests.
Explore projections in Hibernate with Spring, learn what projections are, how to use them in practical and criteria API contexts, and the performance benefits and Spring tooling.
Discover how projections in Hibernate minimize data fetched by loading only id and name, not founder data. Compare plain projections, criteria api, and Spring Data projections.
Use projections in Hibernate with Spring to fetch only needed fields, like title and rating. Reserve entities for updates and writes to maximize performance.
Covering index lets you read only from the index when your projections include the indexed columns, avoiding disk reads and lowering query cost.
The module recap explains how projections limit data in standard sql and criteria api queries, using Spring Data projections. It emphasizes reduced data transfer and memory use, noting covering indices.
In this closing module assignment, modify the product service to fetch only product names using projections, ensuring the query selects just the name field while tests verify the result.
Explore concurrency controls in GPA and hibernate, detect and act on conflicts, compare optimistic looking and pessimistic locking, and prevent conflicts via non-overlapping changes and database-level clocks.
Explains concurrency issues in Hibernate with Spring, highlighting the last update anomaly and stock conflicts, and contrasts optimistic and pessimistic locking and their use.
Demonstrates versioned optimistic locking in hibernate with spring using a version field and @Version; shows how concurrent transactions cause conflicts and how zero rows affected signals a retry.
Explore versionless optimistic locking for non-overlapping changes in Hibernate by using dynamic updates and previous attribute value checks to allow concurrent edits on separate fields.
Describe explicit optimistic locking in Hibernate, using lock mode and lock calls to enforce a version check and optional version increment. Compare normal optimistic lock with optimistic force increment.
Explore pessimistic locking, using shared read locks and exclusive write locks to prevent conflicts, with for update and for share, held until transaction end.
Recap key concurrency strategies in Hibernate with Spring, including optimistic and pessimistic locking. Examine last update anomalies, version-based and version-less optimistic locking, and parameters of pessimistic locks.
Lead the assignment on concurrency control by refactoring an entity to prevent versioned and distinct-attribute optimistic locking conflicts in a cloneable test project.
Explain flushing in Hibernate with Spring, define what flushing is, compare auto and commit flush modes, and examine Hibernate's always and manual flush modes.
Explore how flushing propagates in Hibernate with Spring, collecting changes in the persistence context and sending sql statements to the database at commit or explicit flush.
Understand how auto mode flushes pending changes before queries and before committing transactions. In comet mode, changes flush only before commit, and native queries may run without an earlier flush.
Learn to access the underlying Hibernate API via the entity manager to configure hybrid flush modes—always flush mode, which flushes before every query, and manual flush mode, which you trigger.
Learn how flushing propagates changes from the entity manager to the database when you persist or remove entities, and compare automatic, always, and manual flush modes and their trigger rules.
Discover how statement batching and statement matching optimize Hibernate performance, explore native driver level optimizations, and configure batching for transactional workloads, versioning, and large-scale entity persistence.
Learn how JDBC level statement batching lets you insert multiple rows with a single statement using prepared statements and batch execution, including batch size, parameter setting, and native JDBC tips.
Explore Hibernate 5.2 statement batching with a global batch size in Spring, and see how flush affects batch composition and the importance of correct batching configuration.
Configure transaction-level batching and global batch size, then manage versioned entities, patching, and statement ordering with flush and clear to optimize large-scale Hibernate operations.
Review the module recap on statement batching in SQL for Hibernate, covering GDC driver use, state matching, and configuring batch sizes and transaction level; emphasize measuring and testing before production.
Implement and verify Hibernate with Spring by updating the product service and Spring properties to satisfy tests for insert, transactional, updated, ordering, and versioned Beijing scenarios.
Thank you for joining the course, invite feedback, and encourage completing assignments to gain practical experience, while staying connected through Udemy Q&A, Twitter, Facebook, and the instructor blog for updates.
There are several courses out there targeting basic Hibernate use-cases. This course is different. The goal is to bridge the gap of the basics and the complicated features of the framework.
During the recent years, the IT industry has moved so fast that it's really hard to keep track of it, and I with all the more and more complicated products to be developed, it's critical to understand more advanced features of Hibernate and JPA to be able to support these asks from a development standpoint.
Spring is one of the most frequent framework that is used within the IT industry. I amm going to take this learning experience even further by connecting the dots between Hibernate and Spring, focusing on specific and complex use-cases.
In the course the following topics will be covered:
Entity-state transition pitfalls with merging
The performance aspect of lazy loading data
DTO projections and the positive performance impact
Using covering indices with Hibernate
Flushing fine-tuning
Concurrency-control in depth
Statement batching in detail with optimizations
This is a course tailored specifically for you in order to improve your skills and move your career forward as a professional engineer.
Note that the course does not cover the basics of JPA and Hibernate but assumes that the foundation is already there.
The training also includes a number of practices after almost each section which you can use to polish your skills, and to make sure you understood the specific block.