Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
db-class-id
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Metadata Extension Reference > db-class-id

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

Sets the class ID and/or defines what the DB class ID column looks like. OpenAccess ORM supports inheritance by using a class ID column in the base class table to specify the type of each row. The default class ID value for each class is a 31–bit hash generated from the fully qualified class name. This extension can be used to specify any positive 32–bit integer (unique within the hierarchy) or select the classname {name} or the fully qualified classname {fullname} as the class ID or use "no" if you do not wish to use a discriminator.

You can use a nested db-column extension to define the column used to store the class ID. The default class ID column has SQL type INTEGER. The class ID column may only be defined in the top-most class in the hierarchy but every class may have a class ID defined for it. The example below defines the class ID column to be a TINYINY (byte) and sets the DB class ID for Item to 1 and CompositeItem to 2. Be sure that the class ID values you choose fit into the column.

Copy Code
<class name="Item">
    <extension key="db-class-id" value="1">
        <extension key="db-column">
            <extension key="db-type" value="TINYINT" />
        </extension>
    </extension>
</class>

<class name="CompositeItem" persistence-capable-superclass="Item">
    <extension key="db-class-id" value="2"/>
</class>