I am creating a batch tool that must read data from a database, and put this data in a XML file, which is the application output.
Goal: the XML file contents must be a representation of the data contained in the database.
Starting point is a XSD file I have, which acts as a schema definition for both the database and XML file. First, I generated the database tables using a tool called XSD2DB which generates database tables based on the XSD.
Next, I have used JAXB xjc to generate Java classes based on the XSD.
Another process inserts the relevant data in the database.
Up until now I have instantiated one or two of the generated classes, read some data from the 'reflecting/accompanying' tables in my database, and I finally marshalled the objects to a XML file.
Since the XSD (and the database and XML file for that matter) is pretty large, I wonder if there is any way the database contents can be put in the XML, without having to populate my java objects explicitly. Lazy as I am, I'd like to use some sort of tool that automatically copies the database data to the XML file. While writing this, I am thinking of using Hibernate (JPA) and then JAXB marshalling as a two-step process.
Alternatives, ideas or insights are much appreciated.
Kjeld Sigtermans - SCJP 1.4 - SCWCD 1.4
subject: How to read from XSD generated database and put that data into XML file.