title: Hibernate: table lock with a select?
body: <p>I have this method that selects a row from table product_customer:</p>
  
  <pre><code>public static String getQuoziente(String pcCustomer, String pcAccountNumber, String prodCode) {
      String quoziente=null;
      Session session = HibernateUtil.getSessionFactory().openSession();
  
      try {
          String sql = String.format("SELECT pc_quoziente FROM product_customer " +
                  "WHERE pc_customer=:cliente and pc_account_number=:numacc  and pc_prod_desc=:prod");
          quoziente = (String) session.createSQLQuery(sql)
                  .setParameter("cliente", pcCustomer)
                  .setParameter("numacc", pcAccountNumber)
                  .setParameter("prod", prodCode)
                  .uniqueResult();
      } finally {
          session.close();
      }
      return quoziente;
  }
  </code></pre>
  
  <p>After this query try to truncate the table from MySqlWorkbench with:</p>
  
  <pre><code>TRUNCATE wla.product_customer; 
  </code></pre>
  
  <p>But truncate is blocked from a lock and never ends.
  Why should a simple select row lock the table?</p>
  
  <p>PS: i can delete rows with DELETE, only truncate is locked </p>