About this Book

This book is both a tutorial and a reference for Hibernate and Java Persistence. If you’re new to Hibernate, we suggest that you start reading the book with chapter 1 and begin coding with the “Hello World” tutorial in chapter 2. If you’ve used an older version of Hibernate, you should read the first two chapters quickly to get an overview and then jump into the middle with chapter 3. We will, whenever appropriate, tell you if a particular section or subject is optional or reference material that you can safely skip during your first read.

Roadmap

This book is divided into five major parts.

In part 1, “Getting started with ORM,” we discuss the fundamentals behind object/relational mapping. We walk through a hands-on tutorial to get you started with your first Hibernate project. We look at Java application design for domain models and at the options for creating object/relational mapping metadata.

Part 2, “Mapping strategies,” focuses on Java classes and their properties, and how they map to SQL tables and columns. We explore all basic and advanced mapping options in Hibernate and Java Persistence. We show you how to deal with inheritance, collections, and complex class associations. Finally, we discuss integration with legacy database schemas and some mapping strategies that are especially tricky.

Part 3, “Transactional data processing,” is all about loading and storing data with Hibernate and Java Persistence. We introduce the programming interfaces, how to write transactional applications, and how Hibernate can load data from the database most efficiently.

With part 4, “Writing queries,” we introduce the data query features and cover query languages and APIs in detail. Not all chapters in this part are written in a tutorial style; we expect you’ll browse this part of the book frequently when building an application and looking up a solution for a particular query problem.

In part 5, “Building applications,” we discuss the design and implementation of layered and conversation-aware Java database applications. We discuss the most common design patterns that are used with Hibernate, such as the Data Access Object (DAO). You see how you can test your Hibernate application easily and learn what other best practices are relevant if you work with an object/relational mapping software in web and client/server applications in general.

Who should read this book?

Readers of this book should have basic knowledge of object-oriented software development and should have used this knowledge in practice. To understand the application examples, you should be familiar with the Java programming language and the Unified Modeling Language.

Our primary target audience consists of Java developers who work with SQL-based database systems. We’ll show you how to substantially increase your productivity by using ORM. If you’re a database developer, the book can be part of your introduction to object-oriented software development.

If you’re a database administrator, you’ll be interested in how ORM affects performance and how you can tune the performance of the SQL database-management system and persistence layer to achieve performance targets. Because data access is the bottleneck in most Java applications, this book pays close attention to performance issues. Many DBAs are understandably nervous about entrusting performance to tool-generated SQL code; we seek to allay those fears and also to highlight cases where applications shouldn’t use tool-managed data access. You may be relieved to discover that we don’t claim that ORM is the best solution to every problem.

Code conventions

This book provides copious examples, which include all the Hibernate application artifacts: Java code, Hibernate configuration files, and XML mapping metadata files. Source code in listings or in text is in a fixed-width font like this to separate it from ordinary text. Additionally, Java method names, component parameters, object properties, and XML elements and attributes in text are also presented using fixed-width font.

Java, HTML, and XML can all be verbose. In many cases, the original source code (available online) has been reformatted; we’ve added line breaks and reworked indentation to accommodate the available page space in the book. In rare cases, even this was not enough, and listings include line-continuation markers (). Additionally, comments in the source code have often been removed from the listings when the code is described in the text. Code annotations accompany some of the source code listings, highlighting important concepts. In some cases, numbered bullets link to explanations that follow the listing.

Source code downloads

Hibernate is an open source project released under the Lesser GNU Public License. Directions for downloading Hibernate packages, in source or binary form, are available from the Hibernate website: www.hibernate.org. The source code for all examples in this book is available from http://jpwh.org/. You can also download the code for the examples in this book from the publisher’s website at www.manning.com/books/java-persistence-with-hibernate-second-edition.

Author Online

The purchase of Java Persistence with Hibernate, Second Edition includes free access to a private web forum run by Manning Publications, where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/books/java-persistence-with-hibernate-second-edition. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the authors

CHRISTIAN BAUER is a member of the Hibernate developer team; he works as a trainer and consultant.

GAVIN KING is the founder of the Hibernate project and a member of the original Java Persistence expert group (JSR 220). He also led the standardization effort of CDI (JSR 299). Gavin is currently creating a new programming language called Ceylon.

GARY GREGORY is a principal software engineer at Rocket Software working on application servers and legacy integration. He is the coauthor of Manning’s JUnit in Action and Spring Batch in Action and a member of the Project Management Committees for the Apache Software Foundation projects: Commons, HttpComponents, Logging Services, and Xalan.

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

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