The Hibernate interfaces contexts and can (Web site designers) even automatically
Friday, March 28th, 2008The Hibernate interfaces contexts and can even automatically store the disconnected context for you (in a stateful EJB session bean) between requests. We ll get back to conversations later in the book and show you all the details about the two implementation strategies. You don t have to choose one right now, but you should be aware of the consequences these strategies have on object state and object identity, and you should understand the necessary transitions in each case. We now explore the persistence manager APIs and how you make the theory behind object states work in practice. 9.3 The Hibernate interfaces Any transparent persistence tool includes a persistence manager API. This persistence manager usually provides services for the following: Basic CRUD (create, retrieve, update, delete) operations Query execution Control of transactions Management of the persistence context The persistence manager may be exposed by several different interfaces. In the case of Hibernate, these are Session, Query, Criteria, and Transaction. Under the covers, the implementations of these interfaces are coupled tightly together. In Java Persistence, the main interface you interact with is the EntityManager; it has the same role as the Hibernate Session. Other Java Persistence interfaces are Query and EntityTransaction (you can probably guess what their counterpart in native Hibernate is). We ll now show you how to load and store objects with Hibernate and Java Persistence. Sometimes both have exactly the same semantics and API, and even the method names are the same. It s therefore much more important to keep your eyes open for little differences. To make this part of the book easier to understand, we decided to use a different strategy than usual and explain Hibernate first and then Java Persistence. Let s start with Hibernate, assuming that you write an application that relies on the native API.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.