6.6.0.15.4: Modifying the map document

A map consists of mapping the model attributes and relationships to the schema. The map connects the object model description with the schema description. Once the map is defined, the persistence support for your data store is created during code generation.

XMI vocabulary: Map.mapxmi

After completing the top-down operation, the resulting map may need to be modified to fit existing data or models.

This topic discusses the structure and vocabulary of an XMI map document. The following is a sample XMI code block from the map.mapxmi file that shows the mapping between the BankAccount CMP, and the BANKACCOUNT table.

<ejbrdbmapping:EjbRdbDocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:ejbrdbmapping="ejbrdbmapping.xmi" xmlns:Mapping="Mapping.xmi" xmlns:ejb="ejb.xmi"
xmlns:RDBSchema="RDBSchema.xmi" xmlns:java="java.xmi"
xmi:id="EjbRdbDocumentRoot_1" outputReadOnly="false" topToBottom="true">
<helper xsi:type="ejbrdbmapping:RdbSchemaProperies" xmi:id="RdbSchemaProperies_1" primitivesDocument="DB2UDBNT_V71"/>
<inputs xsi:type="ejb:EJBJar" href="META-INF/ejb-jar.xml#ejb-jar_ID"/>
<outputs xsi:type="RDBSchema:RDBDatabase" href="META-INF/Schema/Schema.dbxmi#TopDownDB_ID"/>
<nested xsi:type="ejbrdbmapping:RDBEjbMapper" xmi:id="RDBEjbMapper_1">
<helper xsi:type="ejbrdbmapping:PrimaryTableStrategy" xmi:id="PrimaryTableStrategy_1">
<table href="META-INF/Schema/Schema.dbxmi#BankAccount"/>
</helper>
<inputs xsi:type="ejb:ContainerManagedEntity" href="META-INF/ejb-jar.xml#BankAccount"/>
<outputs xsi:type="RDBSchema:RDBTable" href="META-INF/Schema/Schema.dbxmi#BankAccount"/>
<nested xmi:id="BankAccount_accountNum---BankAccount_accountNum">
<inputs xsi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#BankAccount_accountNum"/>
<outputs xsi:type="RDBSchema:RDBColumn" href="META-INF/Schema/Schema.dbxmi#RDBColumn_1"/>
<typeMapping href="JavatoDB2UDBNT_V71TypeMaps.xmi#int-INTEGER"/>
</nested>
<nested xmi:id="BankAccount_customerName---BankAccount_customerName">
<helper xsi:type="ejbrdbmapping:EJBConverter" xmi:id="EJBConverter_1">
<targetClass href="java:/java.lang#String"/>
<transformerClass href="java:/com.ibm.vap.converters#VapTrimStringConverter"/>
</helper>
<inputs xsi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#BankAccount_customerName"/>
<outputs xsi:type="RDBSchema:RDBColumn" href="META-INF/Schema/Schema.dbxmi#RDBColumn_2"/>
<typeMapping href="JavatoDB2UDBNT_V71TypeMaps.xmi#String-VARCHAR"/>
</nested>
<nested xmi:id="BankAccount_balance---BankAccount_balance">
<inputs xsi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#BankAccount_balance"/>
<outputs xsi:type="RDBSchema:RDBColumn" href="META-INF/Schema/Schema.dbxmi#RDBColumn_3"/>
<typeMapping href="JavatoDB2UDBNT_V71TypeMaps.xmi#BigDecimal-DECIMAL"/>
</nested>
</nested>
<typeMapping xsi:type="Mapping:MappingRoot" href="JavatoDB2UDBNT_V71TypeMaps.xmi#Java_to_DB2UDBNT_V71_TypeMaps"/>
</ejbrdbmapping:EjbRdbDocumentRoot>

XML element descriptions

helper - defines helper objects that are used to set schema properties, table strategy, and as converters between attribute and column types.

inputs - defines CMP references using an href tag that uses a path statement relative to the META-INF directory.

outputs  - defines database table references using an href tag that uses a path statement relative to the META-INF directory.

nested - defines children mappings for attributes and columns. These mappings use the mapping object to describe the inputs, outputs, and helpers. 

typeMapping - an optional element in the map document.

Adding mappings

The procedure for adding a new mapping is easy if you use the following steps:

  1. Under the nested tag, add a new Mapping object.
    <helper xsi:type="ejbrdbmapping:RdbSchemaProperies" xmi:id="RdbSchemaProperies_1" primitivesDocument="DB2UDBNT_V71"/>
    <inputs xsi:type="ejb:EJBJar" href="META-INF/ejb-jar.xml#ejb-jar_ID"/>
    <outputs xsi:type="RDBSchema:RDBDatabase" href="META-INF/Schema/Schema.dbxmi#TopDownDB_ID"/>
    <nested xsi:type="ejbrdbmapping:RDBEjbMapper" xmi:id="RDBEjbMapper_1">
    <helper xsi:type="ejbrdbmapping:PrimaryTableStrategy" xmi:id="PrimaryTableStrategy_1">
    <table href="META-INF/Schema/Schema.dbxmi#BankAccount"/>
    </helper>
  2. Add the CMPAttribute and RDBColumn references.
     <nested xmi:id="BankAccount_accountNum---BankAccount_accountNum">
    <inputs xsi:type="ejb:CMPAttribute" href="META-INF/ejb-jar.xml#BankAccount_accountNum"/>
    <outputs xsi:type="RDBSchema:RDBColumn" href="META-INF/Schema/Schema.dbxmi#RDBColumn_1"/>
    <typeMapping href="JavatoDB2UDBNT_V71TypeMaps.xmi#int-INTEGER"/>
    </nested>

Make sure all of the id's chosen are unique in the entire document.

Go to previous article: Modifying the schema document Go to next article: Implementing custom finder helpers for CMP entity beans

 

 
Go to previous article: Modifying the schema document Go to next article: Implementing custom finder helpers for CMP entity beans