title: Getting same session object
body: <p>In simple hibernate program i am getting detail of Employee table by using following code. :-
  <strong>Employee employee = (Employee) session.get(Employee.class, new Integer(6));</strong>
  and same time i print the information in console 
  System.out.println("Name : -"+employee.getName() + "Address :- " + employee.getAddress());</p>
  
  <p>Now paused the execution for 15000 ms.  <strong>Thread.sleep(15000);</strong>
  during this time i go through database and manually change the details of employee table.
  when <strong>15000ms completed</strong> , then i clear session cache and again try to fetch same record but i'm getting same object having same information  . whatever information change during sleep time would not be reflected.</p>
  
  <p>below is the program</p>
  
  <p>Configuration configuration = new Configuration();</p>
  
  <pre><code>configuration.configure("hibernate.cfg.xml");
  ServiceRegistry registry = (ServiceRegistry) builder.buildServiceRegistry();
  builder.applySettings(configuration.getProperties());
  ServiceRegistry registry = (ServiceRegistry) builder.buildServiceRegistry();
  factory = configuration.buildSessionFactory(registry);
  
  Session session = factory.openSession();
  Transaction transaction = session.beginTransaction();
  
  Employee employee = (Employee) session.get(Employee.class, new Integer(6));
  System.out.println("Name : -" + employee.getName() + "Address :- " + employee.getAddress());
  
  Thread.sleep(15000);
  //now i made change in database going through the mysql workbench and manually change the details of emp id 6.
  
  System.out.println(" cache remove");
  session.evict(employee);
  session.flush();
  
  Employee employee1 = (Employee) session.get(Employee.class, new Integer(6));
  System.out.println("Name : -" + employee1.getName() + "Address :- " + employee1.getAddress());
  printEmp(employee);
  session.getTransaction().commit();
  session.close();
  </code></pre>