A.5. metadata.xml

Files of this type are used for registering custom datatypes and non-persistent entities and assigning meta annotations.

The metadata.xml file of the project is specified in the cuba.metadataConfig application property.

The file has the following structure:

metadata – root element.

metadata elements:

  • datatypes - an optional descriptor of custom datatypes.

    datatypes elements:

    • datatype - the datatype descriptor. It has one mandatory attribute: class, which defines the implementation class. Other attributes are optional and depend on the implementation. See Example of a Custom Datatype.

  • metadata-model – the project’s meta model descriptor.

    metadata-model attribute:

    • root-package – the project’s root package.

      metadata-model elements:

    • class – a non-persistent entity class.

  • annotations – contains assignments of entity meta annotations.

    annotations elements:

    • entity – entity to assign meta annotation to.

      entity attributes:

      • class – entity class.

        entity elements:

      • annotation – meta annotation element.

        annotation attributes:

        • name – meta annotation name.

        • value – meta annotation value.

Example:

<metadata xmlns="http://schemas.haulmont.com/cuba/metadata.xsd">

  <metadata-model root-package="com.sample.sales">
      <class>com.sample.sales.entity.SomeTransientEntity</class>
      <class>com.sample.sales.entity.OtherTransientEntity</class>
  </metadata-model>

  <annotations>
      <entity class="com.haulmont.cuba.security.entity.User">
          <annotation name="com.haulmont.cuba.core.entity.annotation.TrackEditScreenHistory"
                      value="true"/>
          <annotation name="com.haulmont.cuba.core.entity.annotation.EnableRestore"
                      value="true"/>
      </entity>
  </annotations>

</metadata>