HIBERNATE - Getting Started With Hibernate

Mapping POJO with persistence layer using hibernate mapping document

Each persistent class needs to be mapped with its configuration file. Following code represents Hibernate mapping file for AppLabsUser class.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
  <class name="org.applabs.hibernate.quickstart.AppLabsUser" table="applabsuser">

    <id column="USER_ID" name="id" type="java.lang.Long">
      <generator class="sequence"/>
<property column="USER_NAME" length="255" name="userName" not-null="true" type="java.lang.String"/>
<property column="USER_PASSWORD" length="255" name="userPassword" not-null="true" type="java.lang.String"/>
<property column="USER_FIRST_NAME" length="255" name="userFirstName" type="java.lang.String"/>
<property column="USER_LAST_NAME" length="255" name="userLastName" type="java.lang.String"/>

<property column="USER_EMAIL" length="255" name="userEmail" type="java.lang.String"/>
<property column="USER_CREATION_DATE" length="10" name="userCreationDate" type="java.util.Date"/>
<property column="USER_MODIFICATION_DATE" length="10" name="userModificationDate" type="java.util.Date"/>


One can also generate Hibernate mapping documents using Hibernate extension toolset. Hibernate mapping documents are straight forward. The <class> element maps a table with corresponding class. The <id> element represents the primary key column, and its associated attribute in the domain object. The <property> elements represent all other attributes available in the domain object.

Hibernate tutorial
Introduction to Hibernate
Overview of Hibernate
Features of Hibernate
Getting Started with Hibernate
Prepare Database
Create Persistent Java Objects
Mapping POJO With Persistence Layer Using Hibernate Mapping Document
Hibernate Configuration File
Hibernate Sample Code (Inserting new record)
Hibernate Sample Code (Quering the database)
Hibernate O/R Mapping
Hibernate Mapping In Depth
Hibernate Query language
Hibernate Complete Example

Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions