title: Why doesn't hibernate load persisted entity from second level cache?
body: <p>Does hibernate put into second level cache entity which I persist with save method?</p>
  
  <p>My code is :</p>
  
  <pre><code>Session session = sessionFactory.openSession();
  
          Transaction transaction = session.beginTransaction();
  
          Person person = new Person("Volodia", "Levytskyi", "Mykolaiv");
          session.save(person);
          transaction.commit();
          session.close();
  
          session = sessionFactory.openSession();
          transaction = session.beginTransaction();
  
          Person load = (Person) session.load(Person.class, (long) 1);
          System.out.println("load2=" + load);
          transaction.commit();
          session.close();
  </code></pre>
  
  <p>I expect hibernate to load from second level cache person but it issues select query to database when </p>
  
  <pre><code>session.load(Person.class, (long) 1);
  </code></pre>
  
  <p>is running.</p>
  
  <p>My hibernate.cfg.xml:</p>
  
  <pre><code>&lt;session-factory&gt;
          &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/property&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/hibernateSimpleDB&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;root&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;&lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;property name="format_sql"&gt;true&lt;/property&gt;
          &lt;property name="transaction.factory_class"&gt;org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory&lt;/property&gt;
  
          &lt;property name="hibernate.hbm2ddl.auto"&gt;create&lt;/property&gt;
  
          &lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
  
          &lt;property name="hibernate.cache.region.factory_class"&gt;org.hibernate.cache.ehcache.EhCacheRegionFactory&lt;/property&gt;
          &lt;property name="hibernate.generate_statistics"&gt;true&lt;/property&gt;
  
          &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
  
          &lt;mapping resource="com/masterhibernate/SimpleHibernateDemo/Person.hbm.xml" 
              /&gt;
  
          &lt;!-- &lt;mapping class="com.masterhibernate.SimpleHibernateDemo.Person" /&gt; --&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>My Person.hbm.xml :</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
      &lt;class name="com.masterhibernate.SimpleHibernateDemo.Person"
          table="Person"&gt;
          &lt;cache usage="read-write" /&gt;
  
          &lt;id name="id" column="PersonId"&gt;
              &lt;generator class="native" /&gt;
          &lt;/id&gt;
          &lt;property name="name"&gt;
              &lt;column name="name" length="16" not-null="true" /&gt;
          &lt;/property&gt;
          &lt;property name="surname"&gt;
              &lt;column name="surname" length="36"&gt;&lt;/column&gt;
          &lt;/property&gt;
          &lt;property name="address"&gt;
              &lt;column name="address" length="22"&gt;&lt;/column&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Why is this?</p>