title: How to initialize SQLXML with Document object in Java
body: <p>How do I convert a <code>org.w3c.dom.Document</code> object to <code>java.sql.SQLXML</code> so that it can be persisted into the database using Hibernate? Currently I can get it to work by converting it to a String via <code>javax.xml.transform.Transformer</code>, but I imagine it is the least efficient approach. </p>
  
  <p>I have tried the following but nothing got saved into the DB column.</p>
  
  <pre><code>SQLXML sqlxml = session.connection().createSQLXML();
  sqlxml.setResult(DOMResult.class).setNode(myDocument);
  preparedStmt.setSQLXML(index, sqlxml);
  </code></pre>