Hibernate Mapping is a system utilized to educate ORM device about recognizable proof of POJO classes put away in tables. Mapping is a procedure to outline a POJO class name and table name furthermore to delineate class variables and the table segment names.
Hibernate Mapping is Metadata, not an information. Thus, from the mapping documents, hibernate peruses the information and stores in the Database. Each ORM needs the mapping data. Hibernate can store the condition of Object in the Database.
Conceptual
Figure
All POJO class Objects will map to the Hibernate. Then Hibernate takes the data from POJO class and then maps into a table.
Conceptual
figure
Really our POJO class object having 3 states like. Transient state, Persistent state, Detached state. At whatever point an object of a pojo class is made then it will be in the Transient state, When the object is in a Transient state it doesn't speak to any row of the database, i mean not connected with any Session object, in the event that we talk more we can say no connection with the database its only a typical item. In the event that we change the information of a pojo class object, when it is in transient state then it doesn't impact on the database table, When the item is in persistent state, then it speak to one row of the database, if the object is in persistent state then it is connected with the unique Session.
Hibernate Mapping using XML file
Description
Hibernate maps Pojo class name to Table. If Class name and Table name are same, writing XML in table name is optional and if Variable name and Table Column name are same mapping file Column name is Optional. All XML files are extended to . Xml but, in hibernate mapping, the file name is extended to Xxx .hbm.xml. Following is the syntax of writing a mapping file in Hibernate.
Classname.hbm.xml
[java]
<div class="crayon-line" id="crayon-575c2fd7819be894077258-1">
<hibernate-mapping>
<class name="POJO class name" table="table name in database">
<id name="variable name" column="column name in database" type="java/hibernate type" />
<property name="variable1 name" column="column name in database" type="java/hibernate type" />
<property name="variable2 name" column="column name in database" type="java/hibernate type" />
</class>
</hibernate-mapping>
[/java]
On constructing a mapping file in Hibernate, multiple Pojo classes are obtained.All classes are mapped in one Mapping file.
Mapping file is like back bone to hibernate ORM tool.
Property tag represents a Non-Primary Column.
Mapping for hibernate may be in the form annotation or XML.
Summary
Key Points
Hibernate may have more mapping files.
Hibernate application needs mapping file and configuration file.
Java class property will be mapped to column in data base by using the property tag.