Catálogo de publicaciones - libros

Compartir en
redes sociales


Pro EJB 3: Java Persistence API

Mike Keith Merrick Schincariol

Resumen/Descripción – provisto por la editorial

No disponible.

Palabras clave – provistas por la editorial

Software Engineering/Programming and Operating Systems

Disponibilidad
Institución detectada Año de publicación Navegá Descargá Solicitá
No detectada 2006 SpringerLink

Información

Tipo de recurso:

libros

ISBN impreso

978-1-59059-645-6

ISBN electrónico

978-1-4302-0168-7

Editor responsable

Springer Nature

País de edición

Reino Unido

Fecha de publicación

Información sobre derechos de publicación

© Apress 2006

Tabla de contenidos

Introduction

Mike Keith; Merrick Schincariol

In this chapter we presented an introduction to the Java Persistence API. We began with an overview of current standards for persistence, looking at JDBC, EJB, and JDO. In each case, we looked at the conditions forced on us by these frameworks and developed a view of what a better solution could be.

In the Object-Relational Mapping section we introduced the primary problem facing developers trying to use object-oriented domain models in concert with a relational database: the impedance mismatch. To demonstrate the complexity bridging the gap, we presented three small object models and nine different ways to represent the same information.

We concluded the chapter with a brief look at the Java Persistence API. We looked at the history of the specification and the vendors who came together to create it. We then looked at the role it plays in enterprise application development and introduced the feature set offered by the specification.

In the next chapter we will get our feet wet with the Java Persistence API, taking a whirlwind tour of the API basics and building a simple application in the process.

Pp. 1-15

Getting Started

Mike Keith; Merrick Schincariol

In this chapter we discussed just enough of the basics of the Java Persistence API to develop and run a simple application in a Java SE runtime.

We started out discussing the entity, how to define one, and how to turn an existing Java class into one. We discussed entity managers and how they are obtained and constructed in the Java SE environment.

The next step was to instantiate an entity instance and use the entity manager to persist it in the database. After we inserted some new entities, we were able to retrieve them again and then remove them. We also made some updates and ensured that the changes were written back to the database.

We talked about the resource-local transaction API and how to use it. We then went over some of the different types of queries and how to define and execute them. Finally, we aggregated all of these techniques and combined them into a simple application that we can execute in isolation from an enterprise environment.

In the next chapter, we will look at the impact of the Java EE environment when developing enterprise applications using the Java Persistence API.

Pp. 17-34

Enterprise Applications

Mike Keith; Merrick Schincariol

It is a simple exercise to package and deploy persistence applications using the Java Persistence API. In most cases it is just a matter of adding a very short persistence.xml file to the JAR containing the entity classes.

In this chapter we described how to configure the persistence unit in the Java EE server environment using the persistence.xml file and how in some cases the name may be the only setting required. We then explained when to apply and how to specify the transaction type, the persistence provider, and the data source. We showed how to use and specify the default orm.xml mapping file and then went on to use additional mapping files within the same persistence unit. We also discussed the various ways that classes may be included in the persistence unit and how to customize the persistence unit using vendor-specific properties.

We looked at the ways that persistence units may be packaged and deployed to a Java EE application as part of an EJB archive, a web archive, or a persistence archive that is accessible to all of the components in the application. We examined how persistence units may exist within different scopes of a deployed Java EE application and what the name-scoping rules were.

Finally we compared the configuration and deployment practices to deploying an application to a Java SE environment.

In the next chapter we will consider the accepted and best practices for testing applications that use persistence.

Pp. 35-69

Object-Relational Mapping

Mike Keith; Merrick Schincariol

Mapping objects to relational databases is of critical importance to persistence applications. Dealing with the impedance mismatch requires a sophisticated suite of metadata. The Java Persistence API not only provides this metadata, but also facilitates easy and convenient development.

In this chapter we went through the process of mapping entity state that included simple Java types, large objects, enumerated types, and temporal types. We also used the metadata to do meet-in-the-middle mapping to specific table names and columns.

We went over how identifiers are generated and described four different strategies of generation. We saw the different strategies in action and differentiated them from each other.

We then reviewed some of the relationship concepts and applied them to object-relational mapping metadata. We used join columns and join tables to map single-valued and collection-valued associations and went over some examples of using different kinds of Collection types.

In the next chapter we will discuss using entity managers and persistence contexts in more advanced ways than we did previously, delving into the practices and nuances of injecting and using them in Java EE and Java SE environments.

Pp. 71-109

Entity Manager

Mike Keith; Merrick Schincariol

In this chapter we discussed just enough of the basics of the Java Persistence API to develop and run a simple application in a Java SE runtime.

We started out discussing the entity, how to define one, and how to turn an existing Java class into one. We discussed entity managers and how they are obtained and constructed in the Java SE environment.

The next step was to instantiate an entity instance and use the entity manager to persist it in the database. After we inserted some new entities, we were able to retrieve them again and then remove them. We also made some updates and ensured that the changes were written back to the database.

We talked about the resource-local transaction API and how to use it. We then went over some of the different types of queries and how to define and execute them. Finally, we aggregated all of these techniques and combined them into a simple application that we can execute in isolation from an enterprise environment.

In the next chapter, we will look at the impact of the Java EE environment when developing enterprise applications using the Java Persistence API.

Pp. 111-161

Using Queries

Mike Keith; Merrick Schincariol

Routine use of micro HPLC will need the development of several important constituents; the reproducible preparation of high-performance columns, small-volume pumps and gradient systems, and improvement of an injection system. Subjects to be studied are the development of high-performance monolithic silica columns for a variety of separation modes, multidimensional micro LC systems, and optimization of an interface between LC and MS instruments. Large peak capacities realized by highly efficient micro HPLC systems or multidimensional HPLC will greatly contribute to metabolomics studies when coupled with MS instruments.

Pp. 163-190

Query Language

Mike Keith; Merrick Schincariol

In this chapter we have taken a complete tour of the Java Persistence Query Language, looking at the numerous query types and the syntax for each. We covered the history of the language, from its roots in the EJB 2.0 specification to the major enhancements introduced by the Java Persistence API.

In the section on select queries, we explored each query clause and incrementally built up more complex queries as the full syntax was described. We discussed identification variables and path expressions, which are used to navigate through the domain model in query expressions. We also looked at the various conditional expressions supported by the language.

In our discussion of aggregate queries we introduced the additional grouping and filtering clauses that extend select queries. We also demonstrated the various aggregate functions.

In the sections on update and delete queries, we described the full syntax for bulk update and delete statements, the runtime behavior of which was described in the previous chapter.

In the next chapter we switch back to object-relational mapping and cover advanced concepts such as inheritance, composite primary keys and associations, and multiple table mappings.

Pp. 191-219

Advanced Object-Relational Mapping

Mike Keith; Merrick Schincariol

Routine use of micro HPLC will need the development of several important constituents; the reproducible preparation of high-performance columns, small-volume pumps and gradient systems, and improvement of an injection system. Subjects to be studied are the development of high-performance monolithic silica columns for a variety of separation modes, multidimensional micro LC systems, and optimization of an interface between LC and MS instruments. Large peak capacities realized by highly efficient micro HPLC systems or multidimensional HPLC will greatly contribute to metabolomics studies when coupled with MS instruments.

Pp. 221-256

Advanced Topics

Mike Keith; Merrick Schincariol

Routine use of micro HPLC will need the development of several important constituents; the reproducible preparation of high-performance columns, small-volume pumps and gradient systems, and improvement of an injection system. Subjects to be studied are the development of high-performance monolithic silica columns for a variety of separation modes, multidimensional micro LC systems, and optimization of an interface between LC and MS instruments. Large peak capacities realized by highly efficient micro HPLC systems or multidimensional HPLC will greatly contribute to metabolomics studies when coupled with MS instruments.

Pp. 257-297

XML Mapping Files

Mike Keith; Merrick Schincariol

With all of the XML mapping information under your belt, you should now be able to map entities using annotations, XML, or a combination of the two. In this chapter we went over all of the elements in the mapping file and compared them to their corresponding annotations. We discussed how each of the elements is used, what they override, and how they are overridden. We also used them in some short examples.

Defaults may be specified in the mapping files at different levels, from the global persistence unit level to the mapping file level. We covered what each of the defaulting scopes was and how they were applied.

In the next chapter we will look at how to package and deploy applications that use the Java Persistence API. We will also look at how XML mapping files are referenced as part of a persistence unit configuration.

Pp. 299-333