There are four different mapping mechanisms in EntityDAC. Their principal differences are: which classes constitute the object model, and how the process of meta-model creation and its association with the object model is implemented.
Code Mapped Entities
The object model consists of a set of entities (TEntity class descendants). The meta-model is previously generated as a set of meta-data classes in a separate unit. Mapping is hard-coded in the entity classes implementation.
Benefits of this type of mapping are:
-
using entities in the object model eliminates the need to keep track of their life cycle, because it is engaged in the data context;
-
the meta-model is available at the development stage, that is most clear to the developer;
-
mapping is previously hard-coded, that is the best from the performance point.
Disadvantages:
-
making changes in the object model becomes more complicated, since changing / adding entities' properties requires corresponding changes in the meta-data unit.
Attribute-mapped entities
Object model consists of a set of entities (TEntity class descendants), marked with special mapping attributes. A separate meta-model unit is not used. Instead, the meta-model and mapping are generated dynamically at run-time, based on mapping attributes.
Benefits:
-
entity mapping is implemented directly in the entity declaration, which eliminates the need to refer to a separate unit to find out the mapping features;
-
easier code maintenance, because there is no need to make parallel changes in several units.
Disadvantages:
-
entity classes declaration is some complicated with additional attributes;
-
the meta-mode and mapping generation take place when the application starts, it takes some time.
XML-mapped entities
Object model consists of a set of entities (TEntity class descendants). A separate meta-model unit is not used. The meta-model and mapping are defined in an external XML-file (for example, an Entity Developer project file).
Benefits:
-
the meta-model is available at design-time, which makes possible to open and set up datasets during the application design;
-
it is possible to make some mapping changes with no need to re-compile the application.
Disadvantages:
-
the meta-mode and mapping generation take place when the application starts, it takes some time;
-
the XML-file containing the meta-model is somewhat difficult to understand.
Attribute-mapped objects
The same as "Attribute-mapped entities" mapping, except that the object model does not consist of TEntity, but of TObject descendants.
Benefits:
-
it is possible to mark any existing classes with mapping attributes and use them in EntityDAC.
Disadvantages:
-
in EntityDAC, working with classes, that are not TEntity descendants, is more difficult.