Persistence Service Overview 11.2
If you are working with small entity objects, the effort involved in manually
building a persistence layer into your classes is probably not that big of
a
deal. On
the other hand, as the data model gets larger and more complex, the mapping
process becomes much more tedious, and many ABAP developers are tempted to
cut corners.
For example, consider an object model that is designed to encapsulate a transac-
tional document such as a sales order that has header and line item details stored
in ABAP Dictionaiy tables. Ideally, you would want to use composition tech-
niques to create an object model that has a sales order header object that maintains
a collection of sales order line item objects. However, after implementing all of the
code to map the sales order header table onto the header class, a developer may
decide to forego this same development effort at the line item level. Here, the
developer may prefer to store the line item details inside an internal table
attribute whose line type is already directly compatible with a line item table que-
ried with the
SELECT
statement. In this case, the effectiveness of the object model
begins to break down as more and more procedural elements creep into the
design.
To bridge the gap between object and persistence data models, SAP introduced
the Persistence Service as part of the ABAP Object Services framework. The Persis-
tence Service is a software layer designed to make it easier to work with persis-
tent objects. As you can see in Figure 11.1, the Persistence Service provides a
layer of abstraction between a persistent object and the underlying data store.
There is nothing fundamentally different between a persistent class and a normal
ABAP Objects class. In other words, instances of persistent classes are still tran-
sient in nature. However, when managed by the Persistence Service, these tran-
sient objects behave like persistent objects within an ABAP program. For example,
as you can see in Figure 11.1, the Persistence Service is extracting data from the
underlying AS ABAP database and initializing the persistent object on behalf of an
ABAP program. Similarly, the Persistence Service is brokering the persistence of
changes made to those objects from within the program. You will learn more
about the relationship between a persistent object and the Persistence Service in
the upcoming sections.
281