title: Execute native sql with hibernate
body: <p>I'm using <code>hibernate 4.2.6</code> and <code>PostgreSQL 9.1</code>
  I've been trying to execute sql query with hibernate. I've written:</p>
  
  <pre><code>Session session = Hibernate.util.HibernateUtil.getSessionFactory().openSession();
  session.beginTransaction();
  String sql = String.format("INSERT INTO products (name,cost) VALUES('%s',%s);", product.getName(), product.getCost());
  createSQLQuery(sql);//has no effect. Query doesn't execute.
  session.getTransaction().commit();
  session.close();
  </code></pre>
  
  <p>This query does not executed in DB. But if I write</p>
  
  <pre><code>String sql = String.format("INSERT INTO products (name,cost) VALUES('%s',%s);", product.getName(), product.getCost());
  Properties connectionProps = new Properties();
  connectionProps.put("user", "postgres");
  connectionProps.put("password", "123");
  Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/solid",connectionProps);
  conn.createStatement().execute(sql);
  </code></pre>
  
  <p>corresponding row will add to table. Why hibernate doesn't work, but native query wth JDBC works?</p>