Multiple choice technology programming languages

How can the mapping files be configured in Hibernate?

  1. Mapping files can be added to Configuration in the application code

  2. They can be configured in hibernate.cfg.xml using the <mapping> elements

  3. Both a and b

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Hibernate mapping files can be configured both programmatically by adding them to the Configuration object in application code, and declaratively by using elements in hibernate.cfg.xml. Both approaches are valid and can be used together, giving developers flexibility in their configuration approach.

AI explanation

Correct answer: Both a and b. Hibernate mapping metadata can be supplied in two equivalent ways: programmatically, by adding mapping resources to the Configuration object in application code (e.g., configuration.addResource(...) or addClass(...)), or declaratively, by listing (or) elements inside hibernate.cfg.xml. Since both mechanisms are valid and commonly combined, 'Both a and b' is correct and 'None of the above' is wrong.