title: Saving instance into the database
body: <p>I am practising one of the existing JSF+Spring+Hibernate integration examples on the web.Here is the Employee.java:</p>
  
  <pre><code>package com.hibernate.data;
  
  import java.util.Date;
  
  public class Employee {
  private long employeeId;
  private String employeeName;
  private Date employeeHireDate;
  private double employeeSalary;
  
  public long getEmployeeId(){
  return employeeId;
  }
  public void setEmployeeId(long employeeId){
  this.employeeId = employeeId;
  }
  public String getEmployeeName(){
  return employeeName;
  }
  public void setEmployeeName(String employeeName) {
  this.employeeName = employeeName;
  }
  
  public Date getEmployeeHireDate() {
  return employeeHireDate;
  }
  
  public void setEmployeeHireDate(Date employeeHireDate) {
  this.employeeHireDate = employeeHireDate;
  }
  
  public double getEmployeeSalary() {
  return employeeSalary;
  }
  
  public void setEmployeeSalary(double employeeSalary) {
  this.employeeSalary = employeeSalary;
  }
  }
  </code></pre>
  
  <p>This is the pom.xml file:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.journaldev&lt;/groupId&gt;
    &lt;artifactId&gt;Primefaces-Hibernate-Spring-Integration-Sample&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;Primefaces-Hibernate-Spring-Integration-Sample Maven Webapp&lt;/name&gt;
    &lt;build&gt;
      &lt;plugins&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.6&lt;/source&gt;
            &lt;target&gt;1.6&lt;/target&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;prime-repo&lt;/id&gt;
              &lt;name&gt;PrimeFaces Maven Repository&lt;/name&gt;
              &lt;url&gt;http://repository.primefaces.org&lt;/url&gt;
              &lt;layout&gt;default&lt;/layout&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;dependencies&gt;
          &lt;!-- Servlet --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;!-- Faces Implementation --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-impl&lt;/artifactId&gt;
              &lt;version&gt;2.2.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Faces Library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.faces&lt;/groupId&gt;
              &lt;artifactId&gt;jsf-api&lt;/artifactId&gt;
              &lt;version&gt;2.2.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Primefaces Version 5 --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces&lt;/groupId&gt;
              &lt;artifactId&gt;primefaces&lt;/artifactId&gt;
              &lt;version&gt;5.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- JSP Library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet.jsp-api&lt;/artifactId&gt;
              &lt;version&gt;2.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- JSTL Library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.1.2&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Primefaces Theme Library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.primefaces.themes&lt;/groupId&gt;
              &lt;artifactId&gt;blitzer&lt;/artifactId&gt;
              &lt;version&gt;1.0.10&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- Hibernate library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.6.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;!-- MySQL driver connector library --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.31&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>hibernate.cfg.xml:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
   
  &lt;hibernate-configuration&gt;
   
      &lt;session-factory&gt;
   
          &lt;!-- Database connection settings --&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://localhost:3306/journaldev&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;root&lt;/property&gt;
   
          &lt;!-- SQL dialect --&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
          &lt;!-- Specify session context --&gt;
          &lt;property name="hibernate.current_session_context_class"&gt;org.hibernate.context.internal.ThreadLocalSessionContext&lt;/property&gt;
          &lt;!-- Show SQL --&gt;
          &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt;
          &lt;!-- Referring Mapping File --&gt;
          &lt;mapping resource="domain-classes.hbm.xml"/&gt;
      &lt;/session-factory&gt;
   
  &lt;/hibernate-configuration&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>domain-classes.hbm.xml:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping
  PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="com.hibernate.data.Employee" table="employee"&gt;
          &lt;id name="employeeId" column="EMP_ID" type="long"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property name="employeeName" column="EMP_NAME" type="string"/&gt;
          &lt;property name="employeeHireDate" column="EMP_HIRE_DATE" type="date"/&gt;
          &lt;property name="employeeSalary" column="EMP_SALARY" type="double"/&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Main.java:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package com.test;
  
  import java.util.Date;
  
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.cfg.Configuration;
  
  import com.hibernate.data.Employee;
  
  public class Main {
  public static void main(String [] args){
      //Create a configuration instance
      Configuration configuration = new Configuration();
      //Provide configuration file
      configuration.configure("hibernate.cfg.xml");
      //Build a SessionFactory
      SessionFactory factory = configuration.buildSessionFactory(new  StandardServiceRegistryBuilder().configure().build());
      //Get current session, current session is already associated with  Thread
      Session session = factory.getCurrentSession();
      //Begin transaction, if you would like save your instance
      session.getTransaction().begin();
      //Create employee
      Employee emp = new Employee();
      emp.setEmployeeName("Peter Jousha");
      emp.setEmployeeSalary(2000);
      emp.setEmployeeHireDate(new Date());
      //Save
      session.save(emp);
      //Commit,calling of commit will cause save an instance of employee
      session.getTransaction().commit();
  }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>At this stage of implementing, I should see that the instance automatically is added to the database.But nothing changed in my database. How can I fix that?</p>