Hibernate as JPA Provider

Hibernate is an object-relational (OR) mapping tool, which enables mapping Java classes to tables over several types of relational databases (for example, Oracle and Microsoft SQL Server). For details, see Functional Limitations.

In an elementary mapping, each Java class is mapped to a single table. More advanced mapping enables inheritance mapping (as can occur in the CMDB database).

Other supported features include mapping a class to several tables, support for collections, and associations of types one-to-one, one-to-many, and many-to-one. For details, see Associations below.

For our purposes, there is no need to create Java classes. The mapping is defined from the CMDB class model CITs to the database tables.

This section also includes the following topics:

Examples of Object-Relational Mapping

The following examples describe object-relational mapping:

Example of One CMDB Class Mapped to One Database Table:

Class M1, with attributes A1, A2, and A3, is mapped to table 1 columns c1, c2, and c3. This means that any M1 instance has a matching row in table 1.

Example of One CMDB Class Mapped to Two Database Tables:

Example of Inheritance:

This case is used in the CMDB, where each class has its own database table.

Example of Single Table Inheritance with Discriminator:

An entire hierarchy of classes is mapped to a single database table, whose columns comprise a super-set of all attributes of the mapped classes. The table also contains an additional column (Discriminator), whose value indicates which specific class should be mapped to this entry.

Associations

There are three types of associations: one-to-many, many-to-one and many-to-many. To connect between the different database objects, one of these associations must be defined by using a foreign key column (for the one-to-many case) or a mapping table (for the many-to-many case).

Usability

As the JPA schema is very extensive, a streamlined XML file is provided to make it easier to define associations.

The use case for using this XML file is as follows: Federated data is modeled into one federated class. This class has many-to-one relations to a non-federated CMDB class. In addition, there is only one possible relation type between the federated class and the non-federated class.