Chapter 9. Working with objects

You now have an understanding of how Hibernate and ORM solve the static aspects of the object/relational mismatch. With what you know so far, it's possible to solve the structural mismatch problem, but an efficient solution to the problem requires something more. You must investigate strategies for runtime data access, because they're crucial to the performance of your applications. You basically have learn how to control the state of objects.

This and the following chapters cover the behavioral aspect of the object/relational mismatch. We consider these problems to be at least as important as the structural problems discussed in previous chapters. In our experience, many developers are only really aware of the structural mismatch and rarely pay attention to the more dynamic behavioral aspects of the mismatch.

In this chapter, we discuss the lifecycle of objects—how an object becomes persistent, and how it stops being considered persistent—and the method calls and other actions that trigger these transitions. The Hibernate persistence manager, the Session, is responsible for managing object state, so we discuss how to use this important API. The main Java Persistence interface in EJB 3.0 is called EntityManager, and thanks to its close resemblance with Hibernate APIs, it will be easy to learn alongside. Of course, you can skip quickly through this material if you aren't working with Java Persistence or EJB 3.0—we encourage you to read about both options and then decide what is better for your application.

Let's start with persistent objects, their lifecycle, and the events which trigger a change of persistent state. Although some of the material may be formal, a solid understanding of the persistence lifecycle is essential.

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

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