SchemaExport tool is provided by Hibernate software in the form of org.hibernate.tool.hbm2ddl.SchemaExport predefined class in hibernate3.jar file.

If we activate this tool then it will perform the following actions.

  • First SchemaExport tool will take name and location of hibernate configuration file which we have provided as input parameter.
  • SchemaExport tool will load and parse hibernate configuration file.
  • SchemaExport tool will recognize mapping file configuration in hibernate configuration file then it will load and parse mapping file.
  • As per mapping file details, SchemaExport tool will check whether any table is existed or not in Database.
  • If no table is existed then SchemaExport tool will create new table as per mapping file details.
  • If any table is existed with the name then SChemaExport tool will drop that existed table and creates new table as per mapping file configuration details.

To activate SchemaExport tool manually through command prompt then we have to use the following command on command prompt.

java org.hibernate.tool.hbm2ddl.SchemaExport --config = hibernate.cfg.xml


To run the above command we must copy all hibernate jars to “C:\Java\jdk1.7.0\jre\lib\ext” folder and we must provide POJO class, mapping file and configuration file at the same location from where we are activating SchemaExport tool.


package com.ashok.hibernate.sample.model;

 * @author ashok.mariyala
public class Employee {
	private int id;
	private String empName;
	private String address;
	private double salary;
	public Employee(String empName, String address, double salary) {
		this.empName = empName;
		this.address = address;
		this.salary = salary;

	public int getId() {
		return id;

	public void setId(int id) { = id;

	public String getEmpName() {
		return empName;

	public void setEmpName(String empName) {
		this.empName = empName;

	public String getAddress() {
		return address;

	public void setAddress(String address) {
		this.address = address;

	public double getSalary() {
		return salary;

	public void setSalary(double salary) {
		this.salary = salary;


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"

	<class name="com.ashok.hibernate.sample.model.Employee" table="emp">
		<id name="id" type="int" column="id">
			<generator class="native" />
		<property name="empName" column="emp_name" type="string" />
		<property name="address" column="address" type="string" />
		<property name="salary" column="salary" type="double" />


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
      <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
      <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
      <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
      <property name="hibernate.connection.username">system</property>
      <property name="hibernate.connection.password">ashok</property>

      <property name="">update</property>

      <mapping resource="com/ashok/hibernate/sample/hibernate.hbm.xml"/>

Command on Command prompt

java org.hibernate.tool.hbm2ddl.SchemaExport --config = hibernate.cfg.xml

Scroll to top