Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Influence DB Store mapping by using annotations"

Line 1: Line 1:
This feature is implemented in current CVS Head for the CDO 3.0 release.<br>
+
If using the CDO DBStore the mapping of the EMF/CDO model to the database backend can be influenced by several Ecore annotations to the model. Just add the below EAnnotation's to the appropriate classes/features.
<br>
+
 
When using the DB Store the mapping of the EMF/CDO model to the database backend can be influenced by several annotations. Just add the below EAnnotation's to the appropriate classes/features.<br>
+
This feature is implemented in current CVS HEAD for the CDO 3.0 release.
  
 
= Class Annotations =
 
= Class Annotations =
 
The following annotations are meaningful in the context of EClasses.
 
The following annotations are meaningful in the context of EClasses.
 
<pre>
 
<pre>
<eStructuralFeatures xsi:type="ecore:EAttribute" ...>
+
<eClassifiers xsi:type="ecore:EClass" ...>
 
     <eAnnotations source="http://www.eclipse.org/CDO/DBStore">
 
     <eAnnotations source="http://www.eclipse.org/CDO/DBStore">
 
         ...
 
         ...
 
     </eAnnotations>
 
     </eAnnotations>
</eStructuralFeatures>
+
</eClassifiers>
 
</pre>
 
</pre>
  
Line 31: Line 31:
  
 
= Feature Annotations =
 
= Feature Annotations =
The following annotations are meaningful in the context of EStructuralFeatures
+
The following annotations are meaningful in the context of EStructuralFeatures.
== ColumnLength ==
+
The length of the data.<br>
+
Can be used for example to provide the length for a VARCHAR that was mapped from an EString feature.
+
 
<pre>
 
<pre>
<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
+
<eStructuralFeatures xsi:type="ecore:EAttribute" ...>
     <details key="columnLength" value="256"/>
+
    <eAnnotations source="http://www.eclipse.org/CDO/DBStore">
</eAnnotations>
+
        ...
 +
     </eAnnotations>
 +
</eStructuralFeatures>
 
</pre>
 
</pre>
  
Line 55: Line 54:
 
<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
 
<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
 
     <details key="columnType" value="CLOB"/>
 
     <details key="columnType" value="CLOB"/>
 +
</eAnnotations>
 +
</pre>
 +
 +
== ColumnLength ==
 +
The length of the data.<br>
 +
Can be used for example to provide the length for a VARCHAR that was mapped from an EString feature.
 +
<pre>
 +
<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
 +
    <details key="columnLength" value="256"/>
 
</eAnnotations>
 
</eAnnotations>
 
</pre>
 
</pre>

Revision as of 01:28, 14 August 2009

If using the CDO DBStore the mapping of the EMF/CDO model to the database backend can be influenced by several Ecore annotations to the model. Just add the below EAnnotation's to the appropriate classes/features.

This feature is implemented in current CVS HEAD for the CDO 3.0 release.

Class Annotations

The following annotations are meaningful in the context of EClasses.

<eClassifiers xsi:type="ecore:EClass" ...>
    <eAnnotations source="http://www.eclipse.org/CDO/DBStore">
        ...
    </eAnnotations>
</eClassifiers>

TableName

A class annotation for naming it's table.

<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
    <details key="tableName" value="MY_TABLE_NAME"/>
</eAnnotations>

TableMapping

Exclude a class from persistence.
Sometimes you may have classes in your model that are not intended to be persisted. Without the below annotation CDO would create an empty table also for those classes, but with that annotation those classes are simply ignored.

<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
    <details key="tableMapping" value="NONE"/>
</eAnnotations>

Feature Annotations

The following annotations are meaningful in the context of EStructuralFeatures.

<eStructuralFeatures xsi:type="ecore:EAttribute" ...>
    <eAnnotations source="http://www.eclipse.org/CDO/DBStore">
        ...
    </eAnnotations>
</eStructuralFeatures>

ColumnName

The feature annotation for naming it's column.

<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
    <details key="columnName" value="MY_COLUMN_NAME"/>
</eAnnotations>

ColumnType

The type to be used for storing the feature in the database.
This can be used for example to store a feature of type EString in a Clob column.

<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
    <details key="columnType" value="CLOB"/>
</eAnnotations>

ColumnLength

The length of the data.
Can be used for example to provide the length for a VARCHAR that was mapped from an EString feature.

<eAnnotations source="http://www.eclipse.org/CDO/DBStore">
    <details key="columnLength" value="256"/>
</eAnnotations>

Back to the top