An ORM tool transfers objects between java and database
An object has three elements those are
Identity of an object is nothing but name of an object.
State of an object is nothing but the values assigned for the properties of an object
Behavior of an object is nothing but the methods, which are used to read or write state of an object or modify state of an object.
Mapping tells hibernate that what database table and what columns of the table should be used to persist or store the state of an object
The mapping can be written in two ways 1. By creating an XML file
2. By using annotations
In hibernate, while creation of a mapping file hibernate is recommended to add extension ad .hbm.xml. We can also put extension of mapping file as .xml, but it is not easy to recognize the file as a mapping file.
<hibernate-mapping>
<class name="Empployee" table="Emp">
<id name="no" column="EID"/> <!-- singular Identity field cfg -->
<proerty name="fname" column="FIRSTNAME"/>
<property name="lname" column="LASTNAME"/>
<property name="mail" column="EMAIL"/>
</class>
</hibernate-mapping>
Important points(hibernate mapping file):
1. <id> tag is mandatory
If a table does not have a <id> tag then hibernate works while inserting, but hibernate fails while selecting.
2. Class name and table attributes are same value then table is optional
3. Property name and column attributes are same value then column is optional
Hibernate Examples Project Github Link : https://github.com/SadaLearningHub1/H...