A.6. metadata.xml
Files of this type are used for registering custom datatypes and non-persistent entities and assigning meta annotations.
XML schema is available at http://schemas.haulmont.com/cuba/6.10/metadata.xsd.
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 the following attributes:-
id
- identifier, which should be used to refer to this datatype from @MetaProperty annotation. -
class
- defines the implementation class. -
sqlType
- optional attribute which specifies an SQL type of your database suitable for storing values of this data type. The SQL type will be used by CUBA Studio when it generates database scripts. See Example of a Custom Datatype for details.
The
datatype
element can also contain other attributes that depend on the implementation of the 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.The
annotations
element containsentity
elements which define entities to assign meta-annotation to. Eachentity
element must contain theclass
attribute which specifies an entity class, and a list ofannotation
elements.The
annotation
element defines a meta-annotation. It has thename
attribute which corresponds to the meta-annotation name. The map of meta-annotation attributes is defined using the list of nestedattribute
elements.
Example:
<metadata xmlns="http://schemas.haulmont.com/cuba/metadata.xsd">
<metadata-model root-package="com.sample.sales">
<class>com.sample.sales.entity.SomeNonPersistentEntity</class>
<class>com.sample.sales.entity.OtherNonPersistentEntity</class>
</metadata-model>
<annotations>
<entity class="com.haulmont.cuba.security.entity.User">
<annotation name="com.haulmont.cuba.core.entity.annotation.TrackEditScreenHistory">
<attribute name="value" value="true" datatype="boolean"/>
</annotation>
<annotation name="com.haulmont.cuba.core.entity.annotation.EnableRestore">
<attribute name="value" value="true" datatype="boolean"/>
</annotation>
</entity>
<entity class="com.haulmont.cuba.core.entity.Category">
<annotation name="com.haulmont.cuba.core.entity.annotation.SystemLevel">
<attribute name="value" value="false" datatype="boolean"/>
</annotation>
</entity>
</annotations>
</metadata>