CodesJava

Easy learning with example program codes

Hibernate mapping file


Hibernate mapping file is used by hibernate framework to get the information about the mapping of a POJO class and a database table.

It mainly contains the following mapping information:

  1. Mapping information of a POJO class name to a database table name.
  2. Mapping information of POJO class properties to database table columns.

Elements of the Hibernate mapping file:

  1. hibernate-mapping: It is the root element.
  2. Class: It defines the mapping of a POJO class to a database table.
  3. Id: It defines the unique key attribute or primary key of the table.
  4. generator: It is the sub element of the id element. It is used to automatically generate the id.
  5. property: It is used to define the mapping of a POJO class property to database table column.

Syntax:

<hibernate-mapping>
 
 <class name="POJO class name" table="table name in database">
  <id name="propertyName" column="columnName" type="propertyType" >
	<generator class="generatorClass"/>
  </id>
  <property name="propertyName1" column="colName1" type="propertyType " />
  <property name="propertyName2" column="colName2" type="propertyType " />
  ….
 </class>
 
</hibernate-mapping>

 
Next Topic: Hibernate transaction management with example.
Previous Topic: Object states in Hibernate with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.

 



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki