Search code examples
hibernatenhibernate-mapping

Hibernate 6 mapping without annotations


Up to Hibernate 5 the class mapping can be defined either by using JPA annotations or with an XML file. The XML file is convenient because it isn't tied to the class, which means it's possible to:

  1. map a class even if you don't have the source code
  2. map a class differently depending on the context (a class may be mapped one way on the server, and another way on the client)

Hibernate 6 removed the XML mapping. Is there an alternative method to define a mapping without adding annotations to the persisted classes?


Solution

  • We now recommend the use of the standard JPA ORM mapping format, which is orm.xml.

    For Hibernate-specific extensions to the orm.xml format you can find mapping-3.1.0.xsd here:

    https://hibernate.org/xsd/orm/mapping/mapping-3.1.0.xsd

    I guess this is what you're looking for.