By Joseph B. Ottinger, Dave Minter, Jeff Linwood (auth.)
Starting Hibernate, 3rd version is perfect if you’re skilled in Java with databases (the conventional, or “connected,” approach), yet new to open-source, light-weight Hibernate, a number one object-relational mapping and database-oriented program improvement framework.
Read or Download Beginning Hibernate: Third Edition PDF
Best nonfiction_12 books
- Lie Groups I, Lie Groups II
- TPE 2011
- High-Precision Studies of Compact Variable Stars
- REACH 2007 : Brussels, Belgium, 17-19 April 2007
Extra resources for Beginning Hibernate: Third Edition
Our second test creates three subjects, each with Skills in “Sk1,” whatever that is. ”) S1 has an average of 7, S2 has an average of 6, and S3 has an average of 8. We should therefore expect S3 as the owner of the best Ranking. We’re throwing in some outlier data just to make sure that our service is limited to the actual data it’s trying to find. Note that we’re not actually returning the Skill’s average! For an actual application, that’s very likely to be a requirement; it could easily be fulfilled by immediately calling getRankingFor(), but as designed that’s a very expensive operation (involving creation of a new Session and a series of database roundtrips).
Removed objects are objects that are being managed by Hibernate (persistent objects, in other words) that have been passed to the session’s remove() method. When the application marks the changes held in the session as to be committed, the entries in the database that correspond to removed objects are deleted. Versions prior to Hibernate 3 had support for the Lifecycle and Validatable interfaces. These allowed your objects to listen for save, update, delete, load, and validate events using methods on the object.
The second validates that we have no data for the subject, populates some data, and then looks for the set of Ranking averages. It then makes sure we have the count of averages we expect, and validates that the Rankings themselves are what we expect. 36 Chapter 3 ■ Building a Simple Application Again, it’s doable to write more complete tests, perhaps, but these tests do validate whether our simple requirements are fulfilled. 8 So let’s look at the code for findAllRankings(). As usual, we’ll have a public method and then an internal method that participates in an existing Session, as shown in Listing 3-24: Listing 3-24.