Persistence Service Overview 11.2
media such as files. Irrespective of the underlying storage medium, you must use
an ABAP Dictionaiy object (i.e., a table, view, or structure) as the basis for your
mapping. The following list describes how various ABAP Dictionaiy objects can
be used to help you create your persistence maps:
• Single-table mapping
Most of
the
time, you will map the attributes of your persistent class to a single
ABAP Dictionary table. Here, you must map all of the fields from the table to
attributes in the persistent class. Of course, sometimes you may not want to
map all of the fields of
a
given table to your persistent class. For example, in a
large table with many fields, you might only be interested in a subset of fields
that have certain relevance to a particular usage scenario. In this case, you can
create a view that contains a subset of fields thatyou want to map and then use
the view to build your persistence mapping.
• Multiple-table mapping
It is also possible to map multiple tables onto a single persistent class. The only
requirement here is that each of the tables shares the exact same primaiy key.
At runtime, the Persistence Service is smart enough to connect the relevant
attributes used in the mapping with their associated tables so that the object
data is distributed across each of the tables correctly.
• Structure mappings
For more complex mappings, you can also use structure types. Structure types
are typically used to implement persistence mapping to files, and so on. How-
ever, they can also be used to map persistent classes that have a one-to-many
relationship to another persistent class type (e.g., a sales order and its line
items). Of course, because structure types do not refer to an actual database
table, the ORM tool will not be able to generate the code to persist the data.
Instead, you must implement your own logic for storing the persistent data in
persistent classes mapped from a structure.
11.2.3 Understanding the Class Agent API
After you finalize the persistence mapping for your class, the next step is to acti-
vate your changes in the Class Builder. Here, the Class Builder tool will use the
mapping details to construct the persistence class along with its associated agent
classes. The UML class diagram shown earlier in Figure 11.2 shows the relation-
ships between these classes. It also shows some of the more useful methods that
you can use to obtain and work with objects of your persistent class.
285