The discriminator.properties File

This file maps each supported CI type (that is also used as a discriminator value in orm.xml) to a comma-separated list of possible corresponding values of the discriminator column, or a condition to match possible values of the discriminator column.

If a condition is used, use the syntax: like(condition), where condition is a string that can contain the following wildcards:

  • % (percent sign) - allows you to match any string of any length (including a zero length string)

  • _ (underscore) - allows you to match a single character

For example, like(%unix%) will match unix, linux, unix-aix, and so on. Like conditions may only be applied to string columns.

You can also have a single discriminator value mapped to any value that does not belong to another discriminator by stating 'all-other'.

If the adapter you are creating uses discriminator capabilities, you must define all the discriminator values in the discriminator.properties file.

Example of Discriminator Mapping:

For example, the adapter supports the CI types node, nt, and unix, and the database contains a single table named t_nodes that contains a column called type. If the type is 10001, the row represents a node; if the type is 10004, it represents a unix machine, and so on. The discriminator.properties file might look like this:

node=10001, 10005
nt=10002,10003
unix=2%
mainframe=all-other 

The orm.xml file includes the following code:

    <entity class="generic_db_adapter.node" >
        <table name="t_nodes" />
        ...
        <inheritance strategy="SINGLE_TABLE" />
        <discriminator-value>node</discriminator-value>
        <discriminator-column name="type" />
        ...
    </entity>
    <entity class="generic_db_adapter.nt" name="nt">
        <discriminator-value>nt</discriminator-value>
        <attributes>
    </entity>
    <entity class="generic_db_adapter.unix" name="unix">
        <discriminator-value>unix</discriminator-value>
        <attributes>
    </entity>

The discriminator_column attribute is then calculated as follows:

  • If type contains 10002 or 10003 for a certain entry, the entry is mapped to the nt CIT.

  • If type contains 10001 or 10005 for a certain entry, the entry is mapped to the node CIT.

  • If type starts with 2 for a certain entry, the entry is mapped to the unix CIT.

  • Any other value in the type column is mapped to the mainframe CIT.

    Note The node CIT is also the parent of nt and unix.

Parent topic: Adapter Configuration Files