Now through Nov. 30, save 40-55% on books & eBooks. Use code BOOKSGIVING during checkout. Shop now.
A hands-on practical guide to the now most popular object/relational mapping solution for Java.
° Over 333,000 downloads of Hibernate so far (avg 23,000 a month in 2004)
° Teaches pratical solutions with real-life case studies and provides guidance and best practices for developers
° Complete coverage on how to work with other open source tools such as Ant
Hibernate is a popular open source object/relational persistence and querysystem and an alternative to Enterprise Java Beans. Compared to EJB,Hibernate is less complex, more easily portable and more powerful for linkingJava with traditional relational databases. Hibernate supports many relationaldatabases including: DB2, Informix, MySQL, Oracle, SAP DB, SQL Server,Sybase, and is downloaded over 23,000 times a month on average in 2004. Thisbook provides J2EE developers with a pratical hands-on guide to working withHibernate and their existing databases. Through numerous code examples andcase studies, the author helps reinforce what Hibernate is and how to use it.
Why Object/Relational Mapping?
What Is Hibernate?
Comparing JDBC to Hibernate.
Hibernate's Mapping System.
Other Java/Database Integration Solutions.
Enterprise JavaBeans (EJB) 2.X.
Enterprise JavaBeans (EJB) 3.0.
Java Data Objects (JDO).
Other Commercial O/R Tools.
How to Obtain and Install.
Hibernate Extensions Distribution.
Introduction to MySQL.
2. Getting Oriented.
Mapping Files in Depth.
Generating Java Source.
Generated Persistent Classes.
Generated Database Schema.
3. Starting from Java.
Java Object Model.
Working with Xdoclet.
Generated Mapping Files.
Working with Artifacts and Owners.
4. Starting from an Existing Schema.
Generated Mapping Files.
Working with the Database.
5. Mapping Files.
Mapping File Reference.
6. Persistent Objects.
Setting up the Configuration.
Obtaining the Session.
Objects and Identity.
What Is Identity?
Identity within a Session.
Generating Identity (Primary Keys).
Built-In Hibernate Generators.
Java Collection Relationships.
Java Class Relationships.
Using Hibern8 IDE.
Selected Properties List.
Easily Override Lazy Settings.
Native SQL Queries.
Introduction to Transactions.
Sessions, Transactions, and Flushing.
Optimistic and Pessimistic Locking.
Finding and Solving Problems.
Configuring a Cache.
Using a Custom Cache.
11. Schema Management.
Updating an Existing Schema.
Schema Updates from within an Application.
Command Line Schema Updates.
Ant Task Schema Updates.
Generating Update and Drop Scripts.
Command-Line Script Generation.
Ant Task Script Generation.
Generating Multiple Scripts.
12. Best Practices, Style Guide, Tips and Tricks.
Reducing Code with Inversion of Control.
Reducing Session Creation Impact with ThreadLocal.
Using Hibernate as an EJB BMP Solution.
Integrating with Other Technologies.
Applications That Use Hibernate.
Strategies for Getting Started.
Where to Start?
Start with Many-to-One and One-to-Many.
Profile Database Fetching.
13. Future Directions.
Here and Now.
Simply put, Hibernate solves all of these problems for me, and it does so in a fast, flexible manner. I can use it with Swing, JSP, or as an EJB BMP solution. I can test my code outside of a container. I can even use it to manage my database schema.
Regardless of your backgroundwhether you are a nothing-but-JDBC developer or a full EJB-level architectyou can save yourself considerable time and effort by adding Hibernate to your skill set, and in the process you can get a significant leg up on learning EJB 3.0. You can learn the principal terminology and concepts behind EJB 3.0 today, on the Java 2 (JDK 1.4) JVM you are using now.
Life is short. Spend less time writing code that bridges your database and your Java application and more time adding new features.Required Skills Familiarity with Java development, including object-oriented design. If you don't already know Java, this book will be quite unhelpful.
Familiarity with SQL and relational databases. There are many books on both the practical and theoretical sides of relational database design and development. The examples in this book are all done with MySQL, a free, open-source database. If you have never worked with a relational database before, you will almost certainly want to pick up an introductory text on MySQL.
Familiarity with Ant. Many books on Ant are available; if you are a Java developer and haven't already worked with Ant, you should learn.
Other skills, such as familiarity with JSP web application development, are helpful but not required. One example in Chapter 2 assumes the use of a web server such as Tomcatall other examples can be run from the command-line.Roadmap This book can be loosely broken into a few basic sections. Following the introductory chapter, Chapters 2 through 4 illustrate different approaches to Hibernate development: starting from a Hibernate object/relational mapping file, starting from Java code, or starting from an existing database schema. Chapters 5 through 12 cover basic concepts and the use of persistent objects, concluding with chapters on tools, performance, and best practices. Chapter 13 discusses the future of Hibernate.
This book can be read in several ways, depending on your inclination. If you wish to start with real-world examples and then move into general usage and theory, you can more or less read the book in order. If you prefer a higher-level introduction, you may wish to start with Chapters 6 through 9 and then return to the beginning. Regardless of the method you choose, I encourage you to download and work through the examples from http://www.cascadetg.com/hibernate/.
Chapter 1 introduces Hibernate. It compares Hibernate to other forms of database access, including JDBC and a variety of other tools. It concludes with a list of required files and where to obtain them.
Chapter 2 illustrates an example of development starting with a Hibernate mapping file. The mapping file is used to generate Java and database schema files.
Chapter 3 shows how to use Hibernate when starting from a Java source file. XDoclet is used to generate the mapping file, and Hibernate is used to generate the database schema.
Chapter 4 shows how to use Middlegen in conjunction with Hibernate when starting from an existing database schema.
Chapter 5 is a reference to the Hibernate mapping file format. While few readers will want to read this chapter from start to finish, this reference will hopefully prove invaluable on a day-to-day basis when using Hibernate.
Chapter 6 contains information on the general use of Hibernate, including basic operations such as creating, finding, refreshing, updating, and deleting objects.
Chapter 7 explains how Hibernate handles both class and database relationship concepts.
Chapter 8 discusses Hibernate's two main query mechanisms, HQL and Criteria, and also shows how native SQL can be integrated.
Chapter 9 covers the various aspects of a Hibernate transaction, illustrating both session and database transaction concepts.
Chapter 10 shows tools for identifying potential Hibernate performance issues.
Chapter 11 discusses how Hibernate can be used to manage an application's schema.
Chapter 12 covers various Hibernate best practices.
Chapter 13 discusses future directions for Hibernate, and also covers potential similarities with EJB 3.0.
Download the Index
file related to this title.