Hibernate mapping files used with MD4J must satisfy a set of requirements:

  • Each file must describe only one (sub) class.
  • All files must belong to the same Java package.
  • All files must be in the same directory on the filesystem.
  • POJO properties must not use primitive types (for example you should use integer instead of int).
  • The class attribute is mandatory for many-to-many elements and the corresponding value must be the name of the associated class.
  • All id and property elements must have a valid type attribute.


MD4J looks out for metadata in your input files (see metadata reference) and uses that to customize it's output based on your directions. Using MD4J metadata in Hibernate mappings is rather straightforward, for example you can use the md4j:render-as-image flag to render a property as an img tag in JSP (or whatnot) views:
        <property name="logo" type="string"  not-null="false">
            <meta attribute="md4j:render-as-image">true</meta>