What this book covers
Chapter 1, Entity and Session, covers the internal working of a session and how Hibernate manages entities inside a session. We will also explore the entity life cycle and discuss other topics related to sessions and entities such as stateless sessions, design patterns such as session-per-request, session-per-conversation, batch processing, and proxy objects.
Chapter 2, Advanced Mapping, talks about fundamental mapping concepts and how Hibernate bridges the gap between the object-oriented world and relational database. You will further read discussions on inheritance, and in-memory and in-database value generation. Moreover, the creation of custom mapped data types is also covered. This chapter also demonstrates how to work with collections and offers tips and tricks, and outlines the pitfalls when working with collections. Additionally, it covers batch updates and deletes. Finally, this chapter shows you how to implement object-oriented topics such as inheritance and polymorphism and map them correctly to a relational database.
Chapter 3, Working with Annotations, demonstrates the use of annotations and why and when to use them. Besides the common annotations, it highlights some rare ones, which can be quite useful for most developers. In addition to the common JPA annotations, this chapter also discusses some annotations that are only available in Hibernate.
Chapter 4, Advanced Fetching, shows various fetching strategies and discusses the use of Hibernate and native query languages, criteria objects, filters, and other topics related to data fetch.
Chapter 5, Hibernate Cache, covers various cache structures such as first-level and second-level. Additionally, it explores various cache strategies and how to collect statistics related to caching.
Chapter 6, Events, Interceptors, and Envers, covers events and interceptors in Hibernate and how you can use them to implement a functionality similar to DB triggers and other event-based functions. Furthermore, it covers Entity Auditing (Envers); which implements entity revision management to automatically store historical snapshots of entities and also provides an auditing mechanism.
Chapter 7, Metrics and Statistics, demonstrates how to generate and collect metrics and statistical data within Hibernate. This includes entity, query, collection, and cache statistics. It further shows how to access this data via JMX, that is, Java Management Extensions.
Chapter 8, Addressing Architecture, shows how architectural concerns and constraints are addressed in Hibernate, which includes concurrency and transaction management, scalability, and performance.
Chapter 9, EJB and Spring Context, shows how to correctly create and deploy your application in two popular Java contexts, EJB and Spring.