13.5. Summary

In this chapter, you created a global fetch plan and defined which objects and collections should be loaded into memory at all times. You defined the fetch plan based on your use cases and how you want to access associated entities and iterate through collections in your application.

Next, you selected the right fetching strategy for your fetch plan. Your goal is to minimize the number of SQL statements and the complexity of each SQL statement that must be executed. You especially want to avoid the n+1 selects and Cartesian product issues we examined in detail, using various optimization strategies.

The second half of this chapter introduced caching with the theory behind caching and a checklist you can apply to find out which classes and collections are good candidates for Hibernate's optional second-level cache. You then configured and enabled second-level caching for a few classes and collections with the local EHCache provider, and a cluster-enabled JBoss Cache.

Table 13.2 shows a summary you can use to compare native Hibernate features and Java Persistence.

Table 13-2. Hibernate and JPA comparison chart for chapter 13
Hibernate CoreJava Persistence and EJB 3.0
Hibernate supports fetch-plan definition with lazy loading through proxies or based on interception.Hibernate implements a Java Persistence provider with proxy or interception-based lazy loading.
Hibernate allows fine-grained control over fetch-plan and fetching strategies.Java Persistence standardizes annotations for fetch plan declaration, Hibernate extensions are used for fine-grained fetching strategy optimization.
Hibernate provides an optional second-level class and collection data cache, configured in a Hibernate configuration file or XML mapping files.Use Hibernate annotations for declaration of the cache concurrency strategy on entities and collections.

The next chapters deal exclusively with querying and how to write and execute HQL, JPA QL, SQL, and Criteria queries with all Hibernate and Java Persistence interfaces.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.57.251