<Sequence> Element

Sets the identity strategy of the enclosing element to use sequences of the underlying relational database system.

To define a named sequence for later use:

<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
...

       <Sequencename="client-side-name" [dbName="server-side-name"] />

...
</Mapping>

To define a sequence for use in a PersistentField:

<PersistentField [fieldName="fieldName"]>

       <Sequence [name="client-side-name"] [dbName="server-side-name"] />

</PersistentField>

To re-use a sequence that has already been defined:

<PersistentField [fieldName="fieldName"]>

       <Sequenceref="client-side-name-reference"/>

</PersistentField>

client-side-name: A unique name of the sequence. This is used for sequence references, to identify the sequence to be reused. If client-side-name is not specified, Genome generates a name automatically from the type and the member name.

server-side-name: The name of the sequence to be generated in the underlying relational database system. If server-side-name is not specified, the client-side-name is used to refer to the sequence in the database.

client-side-name-reference: A reference to a sequence defined elsewhere in the mapping files. The value has to be a client-side-name defined for an other sequence.

Remarks

·    The mapped property must be of a numeric type.

·    This mapping feature can only be applied to read only properties (i.e. can only have a getter).

Examples

Define and use an unnamed sequence:

<Type name="Animal">

  …

  <PrimaryKey>

    <Key>Id</Key>

  </PrimaryKey>

 

  <Member name="Id">

    <PersistentField>

      <Sequence/>

    </PersistentField>

  </Member>

  …

</Type>

Define and use an unnamed sequence, specifying the sequence name to be used in the database:

<Type name="Animal">

  …

  <PrimaryKey>

    <Key>Id</Key>

  </PrimaryKey>

 

  <Member name="Id">

    <PersistentField>

      <Sequence dbName="SEQ_ANIM" />

    </PersistentField>

  </Member>

  …

</Type>

                   

Define a named sequence and reuse it for different classes:

<Mapping>

  …

  <Sequence name="ZooSequence" dbName="SEQ_ZOO"/>

  …

  <Type name="Animal">

    …

    <PrimaryKey>

      <Key>Id</Key>

    </PrimaryKey>

 

    <Member name="Id">

      <PersistentField>

        <Sequence ref="ZooSequence"/>

      </PersistentField>

    </Member>

    …

  </Type>

 

  <Type name="Cage">

    …

    <PrimaryKey>

      <Key>Id</Key>

    </PrimaryKey>

 

    <Member name="Id">

      <PersistentField>

        <Sequence ref="ZooSequence"/>

      </PersistentField>

    </Member>

    …

  </Type>

  …

</Mapping>

Requirements

Editions:Professional, Evaluation

Database Platforms:Oracle 9i Release 2, Oracle 10g Release 2

See Also

<PersistentField> Element | Object Identity Generation Strategies



<AutoIncrement> Element <NativeIdGenerator> Element