What is a hibernate xml mapping document and how does it look like?



What is a hibernate xml mapping document and how does it look like?..

Answer / Devendra Katarya

Hibernate XML Mapping Document (hibernate.xml or mapping file) is used to define the mappings between Java classes and database tables in a Hibernate application. It helps Hibernate to understand the structure of the database and map it with the corresponding Java classes.nnA typical hibernate.xml file contains several sections like configuration, session-factory, mapping, and import. Each section describes different aspects of the application such as connection properties, session factory settings, class mappings, and imported namespaces.nnHere's an example of a simple Hibernate XML Mapping Document:nn<hibernate-configuration>n <session-factory>n <!-- Database connection settings -->n <property name="connection.url">jdbc:mysql://localhost/mydb</property>n <property name="connection.driver_class">com.mysql.jdbc.Driver</property>n <property name="connection.username">username</property>n <property name="connection.password">password</property>nn <!-- Mapping file for entity classes -->n <mapping resource="entity/User.hbm.xml"/>n </session-factory>n</hibernate-configuration>

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Hibernate Interview Questions

Explain about hibernate proxy?

1 Answers  


What is the difference between update and merge?

1 Answers  


What does hql stand for?

1 Answers  


What are the important benefits of using Hibernate Framework?

1 Answers  


What is the difference between hibernate session get() and load() method?

1 Answers  


Is jpa an orm?

1 Answers  


What are different states of an entity bean in hybernate?

1 Answers  


Should all the mapping files of hibernate have .hbm.xml extension to work properly?

1 Answers  


How primary key is created by using hibernate?

1 Answers  


What is the use of entitymanager in hibernate?

1 Answers  


Is hibernate sessionfactory thread safe?

1 Answers  


Is it possible to perform collection mapping with one-to-one and many-to-one?

1 Answers  


Categories