(Created page with "This article only considers Persistence in a SQL database. As such it does not apply to systems that use XmlPersistenceMappers or MDrivenServer (MDrivenServer has the settings...") |
(Automatically adding template at the end of the page.) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
This article only considers Persistence in | This article only considers Persistence in an SQL database. As such, it does not apply to systems that use XmlPersistenceMappers or MDrivenServer (MDrivenServer has the settings described below as default). | ||
In MDriven Framework | In MDriven Framework, much is done by using default values - but, if you want to tune the default values, you can. | ||
Consider this model: | Consider this model: | ||
[[File:01 - Code and Persistence Mapping.png|none|thumb]] | |||
We state that the “TheDefaultSuperClass” should be the Superclass for all other classes in our package by setting the Package. | |||
[[File:02 - Code and Persistence Mapping.png|none|thumb|418x418px]] | |||
We state that the “TheDefaultSuperClass” should be the Superclass for all other classes in our package by setting the Package | |||
We mark the TheDefaultSuperClass as being Abstract (indicated by Italic style on the class name in diagrams). | We mark the TheDefaultSuperClass as being Abstract (indicated by Italic style on the class name in diagrams). | ||
The default is that the DefaultSuperclass will get its own table in the database. | The default is that the DefaultSuperclass will get its own table in the database. That is actually often not what we want to do. | ||
Instead, we want to have the fields from DefaultSuperClass in all inheriting classes' tables. | |||
This is how to do it: | |||
# Add a DefaultORMappingBuilder component to your PMP designer. | |||
# Set the NewMappingProvider (the mapping that is calculated from your current model) to the DefaultORMappingBuilder1. | |||
# Also, set the RunTimeMappingProvider (the mapping that will be used in runtime). | |||
[[File:03 - Code and Persistence Mapping.png|none|thumb|448x448px]] | |||
In the DefaultORMappingBuilder, we can now influence the Mapping in certain ways: | |||
[[File:04 - Code and Persistence Mapping.png|none|thumb|422x422px]] | |||
Above, I said that the DefaultSuperclass for the package (here called RootClass) should be ChildMapped – i.e. its attributes are not stored in a table of its own but rather in each child's table. | |||
* I also choose to change how foreign key fields should be generated – the default is <Name>, but here I append an extra “ID”. | |||
* I also set the Id Column name for each table; the default is “Eco_Id” – but I would rather have it based on the table's name, so I set <TableName>ID. | |||
These two changes from default behavior make the database easier to read for someone just accessing the database – as all Identities that are joinable end with an ID. | |||
For control of an ordinary class’s OR mapping (i.e. the non-DefaultSuperClass), simply set this on the class: | |||
[[File:05 - Code and Persistence Mapping.png|none|thumb|340x340px]] | |||
If you do not see this property on your classes – it is most likely that you need to set the OrMappingConfigMode setting on your Package: | |||
[[File:06 - Code and Persistence Mapping.png|none|thumb|460x460px]] | |||
Having the settings above done, we can now: generate code, build all, switch to PMP view, Press Validate Model, and Press Generate default mapping XML: | |||
[[File:07 - Code and Persistence Mapping.png|none|thumb]] | |||
Once you have generated the default mapping XML you get an XML file appended to the project. | Once you have generated the default mapping XML, you get an XML file appended to the project. | ||
It looks like this: | It looks like this: | ||
<html> | |||
<pre class="code"><span style="font-size: xx-small;"><span style="background: white; color: blue;"><?</span><span style="background: white; color: #a31515;">xml </span><span style="background: white; color: red;">version</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">1.0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">encoding</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">utf-8</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">?> | |||
<</span><span style="background: white; color: #a31515;">ORMapping</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">ClassDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">SuperClass</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">TheDefaultSuperClass</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">AliasDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Table</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">ExtentRequiresDiscriminator</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoKey</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyColumn </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1ID</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">KeyImpl</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Column</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">AliasDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorValue </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Value</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">3</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">ClassDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">ClassDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">SuperClass</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class3</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">AliasDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Table</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">ExtentRequiresDiscriminator</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoKey</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyColumn </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4ID</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">KeyImpl</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Column</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">AliasDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorValue </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Value</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">7</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">ClassDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">ClassDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class3</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">SuperClass</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">TheDefaultSuperClass</span><span style="background: white; color: black;">" </span><span style="background: white; color: blue;">/><span style="background-color: #ffff00;"> <!-- </span></span><span style="background: white; color: green;"><span style="background-color: #ffff00;">NOTICE - EMPTY DUE to being abstract</span></span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;">--></span> | |||
<</span><span style="background: white; color: #a31515;">ClassDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">TheDefaultSuperClass</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoKey</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Signature</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">System.Int32</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsId</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">KeyMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">DefaultEcoIdMapper</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Signature</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">System.Int16</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">ClassDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">ClassDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">SuperClass</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">AliasDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Table</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">ExtentRequiresDiscriminator</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoKey</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">KeyColumn </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2ID</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">KeyImpl</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorImpl </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Column</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">AliasDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">DiscriminatorValue </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">EcoType</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Value</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">13</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">AttributeDef </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Alias</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2_A</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AttributeMapper</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: red;">&lt;</span><span style="background: white; color: blue;">Default</span><span style="background: white; color: red;">&gt;</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">ClassDef</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">Database </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">""</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> <span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;"><!-- </span></span><span style="background: white; color: green;"><span style="background-color: #ffff00;">NOTICE – Missing both Class3 and TheDefaultSuperClass since they are both child mapped and abstract</span></span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;">--></span> </span></span> | |||
<</span><span style="background: white; color: #a31515;">Table </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">INT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span><span style="background: white; color: blue;">/> <span style="background-color: #ffff00;"><!-- </span></span><span style="background: white; color: green;"><span style="background-color: #ffff00;">NOTICE - TableName+ID </span></span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;">--></span> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">SMALLINT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">DATETIME</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">'19000101'</span><span style="background: white; color: black;">" </span><span style="background: white; color: blue;">/> <span style="background-color: #ffff00;"><!-- </span></span><span style="background: white; color: green;"><span style="background-color: #ffff00;">NOTICE - Inherited attributes child mapped </span></span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;">--></span> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">DATETIME</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">'19000101'</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">VARCHAR(255)</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">''</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Index </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">IX_PK_Class1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class1ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsUnique</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsCaseSensitive</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsPrimary</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsDescending</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsFilteredOnNotNull</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">Table</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">Table </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">INT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">SMALLINT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">VARCHAR(255)</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">''</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Index </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">IX_PK_Class2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class2ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsUnique</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsCaseSensitive</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsPrimary</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsDescending</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsFilteredOnNotNull</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">Table</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
<</span><span style="background: white; color: #a31515;">Table </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4</span><span style="background: white; color: black;">"</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> <span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;"><!-- </span></span><span style="background: white; color: green;"><span style="background-color: #ffff00;">NOTICE – attributes from both TheDefaultSuperclass And from Class3</span></span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;"><span style="background-color: #ffff00;">--></span> </span></span> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">INT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ECO_TYPE</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">SMALLINT</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">0</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">VARCHAR(255)</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">''</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">ChangeTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">DATETIME</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">'19000101'</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">CreateTime</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">DATETIME</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">'19000101'</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Column </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Attribute2</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">AllowNULL</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Type</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">VARCHAR(255)</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Length</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">255</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Scale</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Precision</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">-1</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">DefaultValue</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">''</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
<</span><span style="background: white; color: #a31515;">Index </span><span style="background: white; color: red;">Name</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">IX_PK_Class4</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">Columns</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">Class4ID</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsUnique</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsCaseSensitive</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsPrimary</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">True</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsDescending</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span><span style="background: white; color: red;">IsFilteredOnNotNull</span><span style="background: white; color: blue;">=</span><span style="background: white; color: black;">"</span><span style="background: white; color: blue;">False</span><span style="background: white; color: black;">" </span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">/> | |||
</</span><span style="background: white; color: #a31515;">Table</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
</</span><span style="background: white; color: #a31515;">Database</span></span><span style="font-size: xx-small;"><span style="background: white; color: blue;">> | |||
</</span><span style="background: white; color: #a31515;">ORMapping</span><span style="background: white; color: blue;">></span></span></pre> | |||
| |||
</html> | |||
Normally you | Normally, you would not bother generating this file. You would just let MDriven generate it when evolving the database – then MDriven stores this in the database so that it can retrieve it on the next evolve. MDriven uses the old mapping and compares it to a freshly generated mapping in order to deduce all the fine print your model changes inflict on the db-mapping. | ||
[[File:08 - Code and Persistence Mapping.png|none|thumb|392x392px]] | |||
In order to completely de-mystify the Mapping provision: | In order to completely de-mystify the Mapping provision: | ||
* NewMappingProvider shares information on how the mapping should look after evolve db. | |||
NewMappingProvider | * OldMappingProvider gets information on how the mapping looks in your current db. | ||
* RuntimeMappingProvider is the mapping your system uses in runtime when accessing the database. | |||
OldMappingProvider | [[Category:ORMapping]] | ||
{{Edited|July|12|2024}} | |||
RuntimeMappingProvider is the mapping your system |
Latest revision as of 15:50, 10 February 2024
This article only considers Persistence in an SQL database. As such, it does not apply to systems that use XmlPersistenceMappers or MDrivenServer (MDrivenServer has the settings described below as default).
In MDriven Framework, much is done by using default values - but, if you want to tune the default values, you can.
Consider this model:
We state that the “TheDefaultSuperClass” should be the Superclass for all other classes in our package by setting the Package.
We mark the TheDefaultSuperClass as being Abstract (indicated by Italic style on the class name in diagrams).
The default is that the DefaultSuperclass will get its own table in the database. That is actually often not what we want to do.
Instead, we want to have the fields from DefaultSuperClass in all inheriting classes' tables.
This is how to do it:
- Add a DefaultORMappingBuilder component to your PMP designer.
- Set the NewMappingProvider (the mapping that is calculated from your current model) to the DefaultORMappingBuilder1.
- Also, set the RunTimeMappingProvider (the mapping that will be used in runtime).
In the DefaultORMappingBuilder, we can now influence the Mapping in certain ways:
Above, I said that the DefaultSuperclass for the package (here called RootClass) should be ChildMapped – i.e. its attributes are not stored in a table of its own but rather in each child's table.
- I also choose to change how foreign key fields should be generated – the default is <Name>, but here I append an extra “ID”.
- I also set the Id Column name for each table; the default is “Eco_Id” – but I would rather have it based on the table's name, so I set <TableName>ID.
These two changes from default behavior make the database easier to read for someone just accessing the database – as all Identities that are joinable end with an ID.
For control of an ordinary class’s OR mapping (i.e. the non-DefaultSuperClass), simply set this on the class:
If you do not see this property on your classes – it is most likely that you need to set the OrMappingConfigMode setting on your Package:
Having the settings above done, we can now: generate code, build all, switch to PMP view, Press Validate Model, and Press Generate default mapping XML:
Once you have generated the default mapping XML, you get an XML file appended to the project.
It looks like this:
<?xml version="1.0" encoding="utf-8"?> <ORMapping> <ClassDef Name="Class1" SuperClass="TheDefaultSuperClass"> <AliasDef Name="Class1_A" Table="Class1" ExtentRequiresDiscriminator="False"> <KeyImpl Name="EcoKey"> <KeyColumn Name="Class1ID" /> </KeyImpl> <DiscriminatorImpl Name="EcoType" Column="ECO_TYPE" /> </AliasDef> <DiscriminatorValue Name="EcoType" Value="3" /> <AttributeDef Name="ChangeTime" Alias="Class1_A" Columns="ChangeTime" AttributeMapper="<Default>" /> <AttributeDef Name="CreateTime" Alias="Class1_A" Columns="CreateTime" AttributeMapper="<Default>" /> <AttributeDef Name="Attribute1" Alias="Class1_A" Columns="Attribute1" AttributeMapper="<Default>" /> </ClassDef> <ClassDef Name="Class4" SuperClass="Class3"> <AliasDef Name="Class4_A" Table="Class4" ExtentRequiresDiscriminator="False"> <KeyImpl Name="EcoKey"> <KeyColumn Name="Class4ID" /> </KeyImpl> <DiscriminatorImpl Name="EcoType" Column="ECO_TYPE" /> </AliasDef> <DiscriminatorValue Name="EcoType" Value="7" /> <AttributeDef Name="ChangeTime" Alias="Class4_A" Columns="ChangeTime" AttributeMapper="<Default>" /> <AttributeDef Name="CreateTime" Alias="Class4_A" Columns="CreateTime" AttributeMapper="<Default>" /> <AttributeDef Name="Attribute2" Alias="Class4_A" Columns="Attribute2" AttributeMapper="<Default>" /> <AttributeDef Name="Attribute1" Alias="Class4_A" Columns="Attribute1" AttributeMapper="<Default>" /> </ClassDef> <ClassDef Name="Class3" SuperClass="TheDefaultSuperClass" /> <!-- NOTICE - EMPTY DUE to being abstract--> <ClassDef Name="TheDefaultSuperClass"> <KeyDef Name="EcoKey" Signature="System.Int32" IsId="True" KeyMapper="DefaultEcoIdMapper" /> <DiscriminatorDef Name="EcoType" Signature="System.Int16" /> </ClassDef> <ClassDef Name="Class2" SuperClass="Class1"> <AliasDef Name="Class2_A" Table="Class2" ExtentRequiresDiscriminator="False"> <KeyImpl Name="EcoKey"> <KeyColumn Name="Class2ID" /> </KeyImpl> <DiscriminatorImpl Name="EcoType" Column="ECO_TYPE" /> </AliasDef> <DiscriminatorValue Name="EcoType" Value="13" /> <AttributeDef Name="Attribute2" Alias="Class2_A" Columns="Attribute2" AttributeMapper="<Default>" /> </ClassDef> <Database Name=""> <!-- NOTICE – Missing both Class3 and TheDefaultSuperClass since they are both child mapped and abstract--> <Table Name="Class1"> <Column Name="Class1ID" AllowNULL="False" Type="INT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <!-- NOTICE - TableName+ID --> <Column Name="ECO_TYPE" AllowNULL="False" Type="SMALLINT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <Column Name="ChangeTime" AllowNULL="False" Type="DATETIME" Length="255" Scale="-1" Precision="-1" DefaultValue="'19000101'" /> <!-- NOTICE - Inherited attributes child mapped --> <Column Name="CreateTime" AllowNULL="False" Type="DATETIME" Length="255" Scale="-1" Precision="-1" DefaultValue="'19000101'" /> <Column Name="Attribute1" AllowNULL="True" Type="VARCHAR(255)" Length="255" Scale="-1" Precision="-1" DefaultValue="''" /> <Index Name="IX_PK_Class1" Columns="Class1ID" IsUnique="False" IsCaseSensitive="False" IsPrimary="True" IsDescending="False" IsFilteredOnNotNull="False" /> </Table> <Table Name="Class2"> <Column Name="Class2ID" AllowNULL="False" Type="INT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <Column Name="ECO_TYPE" AllowNULL="False" Type="SMALLINT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <Column Name="Attribute2" AllowNULL="True" Type="VARCHAR(255)" Length="255" Scale="-1" Precision="-1" DefaultValue="''" /> <Index Name="IX_PK_Class2" Columns="Class2ID" IsUnique="False" IsCaseSensitive="False" IsPrimary="True" IsDescending="False" IsFilteredOnNotNull="False" /> </Table> <Table Name="Class4"> <!-- NOTICE – attributes from both TheDefaultSuperclass And from Class3--> <Column Name="Class4ID" AllowNULL="False" Type="INT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <Column Name="ECO_TYPE" AllowNULL="False" Type="SMALLINT" Length="0" Scale="0" Precision="0" DefaultValue="" /> <Column Name="Attribute1" AllowNULL="True" Type="VARCHAR(255)" Length="255" Scale="-1" Precision="-1" DefaultValue="''" /> <Column Name="ChangeTime" AllowNULL="False" Type="DATETIME" Length="255" Scale="-1" Precision="-1" DefaultValue="'19000101'" /> <Column Name="CreateTime" AllowNULL="False" Type="DATETIME" Length="255" Scale="-1" Precision="-1" DefaultValue="'19000101'" /> <Column Name="Attribute2" AllowNULL="True" Type="VARCHAR(255)" Length="255" Scale="-1" Precision="-1" DefaultValue="''" /> <Index Name="IX_PK_Class4" Columns="Class4ID" IsUnique="False" IsCaseSensitive="False" IsPrimary="True" IsDescending="False" IsFilteredOnNotNull="False" /> </Table> </Database> </ORMapping>
Normally, you would not bother generating this file. You would just let MDriven generate it when evolving the database – then MDriven stores this in the database so that it can retrieve it on the next evolve. MDriven uses the old mapping and compares it to a freshly generated mapping in order to deduce all the fine print your model changes inflict on the db-mapping.
In order to completely de-mystify the Mapping provision:
- NewMappingProvider shares information on how the mapping should look after evolve db.
- OldMappingProvider gets information on how the mapping looks in your current db.
- RuntimeMappingProvider is the mapping your system uses in runtime when accessing the database.