Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
Skip header Section
Pro EJB 3: Java Persistence API (Pro)May 2006
Publisher:
  • Apress
  • 901 Grayson Street Suite 204 Berkely, CA
  • United States
ISBN:978-1-59059-645-6
Published:01 May 2006
Skip Bibliometrics Section
Reflects downloads up to 15 Oct 2024Bibliometrics
Abstract

No abstract available.

Contributors

Reviews

Mike S. Joy

An introduction to the new Java Persistence application programming interfaces (APIs), this book serves not only as a tutorial on how to use them, but also as a basic reference text. Java persistence refers to the use of Java for programs where data used by the software persists between invocations of the software, using a relational database to store and maintain the data. The Java Persistence API (JPA) uses the plain old Java object (POJO) model, and is a simplification of the previous Java approach to persistence used by Enterprise Java Beans (EJB) prior to EJB 3.0. The introduction clearly describes, in a historical context, the technologies and concepts that the book is dealing with, and explains how the previous approach—that of entity beans—was a complex solution to implementing persistence, which was difficult to use. The technical problems associated with implementing an object-relational mapping (ORM), which associates Java objects with table rows in a relational database, are covered, and provide good motivation for the subsequent material. Chapter 2 clarifies the meanings of terms such as “entity” and “persistable object” and introduces annotations as part of the Java SE 5 language specification. A simple example is used to show how a bean-like Java object can be converted into an entity, and to illustrate the roles of transactions and of the entity manager in the process. Chapter 3 describes the principal features of the Java EE platform, including the EJB model, session beans, remote method invocation (RMI), servlets, and transaction management. The example from the previous chapter is expanded to form the basis of a simple enterprise application. The next chapter explores ORM in depth and shows how a variety of simple Java objects can be mapped to a relational database. This chapter requires some understanding of databases and database concepts, but this need only be at a very basic level. This is followed in chapter 5 by a detailed consideration of how an entity manager works, including the various persistence contexts, and includes further material on transaction management. Chapters 6 and 7 cover the Java Persistence Query Language (JPQL), which has a syntax similar to structured query language (SQL), but is tailored to Java and, for example, can return Java objects in response to queries rather than SQL data. A discussion of best practices is included, which focuses the reader’s attention on efficiency considerations. The second of these two chapters commences with a semi-formal description of the syntax and semantics of the language, which compares and contrasts it with SQL. Advanced ORM topics are the focus of chapter 8. These include the handling of complex relational database artifacts, such as compound joins, and the mapping of hierarchies of classes and subclasses to a database. Chapter 9 covers further advanced issues, including concurrency, locking, and versioning, and a discussion of how Java Database Connectivity (JDBC) compares with the use of native SQL queries in the Java Persistence API. Metadata associated with entities can be coded as annotations within the Java source code or as Extensible Markup Language (XML). Chapter 10 describes the XML elements that can be used to encode the metadata and discusses the advantages and disadvantages of the two approaches. A completed product must be packaged so that it can be distributed and deployed. Chapter 11 discusses the options available for this part of the process, including the use of EJB jar files, Web archives (war files), and the configuration information that needs to be included. The testing phase of the software life cycle is not forgotten and an appropriate unit testing framework is presented in chapter 12. Legacy Java applications with persistence may have been implemented using JDBC or earlier versions of EJB, and the migration of the persistence layer of such applications to EJB 3.0 and the Java Persistence API is the subject of the final chapter. There is a comprehensive index, and the publisher’s Web site offers downloads of the code fragments presented in the book. The appendix contains reference summaries of the metadata (both annotations and XML) and of the principal Java interfaces referred to in the book. The book is very well written, and the technical material is presented clearly without excessive detail. The authors claim that previous knowledge of the J2EE platform is not required, but the Apress roadmap diagram on the back cover suggests that the companion book Beginning Java EE 5 [1] is a prerequisite, and I certainly feel that some prior experience with J2EE would be beneficial to the reader. That aside, this is an excellent textbook. Online Computing Reviews Service

Access critical reviews of Computing literature here

Become a reviewer for Computing Reviews.

Recommendations