Nicht aus der Schweiz? Besuchen Sie lehmanns.de

Pro Hibernate 3 (eBook)

eBook Download: PDF
2006 | 1st ed.
264 Seiten
Apress (Verlag)
978-1-4302-0042-0 (ISBN)

Lese- und Medienproben

Pro Hibernate 3 - Dave Minter, Jeff Linwood
Systemvoraussetzungen
35,30 inkl. MwSt
(CHF 34,45)
Der eBook-Verkauf erfolgt durch die Lehmanns Media GmbH (Berlin) zum Preis in Euro inkl. MwSt.
  • Download sofort lieferbar
  • Zahlungsarten anzeigen
* First to market with complete Hibernate 3 coverage and real-world application design tips.

* Comprehensive reference for Hibernate object relational mapping strategies.

* Integrated approach to database and Java application design.



Dave Minter has adored computers since he was small enough to play in the boxes they came in. He built his first PC from discarded, faulty, and obsolete components, and considers that to be the foundation of his career as an integration consultant. Dave is based in London, where he helps large and small companies build systems that 'just work.' He co-authored Building Portals with the Java Portlet API and Pro Hibernate 3.
Pro Hibernate 3 is the first book to offer complete coverage of the open source lightweight Hibernate 3 and its features. Authors Dave Minter and Jeff Linwood discuss the persistence layer and share design tips and best practices. And the duo goes beyond just explaining how to use parts of Hibernate; they probe well beneath the surface, and teach you how to step back and solve problems thoroughly.If you have experience using Java with databases, but lack experience with Hibernate, then this book is ideal for you. Similarly, if you have some familiarity with Hibernate 2 and now want to learn the nuances of version 3, then this book is a wise addition to your library.

Dave Minter has adored computers since he was small enough to play in the boxes they came in. He built his first PC from discarded, faulty, and obsolete components, and considers that to be the foundation of his career as an integration consultant. Dave is based in London, where he helps large and small companies build systems that "just work." He co-authored Building Portals with the Java Portlet API and Pro Hibernate 3.

Contents at a Glance 5
Contents 7
About the Authors 13
About the Technical Reviewer 15
Acknowledgments 17
Introduction 19
Part 1 Hibernate 3 Primer 23
1 An Introduction to Hibernate 3 24
2 Integrating and Configuring Hibernate 34
3 Building a Simple Application 48
4 Using Annotations with Hibernate 86
Part 2 Hibernate 3 Reference 104
5 The Persistence Lifecycle 106
6 Creating Mappings 114
7 Querying Objects with Criteria 152
8 Querying with HQL and SQL 166
9 Using the Session 180
10 Design Considerations with Hibernate 3 196
11 Events and Interceptors 210
12 Hibernate Filters 224
13 Fitting Hibernate into the Existing Environment 234
14 Upgrading from Hibernate 2 244
Index 250

C H A P T E R 7

Querying Objects with Criteria (P. 131)

In this chapter, we are going to discuss retrieving objects from the database using Hibernate’s criteria query API. Hibernate provides three different ways to retrieve data: the criteria query API, the Hibernate Query Language (HQL), and native SQL queries. The criteria query API provides a set of Java objects you can use to construct your queries. Hibernate provides its own object query language, HQL, which allows you to use SQL-like syntax to retrieve objects from the database. Lastly, Hibernate provides an API for using SQL directly against the database, which allows you to use database-specific SQL that Hibernate does not support.

We discuss criteria in this chapter—in Chapter 8 we will cover HQL and SQL queries. The criteria query API lets you build nested, structured query expressions in Java, providing a compile-time syntax checking that is not possible with a query language like HQL or SQL. The criteria query API also includes Query By Example (QBE) functionality for supplying example objects that contain the properties you would like to retrieve.

In Hibernate 3, the criteria query API also includes projection and aggregation methods, including count. In Hibernate 2, you had to download a patch to the criteria query API to enable row counting.

Using the Criteria Query API

The easiest way to retrieve data with Hibernate is to use the criteria query API. Instead of writing an SQL SELECT statement or an HQL statement, you can build up a query programmatically. You can also use QBE to retrieve objects that match an object that you have partially populated (we will discuss QBE in more detail further on in the chapter). The org.hibernate. Criteria interface defines the available methods for one of these criteria query objects.

The Hibernate Session interface contains several createCriteria() methods. Pass the persistent object’s class or its entity name to the createCriteria() method, and Hibernate will create a Criteria object that returns instances of the persistence object’s class when your application executes a criteria query.

The simplest example of a criteria query is one with no optional parameters or restrictions —the criteria query will simply return every object that corresponds to the class. We will illustrate this criteria with an example, but we wanted to first introduce the sample application we are using in this chapter, and the next chapter on HQL. The sample application has three classes: Supplier, Product, and Software. The Supplier class (see Listing 7-1) has a name property and a List collection of Product objects.

Listing 7-1. The Supplier Class

package com.hibernatebook.criteria,

import java.util.ArrayList,

import java.util.List,

public class Supplier

{

private int id,

private String name,

private List products = new ArrayList(),

public int getId()

{

return id,

}

public void setId(int id)

{

Erscheint lt. Verlag 22.11.2006
Zusatzinfo 264 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Schlagworte action • Annotation • Hibernate • Java • object • object oriented design • Open Source • query language • SQL • Stored Procedure
ISBN-10 1-4302-0042-1 / 1430200421
ISBN-13 978-1-4302-0042-0 / 9781430200420
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 1,4 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Johannes Ernesti; Peter Kaiser

eBook Download (2023)
Rheinwerk Computing (Verlag)
CHF 43,85
Das Handbuch für Webentwickler

von Philip Ackermann

eBook Download (2023)
Rheinwerk Computing (Verlag)
CHF 48,75