title: XML to Relational with DB2 and Java (and Hibernate?)
body: <p>What I have here is a bunch of XML-Files containing data and a nice ER-Model to which the data belongs. What my problem is: I need to get this data into a db2. The tables with all necessary attributes and keys are already created.
  I was thinking of three different solutions: </p>
  
  <ol>
  <li><p>Parsing the XML and creating SQL-Queries from it. This solution seems straight forward but would require a lot of rather ugly string comparations and the like.</p></li>
  <li><p>Inserting the XML into the database and levering pureXML to query the data from it and then inserting it into the relational tables. This would require some tinkering with pureXML or XML Extender as I'm not really familiar with them.</p></li>
  <li><p>The IMHO most elegant solution. Creating an object model of the ER-model and a Hibernate mapping. Than use reflection to create objects from the XML data. Than somehow get the relations between the objects right (This isprobably the hardest part.) and let Hibernate to the rest.</p></li>
  </ol>
  
  <p>Is there another way I have overlooked? What solution would you prefer? Is think there are a lot of pitfalls along the way with either solution and I'm afraid I completely missed something.</p>