title: Hibernate select query is not returning the latest record from database
body: <p>I am working on a simple hibernate crud application where I am doing CRUD operation on a table LOCATION.
  I am using maven 3.0, hibernate 3.6, oracle 10g, java 8.</p>
  
  <p>I am performing these 4 operations.
  1) Insert a row in table Location(successful)
  2) Retrieve that row to check the status(successful)
  3) Updating one column of the same record(successful. Database is being updated)
  4) Retrieve the same row again. Here is the catch. I am not getting the updated state of the row which has already been updated in step 3. I am getting the result which was returned in step 2 retrieval.</p>
  
  <p>Here is my Main class.</p>
  
  <pre><code>public class App {
  
      public static void main(String[] args) {
          Session session = HibernateUtil.getSessionFactory().openSession();
          //step 1
          session.beginTransaction();
          saveLocation(session);
          session.getTransaction().commit();
          //step 2
          session.beginTransaction();
          retrieveLocation(session);
          session.getTransaction().commit();
          //step 3
          session.beginTransaction();
          updateLocation(session);
          session.getTransaction().commit();
          //step 4
          session.beginTransaction();
          retrieveLocation(session);
          session.getTransaction().commit();
  
      }
  
      private static void saveLocation(final Session session) {
          Location location = new Location();
          location.setZip("751001");
          location.setCity("Bhubaneswar");
          location.setCountry("India");
          location.setRegion("Asia pacific");
          session.save(location);
      }
  
      private static void retrieveLocation(final Session session) {
          Query query = session.createQuery("from org.bhawani.practice.hibernate.location.Location where zip = :zip");
          query.setParameter("zip", "751001");
          List&lt;Location&gt; locations = query.list();
          for (Location location : locations) {
              System.out.println("City: " + location.getCity());
          }
      }
  
      private static void updateLocation(final Session session) {
          Query query = session.createQuery(
                  "update org.bhawani.practice.hibernate.location.Location set city = :city where zip = :zip");
          query.setParameter("city", "Cuttack");
          query.setParameter("zip", "751001");
          query.executeUpdate();
      }
  
  }
  </code></pre>
  
  <p>Here is my model class Location.java</p>
  
  <pre><code>package org.bhawani.practice.hibernate.location;
  
  public class Location {
      private String zip;
      private String city;
      private String country;
      private String region;
  
      public Location() {
      }
  
      public String getZip() {
          return zip;
      }
  
      public void setZip(String zip) {
          this.zip = zip;
      }
  
      public String getCity() {
          return city;
      }
  
      public void setCity(String city) {
          this.city = city;
      }
  
      public String getCountry() {
          return country;
      }
  
      public void setCountry(String country) {
          this.country = country;
      }
  
      public String getRegion() {
          return region;
      }
  
      public void setRegion(String region) {
          this.region = region;
      }
  
  }
  </code></pre>
  
  <p>Here is my hibernate mapping xml.</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;!DOCTYPE hibernate-mapping PUBLIC 
       "-//Hibernate/Hibernate Mapping DTD//EN"
       "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
      &lt;hibernate-mapping&gt;
      &lt;class name="org.bhawani.practice.hibernate.location.Location"
          table="LOCATION"&gt;
          &lt;id name="zip" type="string"&gt;
              &lt;column name="ZIP" /&gt;
              &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;property name="city" type="string"&gt;
              &lt;column name="CITY" /&gt;
          &lt;/property&gt;
          &lt;property name="country" type="string"&gt;
              &lt;column name="COUNTRY" /&gt;
          &lt;/property&gt;
          &lt;property name="region" type="string"&gt;
              &lt;column name="REGION" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
      &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Here is my table description.</p>
  
  <pre><code>Name    Null     Type               
  ------- -------- ------------------ 
  ZIP     NOT NULL VARCHAR2(255 CHAR) 
  CITY             VARCHAR2(255 CHAR) 
  COUNTRY          VARCHAR2(255 CHAR) 
  REGION           VARCHAR2(255 CHAR) 
  </code></pre>
  
  <p>Here is my hibernate config file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration SYSTEM 
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@127.0.0.1:1521:XE&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;hr&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;admin&lt;/property&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/property&gt;
          &lt;property name="hibernate.default_schema"&gt;HR&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;mapping resource="org/bhawani/practice/hibernate/location/Location.hbm.xml" /&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>