Available:*
Library | Item Barcode | Call Number | Material Type | Item Category 1 | Status |
---|---|---|---|---|---|
Searching... | 30000010075938 | QA76.76.M54 P83 2004 | Open Access Book | Book | Searching... |
On Order
Summary
Summary
What is this book about?
This book is written for professional Java developers who already understand how to build server-side Java applications. The book assumes no previous experience with Hibernate, though readers should have a general familiarity with databases and Web development.
What does this book cover?
After a quick overview of Hibernate in the first two chapters, the authors jump right to the code. They show how to do the following:
Obtain and install Hibernate Build the Hibernate development environment Use Hibernate to connect to databases Use Hibernate to create persistent classes and objects Use the Hibernate database query language and transaction management functions Use the Hibernate APIsAfter covering these essentials, the authors go further, showing readers how to use Hibernate in the real world. This means demonstrating how to use Hibernate with other popular tools that readers are using (including Eclipse, Tomcat, Maven, Struts, and XDoclet). This book takes a very real-world, hands-on approach to these topics and includes many working code examples, as well as a sophisticated sample application.
Author Notes
Eric Pugh is a member of the Maven development team and an experienced Java enterprise developer specializing in database application design and development, and open source tool integration. He has contributed Hibernate-related code to many projects, including XDoclet and OSWorkflow, and is currently leading development of the Hibernate plugin for Maven. Eric has built several Hibernate applications for clients (including a Web-based lab automation application) and regularly uses Hibernate with Eclipse and Maven. In addition to writing documentation and specifications, Eric has written for OnJava.
Joseph D. Gradecki is a software engineer at Comprehensive Software Solutions, where he works on their SABIL product, an enterprise-level securities processing system. He has built numerous dynamic, enterprise application using Java, Hibernate, MySQL, XML, AspectJ, servlets, JSPs, Resin, BroadVision, and other technologies. He is the author of Mastering JXTA and the co-author of MySQL and Java Developers Guide and Professional Java Tools for Extreme Programming . Joe holds Bachelors and Masters degrees in Computer Science and is currently pursuing a Ph.D.
Table of Contents
Introduction | p. ix |
Chapter 1 Introduction to Mapping Objects to Relational Databases | p. 1 |
Serialization | p. 2 |
XML | p. 2 |
Object-Oriented Database Systems | p. 3 |
Mapping | p. 3 |
Primary Keys, Timestamps, and Version Numbers | p. 8 |
Handling Inheritance | p. 8 |
Working With Relationships | p. 11 |
Summary | p. 14 |
Chapter 2 Introduction to Hibernate | p. 15 |
Hibernate | p. 15 |
Hibernate Architecture | p. 16 |
Hibernate Configuration | p. 18 |
Hibernate Sessions | p. 20 |
Hibernate Callbacks | p. 21 |
Hibernate's Support for Other Technologies | p. 22 |
Summary | p. 22 |
Chapter 3 Hibernate Development Environment | p. 23 |
Obtaining Hibernate | p. 23 |
Hibernate Prerequisites and Requirements | p. 24 |
Installing Hibernate | p. 25 |
Hibernate Configuration File | p. 26 |
Hooking Up a Database Server | p. 26 |
Setting Up Hibernate to Use MySQL | p. 27 |
Setting Up Hibernate to Use Microsoft SQL Server | p. 27 |
A Standalone Hibernate Application | p. 28 |
Creating the Java Class | p. 28 |
Creating a Database Table | p. 30 |
Building a Mapping Document for Database Tables | p. 30 |
Application Skeleton Code | p. 33 |
Loading the Mapping into an Application | p. 38 |
A Servlet-Based Hibernate Application | p. 46 |
Installing and Configuring Tomcat | p. 46 |
Setting Up Tomcat Database Access | p. 47 |
Adding Hibernate to the Web Application | p. 49 |
Interface Page | p. 50 |
Writing a Servlet to Use Hibernate | p. 51 |
Summary | p. 53 |
Chapter 4 Database Connecting and Schema Generation | p. 55 |
Overview of Hibernate JDBC Properties | p. 56 |
hibernate.connection.driverclass | p. 56 |
hibernate.connection.url | p. 58 |
hibernate.connection.username | p. 58 |
hibernate.connection.password | p. 58 |
hibernate.connection.pool_size | p. 58 |
hibernate.connection.datasource | p. 58 |
hibernate.jndi.url | p. 59 |
hibernate.jndi.class | p. 59 |
hibernate.dialect | p. 59 |
hibernate.default_schema | p. 59 |
hibernate.Session_-factory_name | p. 59 |
hibernate.use_outer_join | p. 59 |
hibernate.max_fetch_depth | p. 59 |
hibernate.jdbc.fetch_size | p. 60 |
hibernate.jdbc.batch_size | p. 60 |
hibernate.jdbc.use_scrollable_resultset | p. 60 |
hibernate.jdbc.use_streams_for_binary | p. 60 |
hibernate.cglib.use_reflection_optimizer | p. 60 |
hibernate.jndi.[left angle bracket]property[right angle bracket] | p. 60 |
hibernate.connection.isolation | p. 60 |
hibernate.connection.provider_class | p. 61 |
hibernate.transaction.factory_class | p. 61 |
jta.UserTransaction | p. 61 |
hibernate.show_sql | p. 61 |
Query Substitutions | p. 62 |
SQL Dialect Determination | p. 62 |
Using Connection Pooling | p. 64 |
Using Hibernate's Built-in Pooling | p. 65 |
Using C3P0 | p. 65 |
Using Apache DBCP | p. 66 |
Using Proxool | p. 66 |
JDBC Database Connection | p. 67 |
Using More Than One Database Server | p. 68 |
Building the Mapping Document | p. 69 |
[left angle bracket]hibernate-mapping[right angle bracket] Element | p. 69 |
[left angle bracket]class[right angle bracket] Element | p. 70 |
[left angle bracket]id[right angle bracket] Element | p. 72 |
[left angle bracket]generator[right angle bracket] Element | p. 73 |
[left angle bracket]composite-id[right angle bracket] Element | p. 75 |
[left angle bracket]discriminator[right angle bracket] Element | p. 76 |
[left angle bracket]version[right angle bracket] Element | p. 77 |
[left angle bracket]timestamp[right angle bracket] Element | p. 78 |
[left angle bracket]property[right angle bracket] Element | p. 78 |
Relationship Elements | p. 80 |
[left angle bracket]many-to-one[right angle bracket] Element | p. 80 |
[left angle bracket]one-to-one[right angle bracket] Element | p. 81 |
[left angle bracket]component[right angle bracket] Element | p. 82 |
[left angle bracket]subclass[right angle bracket] Element | p. 82 |
[left angle bracket]joined-subclass[right angle bracket] Element | p. 83 |
Collection Elements | p. 84 |
[left angle bracket]key[right angle bracket] Element | p. 85 |
[left angle bracket]index[right angle bracket] Element | p. 86 |
[left angle bracket]element[right angle bracket] Element | p. 86 |
Summary | p. 86 |
Chapter 5 Creating Persistent Classes | p. 87 |
Creating Persistent Java Classes | p. 87 |
Mapping a Basic Java Class | p. 88 |
Mapping a Class with Binary Data | p. 93 |
Mapping a Serializable Class | p. 95 |
Mapping a Class with Data/Calendar Attributes | p. 97 |
Mapping a Read-Only Class | p. 99 |
Mapping Classes Using Versioning/Timestamps | p. 102 |
Mapping Inheritance with Java Classes | p. 107 |
Persisting Interfaces | p. 117 |
Mapping Enums | p. 119 |
Working with Column Formulas | p. 122 |
Using the Session Pattern | p. 124 |
Summary | p. 126 |
Chapter 6 Working with Collections | p. 127 |
Associations | p. 127 |
Index Elements | p. 128 |
Element Elements | p. 129 |
Bidirectional Associations | p. 130 |
Lazy Initialization | p. 131 |
Mapping Maps/SortedMaps | p. 131 |
Mapping a Values Map | p. 131 |
Mapping an Object Map: [left angle bracket]many-to-many[right angle bracket] Element | p. 135 |
Mapping a TreeMap | p. 140 |
Mapping Set/SortedSets | p. 147 |
SortedSet Interface Mapping | p. 151 |
Mapping Lists | p. 152 |
Bag Mapping | p. 156 |
Mapping Arrays | p. 157 |
Mapping a Bidirectional Association | p. 158 |
Summary | p. 160 |
Chapter 7 Using Persistent Objects | p. 161 |
Persisting Objects | p. 161 |
Loading Data into an Object | p. 164 |
Using Previous Sessions | p. 165 |
Flushing Objects | p. 166 |
Deleting Objects | p. 166 |
Refreshing Objects | p. 168 |
Updating Objects | p. 168 |
Finding Objects | p. 169 |
Finding Large Resultsets | p. 171 |
Filtering Collections | p. 171 |
Scalar Queries | p. 172 |
Queries and Named Queries | p. 173 |
Query Results Control | p. 176 |
Single Row | p. 178 |
Named Queries | p. 178 |
Named Parameters | p. 179 |
Query Timeout | p. 180 |
SQL Queries | p. 180 |
Criteria Objects | p. 181 |
Summary | p. 184 |
Chapter 8 Hibernate Query Language | p. 185 |
Chapter Example | p. 185 |
Example Classes | p. 185 |
Example Mapping Document | p. 189 |
Example Tables | p. 191 |
Example Application | p. 191 |
Example Rows | p. 192 |
Example Use | p. 193 |
Select Clause | p. 194 |
Narrowing the SELECT Using the WHERE Clause | p. 196 |
Working with Collections in HQL | p. 197 |
.size, size() | p. 197 |
.minIndex, minindex(), .maxIndex, maxindex() | p. 197 |
index() | p. 198 |
any(), some(), all(), exists(), in(), elements(), indices() | p. 198 |
[] | p. 199 |
Other HQL WHERE Expressions | p. 199 |
Logicals | p. 199 |
NULL Expression | p. 199 |
Groupings | p. 200 |
Scalar Functions | p. 200 |
Equality | p. 201 |
Named Parameters | p. 201 |
Booleans | p. 201 |
Subselects | p. 202 |
Polymorphism | p. 202 |
Order By Clause | p. 203 |
Aggregate Functions | p. 204 |
Group By Clause | p. 204 |
HAVING Clause | p. 205 |
Working with HQL Joins | p. 205 |
Left Outer Join | p. 205 |
Right Outer Join | p. 206 |
Inner Join | p. 206 |
Full Join | p. 206 |
Fetch Join | p. 206 |
Summary | p. 206 |
Chapter 9 Hibernate Caching | p. 207 |
Why Cache? What Does Hibernate Provide? | p. 207 |
Caching the Survey Object Example Code | p. 208 |
Setting Up a SessionFactory Cache | p. 212 |
Using the Persistent Object Cache | p. 213 |
Read-Only Cache Usage | p. 213 |
Read-Write Cache Usage | p. 214 |
Nonstrict Read-Write Cache Usage | p. 214 |
Transactional Cache Usage | p. 214 |
SessionFactory Support Methods | p. 214 |
Using the Query Cache | p. 215 |
Session Cache Functionality | p. 216 |
Setting Up EHCache | p. 216 |
When Not to Use Caching | p. 218 |
Summary | p. 219 |
Chapter 10 Hibernate Transactions and Locking | p. 221 |
What Are Transactions? | p. 223 |
Configuration | p. 223 |
Database Support | p. 224 |
Using Transactions | p. 225 |
The Transaction API | p. 226 |
Transaction Example Using MySQL | p. 227 |
ISAM Table Type | p. 228 |
InnoDB Table Type | p. 228 |
Forced Rollback Example | p. 229 |
Optimal Session Use | p. 229 |
Locking | p. 230 |
Summary | p. 234 |
Chapter 11 J2EE and Hibernate | p. 235 |
Installing an Application Server | p. 235 |
Configuring Tomcat for Hibernate with JNDI | p. 235 |
Configuring Tomcat for JNDI | p. 236 |
Creating the Necessary Hibernate Configuration File | p. 236 |
SessionFactory Singleton Class | p. 237 |
Building a Stateless Session Bean | p. 238 |
Building a Stateful Session Bean | p. 240 |
Using Container Managed Transactions (CMT) | p. 242 |
Summary | p. 245 |
Chapter 12 Hibernate and DAO Design Pattern | p. 247 |
Data Access Object Design Pattern | p. 247 |
Factory Method Implementation | p. 250 |
Abstract Factory Implementation | p. 252 |
Concrete DAO Example | p. 253 |
Building a DAO Factory | p. 254 |
Building Specific Data Source Factories | p. 254 |
Building the DAO Objects | p. 255 |
Testing It All | p. 259 |
Summary | p. 260 |
Chapter 13 Hibernate and XDoclet | p. 261 |
Introduction to XDoclet | p. 262 |
What Is Javadoc? | p. 263 |
How XDoclet Works | p. 264 |
Code Generation Templating | p. 265 |
Why XDoclet Simplifies Development | p. 265 |
Installing XDoclet | p. 266 |
Using XDoclet with Hibernate | p. 266 |
Simple Example | p. 266 |
Generating Hibernate.cfg.xml | p. 268 |
Generating an MBean Descriptor File for JBoss | p. 270 |
Tagging Source Files with Mapping Attributes | p. 272 |
Hibernate XDoclet Tags and Description | p. 282 |
@hibernate.class | p. 282 |
@hibernate.cache | p. 283 |
@hibernate.discriminator | p. 283 |
@hibernate.joined-subclass | p. 283 |
@hibernate.joined-subclass-key | p. 284 |
@hibernate.query | p. 284 |
@hibernate.subclass | p. 284 |
@hibernate.array | p. 284 |
@hibernate.bag (0..1) | p. 285 |
@hibernate.collection-cache | p. 285 |
@hibernate.collection-composite-element | p. 286 |
@hibernate.collection-element | p. 286 |
@hibernate.collection-index | p. 286 |
@hibernate.collection-key | p. 287 |
@hibernate.collection-key-column (0..*) | p. 287 |
@hibernate.collection-many-to-many | p. 287 |
@hibernate.collection-one-to-many | p. 287 |
@hibernate.column | p. 288 |
@hibernate.component | p. 288 |
@hibernate.generator-param | p. 288 |
@hibernate.id | p. 289 |
@hibernate.index-many-to-many | p. 289 |
@hibernate.list | p. 290 |
@hibernate.many-to-one | p. 290 |
@hibernate.map | p. 291 |
@hibernate.one-to-one | p. 291 |
@hibernate.primitive-array | p. 292 |
@hibernate.property | p. 292 |
@hibernate.set | p. 292 |
@hibernate.timestamp | p. 293 |
@hibernate.version | p. 293 |
Full-Circle Process | p. 294 |
Tips on Using XDoclet | p. 304 |
Summary | p. 305 |
Chapter 14 Hibernate and Maven | p. 307 |
Installing Maven | p. 308 |
Using Maven | p. 308 |
The Project Object Model | p. 309 |
Five-Minute Tutorial to Using Maven | p. 310 |
Generating Hibernate Files with Maven | p. 312 |
Scripting Directly in Maven.xml | p. 314 |
Using the Hibernate Plug-in for Maven | p. 317 |
Putting It All Together | p. 319 |
Generating Files | p. 319 |
Configuring a Database Prior to Running Unit Tests | p. 320 |
Advantages over Ant | p. 327 |
Things to Be Aware Of | p. 327 |
Summary | p. 328 |
Chapter 15 Hibernate Extensions | p. 329 |
Tools | p. 329 |
SchemaExport/SchemaUpdate | p. 329 |
Hibernate Extensions | p. 342 |
AndroMDA | p. 355 |
MiddleGen | p. 358 |
Summary | p. 361 |
Chapter 16 Hibernate and Eclipse | p. 363 |
Hibernator | p. 363 |
Database Connection | p. 364 |
Creating a Mapping Document | p. 366 |
Querying the Database | p. 367 |
Creating a Schema | p. 367 |
Updating the Schema | p. 367 |
HiberClipse | p. 368 |
Configuring a JDBC Connection | p. 369 |
Creating a Mapping Document | p. 369 |
Creating Java Code from a Mapping Document | p. 370 |
Creating a Schema Export or Updating a Schema | p. 370 |
Hibernate Synchronizer | p. 370 |
Configuration File Wizard | p. 370 |
Mapping Document Wizard | p. 371 |
Summary | p. 372 |
Chapter 17 Using Velocity, Struts, and Hibernate | p. 373 |
Brief Introduction to Struts | p. 373 |
Struts Flow Diagram | p. 373 |
Installing Struts | p. 374 |
A Sample Application | p. 374 |
Building the ActionForm | p. 375 |
RegisterForm Code | p. 376 |
Creating an Action | p. 377 |
RegisterAction Code | p. 377 |
Configuring Struts | p. 378 |
Struts Configuration File | p. 382 |
Toolbox.xml File | p. 385 |
Success Page | p. 385 |
Success.vm Template | p. 385 |
Success under Struts and Velocity | p. 385 |
Register Page | p. 385 |
Register.VM Template | p. 387 |
Compile | p. 387 |
Run | p. 387 |
Summary | p. 388 |
Chapter 18 Hibernate and AspectJ | p. 389 |
What Is Aspect-Oriented Programming | p. 389 |
Where OOP Has Brought Us | p. 390 |
What OOADP Did for Computer Science | p. 390 |
Problems Resulting from OOP | p. 392 |
Results of Tangled Code | p. 396 |
How AOP Solves OOP Problems | p. 396 |
Introduction to AspectJ | p. 398 |
AOP Language Specification | p. 399 |
AOP Language Implementation | p. 401 |
AspectJ | p. 402 |
Example Aspect | p. 403 |
Using AspectJ with Hibernate | p. 404 |
Summary | p. 405 |
Chapter 19 Hibernate Interceptors | p. 407 |
Interceptor Interface | p. 407 |
Building an Interceptor | p. 408 |
Summary | p. 412 |
Appendix A Hibernate Database Connectivity | p. 413 |
DB2 | p. 413 |
DB2/400 | p. 414 |
HypersonicSQL | p. 414 |
Interbase | p. 414 |
McKoi SQL | p. 415 |
Microsoft SQL Server | p. 415 |
MySQL | p. 416 |
Oracle | p. 416 |
Pointbase | p. 416 |
PostgreSQL | p. 417 |
SAP DB | p. 417 |
Sybase | p. 417 |
Appendix B Getting Involved with Hibernate | p. 419 |
Hibernate Forums | p. 419 |
Hibernate Wiki | p. 420 |
Contributing to the Further Development of Hibernate | p. 420 |
Checking Out the Source and Building It | p. 420 |
Development Mailing List | p. 421 |
Issue Tracking | p. 421 |
More Information on Open Source | p. 422 |
Index | p. 423 |