Show TOC

Background documentationPersistence Layer Locate this document in the navigation structure

 

In this section you can find general guidance for using the SAP NetWeaver Composition Environment to implement a persistence layer of Java EE 5 applications:

  • The deployment descriptors are not necessary anymore. The declaration and configuration of Enterprise JavaBeans (EJBs) in the deployment descriptor can be defined directly within the Java code, using the annotations metadata facility (a set of intelligent defaults for the most common cases or configuration by exception)

  • You can replace DAOs (Data Access Objects) with the EJB 3.0 Java Persistence API.

    In EJB 3.0, the Persistence API uses metadata annotations to define persistence and relationship criteria on the lines of object-relational mapping concepts.

  • The business/domain model is implemented using entity beans and you can rely on the direct usage of entity beans to transport values and objects. The entities can be detached (decoupled) with the underlying persistence layer. This advantage makes Data Transfer Objects (DTOs) obsolete.

  • Do not exaggerate the connections of entities by defined relationships.

  • Decide carefully when to use lazy fetching (specification does not require a server to provide it).

    Lazy fetching can improve the application performance dramatically, but unfortunately detached entities do not support lazy fetching. Detaching means that an entity can be passed to a separate application tier (for example, from EJB to Web tier). However, an entity that is outside the persistence context does not have valid references to entity sets (collections, single entities) of lazy relations. To get lazy related entities or collections of a relation tree you have to go back and request the entity that owns the relation and fetch the related entities again in the context of the persistence unit. That feature can influence your application design and has to be considered in an early stage of the design and development.

  • To improve performance, loosely-connected entities with relationships that are not expected to be used so regularly can be loaded by queries.