|
When you are using an RDBMS datastore you need to specify how your class will map on to the relational
datastore. This part is termed
Object-Relational Mapping
. This is not required for other
types of datastore.
When you are persisting to RDBMS datastores you are mapping a series of objects into a series of
datastore
tables
in a
schema
. These
tables
are interrelated using
foreign-keys
. With JDO2 you can define fully this object-relational mapping in the MetaData
(or in annotations if you so wish).
The design of the persistence layer of an application requiring object-relational mapping can be approached in 3 ways.
-
Forward Mapping
- Here you have a set of model classes, and want to design the datastore schema
that will store represent these classes.
-
Reverse Mapping
- Here you have an existing datastore schema, and want to design your model
classes to represent this schema.
-
Meet in the Middle Mapping
- Here you have a set of model classes and you have an existing
datastore schema, and you want to match them up.
DataNucleus can be used in all of these modes, though provides significant assistance for
Forward Mapping
cases.
In particular, when using this mode you can use the
DataNucleus SchemaTool
to generate
the datastore schema, based on a set of input classes and MetaData files. It should be noted though that
DataNucleus SchemaTool
also provides modes of operation for updating an existing schema, and hence can also
be used for
Meet in the Middle Mapping
. Additionally, it can be used as a validation mechanism when designing
your system in
Reverse Mapping
mode, where it will inform you of inconsistencies between your classes
and your datastore schema.
|
|