52.4k views
0 votes
What is the difference between a mapped (hbm) and annotation driven class in Hibernate?

A) A mapped class is defined in an XML file, while an annotation driven class is defined in Java code.
B) A mapped class is used for one-to-one relationships, while an annotation driven class is used for many-to-many relationships.
C) A mapped class is used for persistent classes, while an annotation driven class is used for transient classes.
D) A mapped class is used for unidirectional relationships, while an annotation driven class is used for bidirectional relationships.

User Svachalek
by
8.9k points

1 Answer

3 votes

Final answer:

The difference between a mapped (hbm) class and an annotation-driven class in Hibernate is that the former is configured through XML files, while the latter uses Java annotations(option A).

Step-by-step explanation:

The difference between a mapped (hbm) class and an annotation-driven class in Hibernate is how they are defined and used to configure the object-relational mapping. Option A) A mapped class is defined in an XML file, while an annotation-driven class is defined in Java code, is correct. In Hibernate, XML mapping files (hbm files) are the traditional way of configuring mappings between entity classes and database tables.

On the other hand, Hibernate annotations are a more recent and often preferred approach as they keep the configuration closer to the code and make it more readable. Neither of these methods are restricted to certain types of relationships, as is suggested by options B and D, or the nature of the class's persistence as suggested by option C.

HEnce, the answer is option A.

User FirasKoubaa
by
7.3k points