The Persistence Manager


The persistence manager is the building block in the architecture of Enterprise JavaBeans that enables the automatic persistence of particular components. It was introduced with version 2.0 of the EJB specification to achieve a better separation of the physical data storage from the object model. The goal was to improve the portability of persistent EJB components to application servers of other manufacturers. Moreover, improvements were introduced for the mapping of a persistent component onto the storage medium, as well as the possibility of constructing declarative relations between persistent components and an abstract query language. In version 1.1 one was often forced, in the situation of automatic container-governed persistence, to rely on the use of proprietary tools (object-relational "OR" mapping tools) or the use of proprietary extensions of the EJB container, with the result that the portability of the components was greatly compromised.

As always, persistence is managed by the EJB container; that is, it determines when the data of a component are loaded or stored. The EJB container also determines whether in the case of an action's failure a successfully executed saving operation should be undone (transaction). The persistence manager, on the other hand, is responsible for where and how the persistent data are stored. It takes over communication with the storage medium (for example, a database). The mapping of the persistent data of an Enterprise Bean onto the storage medium (for example, the mapping onto one or more database tables) is determined at the installation of a component. The persistence manager plays no role when the Enterprise Bean itself looks after persistence or when the components possess no persistent data.

In most cases a database is used for storing data. In spite of the ANSI SQL standard the databases of different producers are not one hundred percent compatible with one another. For example, they use different key words in the syntax of their query languages. It is usual that particular database functions that distinguish one database from those of other producers are usable only with proprietary extensions of the standard query language SQL. The persistence manager is supposed to catch these difficulties as well. Depending on the implemented database, a specialized persistence manager can be used that is able to deal with the peculiarities of the database system.

A further responsibility of the persistence manager is the formulation of search queries. With knowledge of the mapping of the data and of the peculiarities of the storage medium in use it can translate abstract search queries into concrete search queries. For the formulation of abstract search queries for finding EJB components the specification of Enterprise JavaBeans offers a query language called EJB-QL (Enterprise JavaBeans Query Language). EJB-QL was introduced in version 2.0 of the EJB specification and is further enhanced in version 2.1.

The persistence manager and the query language EJB-QL are dealt with extensively in Chapter 5.




Enterprise JavaBeans 2.1
Enterprise JavaBeans 2.1
ISBN: 1590590880
EAN: 2147483647
Year: 2006
Pages: 103

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net