Providing an XML-based hibernate mapping

In the preceding recipe, you learned how to create a POJO. Now we will consider how to create the configuration for hibernate. There are multiple ways of mapping, and this is one of them.

Generally, the configuration provides the following information:

  • The mapping between the POJO and the database table
  • The mapping between the POJO property and the database table column
  • The definition of the primary key column
  • The definitions of the foreign key column and relationships such as one-to-one, one-to-many, many-to-one, many-to-many with another table, and so on
  • Constraints such as not-null, formula, lazy, cascade, and so on
  • The definitions of the length, the data type of the column, the formula, and so on

How to do ...

Get Java Hibernate Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.