title: Hibernate query.executeUpdate() not working properly
body: <p>Hibernate query.executeUpdate() is not working..</p>
  <p>Here is the code  for updating</p>
  <pre><code>   public static void expDue(){
     Session session=HibernateUtil.getSessionFactory().openSession();
      java.util.Date utilDate=new java.util.Date();
      java.sql.Date sqldate=new java.sql.Date(utilDate.getTime());
      Format formatter = new SimpleDateFormat(&quot;yyyy-MM-dd&quot;);
      String a= formatter.format(sqldate);      
      boolean b=false;
      if(b==false){
      Query query = session.createQuery(&quot; update Issue set dueStatus = 'true' where returnDate='&quot;+a+&quot;'&quot;);
      int result = query.executeUpdate();
      System.out.println(query.executeUpdate()+&quot;Rows affected: &quot; + result);
      b=true;
      }
  </code></pre>
  <p>Here, printing the result shows correct value, but no change in database.</p>
  <p>And hibernate code</p>
  <pre><code>&lt;hibernate-configuration&gt;
    &lt;session-factory&gt;
      &lt;!-- SQL dialect --&gt;
      &lt;property name=&quot;dialect&quot;&gt;org.hibernate.dialect.HSQLDialect&lt;/property&gt; 
   
      &lt;!-- Database connection settings --&gt; 
      &lt;property name=&quot;hibernate.connection.driver_class&quot;&gt;org.hsqldb.jdbcDriver&lt;/property&gt;
          &lt;property name=&quot;hibernate.connection.url&quot;&gt;jdbc:hsqldb:db/hsql/library;shutdown=true&lt;/property&gt;
          &lt;property name=&quot;hibernate.connection.username&quot;&gt;sa&lt;/property&gt;
          &lt;property name=&quot;hibernate.connection.password&quot;&gt;sa&lt;/property&gt;
          &lt;property name=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.HSQLDialect&lt;/property&gt;
      
   
      &lt;!-- JDBC connection pool (use the built-in one) --&gt;
      &lt;property name=&quot;connection.pool_size&quot;&gt;1&lt;/property&gt; 
   
      &lt;!-- Enable Hibernate's automatic session context management --&gt;
      &lt;property name=&quot;current_session_context_class&quot;&gt;thread&lt;/property&gt;
   
      &lt;!-- Disable the second-level cache  --&gt; 
      &lt;property
       name=&quot;cache.provider_class&quot;&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt;
   
      &lt;!-- disable batching so HSQLDB will propagate errors correctly. --&gt;
      &lt;property name=&quot;jdbc.batch_size&quot;&gt;0&lt;/property&gt; 
   
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name=&quot;show_sql&quot;&gt;true&lt;/property&gt; 
   
      &lt;!-- List all the mapping documents we're using --&gt; 
      &lt;mapping class=&quot;com.habitz.librarymanagement.domain.Admin&quot; /&gt;
          &lt;mapping class=&quot;com.librarymanagement.domain.Book&quot; /&gt;
          &lt;mapping class=&quot;com.librarymanagement.domain.Category&quot; /&gt;
          &lt;mapping class=&quot;com.librarymanagement.domain.Group&quot; /&gt;
          &lt;mapping class=&quot;com.librarymanagement.domain.Issue&quot; /&gt;
          &lt;mapping class=&quot;com.librarymanagement.domain.Member&quot; /&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  <p>In console printing the result shows correct values. But the database shows no change...</p>
  <p>If you know about this please share answers here...</p>
  <p><strong>UPDATE</strong></p>
  <pre><code>Transaction tx = null;
          tx = session.beginTransaction();
              Query query = session
                      .createQuery(&quot; update Issue set dueStatus = 'true' where returnDate='&quot;
                              + a + &quot;'&quot;);
          
              int result = query.executeUpdate();
              System.out.println(query.executeUpdate() + &quot;Rows affected: &quot;
                      + result);  
              tx.commit();
  </code></pre>