Linwood / Minter | Beginning Hibernate | E-Book | www2.sack.de
E-Book

E-Book, Englisch, 400 Seiten

Linwood / Minter Beginning Hibernate


2. ed
ISBN: 978-1-4302-2851-6
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark

E-Book, Englisch, 400 Seiten

ISBN: 978-1-4302-2851-6
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark



Beginning Hibernate, Second Edition is ideal if you're experienced in Java with databases (the traditional, or 'connected,' approach), but new to open-source, lightweight Hibernate-the de facto object-relational mapping and database-oriented application development framework. This book packs in information about the release of the Hibernate 3.5 persistence layer and provides a clear introduction to the current standard for object-relational persistence in Java. And since the book keeps its focus on Hibernate without wasting time on nonessential third-party tools, you'll be able to immediately start building transaction-based engines and applications. Experienced authors Dave Minter and Jeff Linwood provide more in-depth examples than any other book for Hibernate beginners. The authors also present material in a lively, example-based manner-not a dry, theoretical, hard-to-read fashion.

Jeff Linwood has been involved in software programming since he had a 286 in high school. He got caught up with the Internet when he got access to a UNIX shell account, and it has been downhill ever since. Jeff has published articles on several Jakarta Apache open source projects in Dr. Dobb's Journal, CNET's Builder.com, and JavaWorld. Jeff has a bachelor's degree in chemical engineering from Carnegie Mellon University. He currently works for the Gossamer Group in Austin, Texas, on content management and web application syndication systems. He gets to play with all the latest open source projects there. Jeff also co-authored Professional Struts Applications, Building Portals with the Java Portlet API, and Pro Hibernate 3. He was a technical reviewer for Enterprise Java Development on a Budget and Extreme Programming with Ant.

Linwood / Minter Beginning Hibernate jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


1;Contents at a Glance;4
2;Table of Contents;6
3;About the Authors;16
4;About the Technical Reviewer;17
5;Acknowledgments;18
6;Introduction;19
6.1;Who This Book Is For;19
6.2;How This Book Is Structured;19
6.3;Downloading the Code;21
6.4;Contacting the Authors;21
7;CHAPTER 1 An Introduction to Hibernate 3.5;22
7.1;Plain Old Java Objects (POJOs);22
7.2;Origins of Hibernate and Object-Relational Mapping;24
7.3;Hibernate As a Persistence Solution;25
7.4;A Hibernate Hello World Example;26
7.5;Mappings;27
7.6;Summary;28
8;CHAPTER 2 Integrating and Configuring Hibernate;29
8.1;The Steps Needed to Integrate and Configure Hibernate;29
8.2;Understanding Where Hibernate Fits in Your Java Application;30
8.3;Deploying Hibernate;31
8.3.1;Required Libraries for Running Hibernate 3.5;31
8.3.2;JMX and Hibernate;32
8.4;Hibernate Configuration;32
8.4.1;Hibernate Properties;34
8.4.2;XML Configuration;38
8.4.3;Annotated Classes;39
8.4.4;Naming Strategy;40
8.4.5;Using a Container-Managed Data Source;41
8.5;The Session Factory;41
8.6;SQL Dialects;42
8.7;Summary;45
9;CHAPTER 3 Building a Simple Application;46
9.1;Installing the Tools;46
9.1.1;Hibernate and Hibernate Tools;46
9.1.2;Simple Logging Facade for Java (SLF4J) 1.5.11;47
9.1.3;HSQLDB 2.0.0;47
9.1.4;Ant 1.8.0;48
9.1.5;The Ant Tasks;51
9.2;Creating a Hibernate Configuration File;52
9.3;Running the Message Example;54
9.4;Persisting Multiple Objects;57
9.5;Creating Persistence Classes;58
9.6;Creating the Object Mappings;61
9.7;Creating the Tables;67
9.8;Sessions;69
9.8.1;The Session and Related Objects;69
9.8.2;Using the Session;71
9.9;The Example Client;73
9.10;Summary;78
10;CHAPTER 4 The Persistence Life Cycle;79
10.1;Introduction to the Life Cycle;79
10.2;Entities, Classes, and Names;80
10.3;Identifiers;81
10.4;Entities and Associations;81
10.5;Saving Entities;85
10.6;Object Equality and Identity;86
10.7;Loading Entities;87
10.8;Refreshing Entities;88
10.9;Updating Entities;89
10.10;Deleting Entities;90
10.11;Cascading Operations;90
10.12;Lazy Loading, Proxies, and Collection Wrappers;92
10.13;Querying Objects;93
10.14;Summary;93
11;CHAPTER 5 An Overview of Mapping;94
11.1;Why Mapping Cannot Be Automated;95
11.2;Primary Keys;97
11.3;Lazy Loading;99
11.4;Associations;99
11.4.1;The One-to-One Association;101
11.4.2;The One-to-Many and Many-to-One Association;103
11.4.3;The Many-to-Many Association;105
11.4.4;Applying Mappings to Associations;106
11.5;Other Information Represented in Mappings;106
11.5.1;Specification of (Database) Column Types and Sizes;106
11.5.2;The Mapping of Inheritance Relationships to the Database;106
11.5.3;Primary Key;107
11.5.4;The Use of SQL Formula–Based Properties;107
11.5.5;Mandatory and Unique Constraints;107
11.5.6;Cascading of Operations;107
11.6;Summary;107
12;CHAPTER 6 Mapping with Annotations;108
12.1;Creating Hibernate Mappings with Annotations;108
12.1.1;Cons of Annotations;108
12.1.2;Pros of Annotations;108
12.1.3;Choosing Which to Use;110
12.1.4;Using Annotations in Your Application;110
12.1.5;JPA 2 Persistence Annotations;110
12.1.6;Entity Beans with @Entity;112
12.1.7;Primary Keys with @Id and @GeneratedValue;112
12.1.8;Generating Primary Key Values with @SequenceGenerator;114
12.1.9;Generating Primary Key Values with @TableGenerator;115
12.1.10;Compound Primary Keys with @Id, @IdClass, or @EmbeddedId;116
12.1.11;Database Table Mapping with @Table and @SecondaryTable;120
12.1.12;Persisting Basic Types with @Basic;122
12.1.13;Omitting Persistence with @Transient;122
12.1.14;Mapping Properties and Fields with @Column;123
12.1.15;Modeling Entity Relationships;124
12.1.15.1;Mapping an Embedded (Component) One-to-One Association;124
12.1.15.2;Mapping a Conventional One-to-One Association;125
12.1.15.3;Mapping a Many-to-One or One-to-Many Association;126
12.1.15.4;Mapping a Many-to-Many Association;130
12.1.16;Inheritance;131
12.1.16.1;Single Table;132
12.1.16.2;Joined;133
12.1.16.3;Table per Class;133
12.1.16.4;Choosing Between Inheritance Types When Modeling Inheritance;134
12.1.17;Other JPA 2 Persistence Annotations;134
12.1.17.1;Temporal Data;134
12.1.17.2;Element Collections;135
12.1.17.3;Large Objects;135
12.1.17.4;Mapped Superclasses;136
12.1.18;Ordering Collections with @OrderColumn;136
12.1.18.1;Named Queries (HQL or JPQL);137
12.1.18.2;Named Native Queries (SQL);138
12.2;Configuring the Annotated Classes;138
12.3;Hibernate 3–Specific Persistence Annotations;139
12.3.1;@Entity;140
12.3.2;Sorting Collections with @Sort;140
12.3.3;Applying Indexes with @Table and @Index;141
12.3.4;Restricting Collections with @Where;141
12.3.5;Alternative Key Generation Strategies with @GenericGenerator;141
12.4;Using Ant with Annotation-Based Mappings;142
12.5;Code Listings;143
12.6;Summary;148
13;CHAPTER 7 Creating Mappings with Hibernate XML Files;149
13.1;Hibernate Types;149
13.1.1;Entities;149
13.1.2;Components;150
13.1.3;Values;150
13.2;The Anatomy of a Mapping File;152
13.2.1;The Element;152
13.2.2;The Element;154
13.2.3;The Element;157
13.2.4;The Element;160
13.2.5;The Element;162
13.2.6;The Element;163
13.2.7;The Element;165
13.2.8;The Collection Elements;168
13.2.8.1;The set Collection;170
13.2.8.2;The list Collection;172
13.2.8.3;The idbag Collection;173
13.2.8.4;The map Collection;174
13.2.8.5;The bag Collection;175
13.3;Mapping Simple Classes;176
13.4;Mapping Composition;178
13.5;Mapping Other Associations;181
13.6;Mapping Collections;184
13.7;Mapping Inheritance Relationships;187
13.7.1;One Table per Concrete Class;187
13.7.2;One Table per Subclass;188
13.7.3;One Table per Class Hierarchy;190
13.8;More Exotic Mappings;191
13.8.1;The any Tag;191
13.8.2;The array Tag;192
13.8.3;The Element;192
13.9;Summary;192
14;CHAPTER 8 Using the Session;193
14.1;Sessions;193
14.2;Transactions and Locking;197
14.2.1;Transactions;197
14.2.2;Locking;200
14.2.3;Deadlocks;201
14.3;Caching;205
14.4;Threads;207
14.5;Summary;208
15;CHAPTER 9 Searches and Queries;209
15.1;Hibernate Query Language (HQL);209
15.2;Syntax Basics;210
15.2.1;UPDATE;210
15.2.2;DELETE;210
15.2.3;INSERT;211
15.2.4;SELECT;211
15.3;The First Example with HQL;212
15.4;Logging and Commenting the Underlying SQL;216
15.4.1;Logging the SQL;216
15.4.2;Commenting the Generated SQL;217
15.5;The from Clause and Aliases;218
15.6;The select Clause and Projection;218
15.7;Using Restrictions with HQL;219
15.8;Using Named Parameters;220
15.9;Paging Through the Result Set;221
15.10;Obtaining a Unique Result;221
15.11;Sorting Results with the order by Clause;222
15.12;Associations;222
15.13;Aggregate Methods;223
15.14;Bulk Updates and Deletes with HQL;224
15.15;Named Queries for HQL and SQL;225
15.16;Using Native SQL;227
15.17;Summary;229
16;CHAPTER 10 Advanced Queries Using Criteria;230
16.1;Using the Criteria API;230
16.2;Using Restrictions with Criteria;230
16.3;Paging Through the Result Set;234
16.4;Obtaining a Unique Result;234
16.5;Sorting the Query’s Results;235
16.6;Associations;235
16.7;Distinct Results;236
16.8;Projections and Aggregates;236
16.9;Query By Example (QBE);238
16.10;Summary;240
17;CHAPTER 11 Filtering the Results of Searches;241
17.1;When to Use Filters;241
17.2;Defining and Attaching Filters;242
17.2.1;Filters with Annotations;242
17.2.2;Filters with XML Mapping Documents;243
17.3;Using Filters in Your Application;243
17.4;A Basic Filtering Example;244
17.5;Summary;248
18;CHAPTER 12 Case Study – Using Hibernate with an Existing Database;249
18.1;Setting up the Database;249
18.1.1;Downloading the Data;249
18.1.2;Understanding the Data;250
18.1.2.1;Geographic Names;250
18.1.2.2;Country Subdivision Codes;252
18.1.2.3;Second-Level Subdivisions;252
18.1.2.4;Feature Codes;253
18.1.3;Creating the Database Schema;254
18.1.4;Loading the Data;256
18.2;Creating a Java Object Model;257
18.2.1;Creating the Admin1Code Class;258
18.2.2;Creating the Admin2Code Class;261
18.2.3;Creating the Feature Codes Class;264
18.2.4;Creating the Place Class;267
18.3;Configuring Hibernate;271
18.4;Building the List of High Points;273
18.4.1;Developing the HQL Query;273
18.4.2;Running the Query;274
18.5;Moving Forward with the Example;276
18.6;Summary;276
19;APPENDIX A More Advanced Features;277
19.1;Managed Versioning and Optimistic Locking;277
19.2;Maps;278
19.3;Limitations of Hibernate;279
19.4;Hand-Rolled SQL;280
19.4.1;Using a Direct Mapping;280
19.4.2;Using a View;281
19.4.3;Putting SQL into an Annotation or Mapping;283
19.5;Invoking Stored Procedures;285
19.6;Events;286
19.6.1;An Example Event Listener;289
19.7;Interceptors;290
19.7.1;An Example Interceptor;293
19.8;Overriding the Default Constructor;298
19.9;Hibernate Search;299
19.10;Summary;300
20;APPENDIX B Hibernate Tools;301
20.1;The Eclipse Plug-In;301
20.1.1;Downloading the Hibernate Tools Plug-in;302
20.1.2;Installing the Plug-In;302
20.1.3;The Boilerplate Project Configuration;305
20.1.4;Using the Hibernate Console;307
20.1.4.1;Creating a Hibernate Console Configuration;308
20.1.4.2;Generating the Schema;311
20.1.4.3;Running the Test Program;312
20.1.4.4;Browsing the Model;312
20.1.4.5;Testing HQL Queries;314
20.1.4.6;Query Parameters;316
20.1.4.7;Creating a Mapping Diagram;317
20.1.4.8;Generating a Configuration File;318
20.1.4.9;The Reverse Engineering and Code Generation Tools;319
20.2;The Ant Tasks;327
20.2.1;How the Ant Tasks Work;327
20.2.2;Reverse Engineering;333
20.2.3;Templates;337
20.2.4;Configuring the Classpath;338
20.3;Summary;339
21;APPENDIX C Hibernate and Spring;340
21.1;Configuring Hibernate from a Spring Application;340
21.1.1;Configuring Spring;341
21.2;Using Hibernate in Your Spring Beans;343
21.3;Declarative Transaction Management;344
21.4;Managing the Session;345
21.5;The Sample Configuration File;346
21.6;Summary;349
22;APPENDIX D Upgrading from Hibernate 2;350
22.1;Package and DTD Changes;350
22.2;New Features and Support for Old Ones;351
22.2.1;Changes and Deprecated Features;352
22.2.2;Additions;353
22.3;Changes to Tools and Libraries;353
22.4;Changes with Java 5;354
22.5;Summary;354
23;Index;355



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.