title: Hibernate save sql to file
body: <p>I'd like to serialize entity to SQL-query string and save it into .txt file to be able to write it into database later. I need the solution to work regardless of SQL dialect, so I'd like to use Hibernate.</p>
  
  <p>Is it possible to do it with Hibernate? Could you give me a clue or tutorial how could I accomplish this?</p>
  
  <p>Let's assume we have an Entity:</p>
  
  <pre><code>@Entity  
  public class Project {
         @Id
         @GeneratedValue(strategy = GenerationType.SEQUENCE)
         private Long id;
         private String name;
  
         //... setters, getters and constructor
  }
  </code></pre>
  
  <p>And I'd like to serialize some entities to strings of SQL statements like the following:</p>
  
  <pre><code>INSERT INTO project (name)
  VALUES ('SQL Convertion Project');
  INSERT INTO project (name)
  VALUES ('DB Migration');
  INSERT INTO project (name)
  VALUES ('Stackoverflow is cool');
  </code></pre>