Hi all! If you have been reading this blog for a while, you must remember Steve Brodsky’s entry on pureQuery and pureXML. If you are a new reader of this blog or don’t remember Steve’s post, you can find it here.
In his entry, Steve described how both technologies were born and why both of them got the “pure” in the name. He finished the post by describing some of the integration points between pureQuery and pureXML. That’s where I jump in! Motivated by his post, I decided to create some code snippets to show you how you can plug pureQuery and pureXML together to create Java applications that persist data into a DB2 pureXML database. My initial plan was to put that in a blog post, but as I started writing it down, more ideas were flowing in my mind than I could actually fit a single blog entry, so I decided to work on a more complete article.
The article contains the code samples (available for download) that will get you started developing with pureQuery and pureXML, but its main focus is on the different approaches that one can use when developing such applications.
In a typical application development scenario with three layers – SQL, data access API and business logic - I suggest three different approaches to handle the XML data, each one focusing on a different layer. There are certainly more approaches you can use, and you can even mix and match some of them, but my main goal was to get you started with these two great technologies and to open your mind to different ways of thinking when it comes to integrating XML into your Java applications.
Without further ado, here are the approaches I suggest in the article:
- Give control to the SQL layer: With this approach, use the SQL layer to transform between XML and relational format so that the data can be used by the existing facilities provided by pureQuery.
- Give control to the data access API: With this approach, use an XML mapping framework (this article uses the mapping libraries of J2SE V6) to map between XML documents and Java objects, integrated in pureQuery's API custom handlers.
- Give control to the application layer: Implement your own mapping framework integrated in the Java beans that will represent your data in the business logic.
I hope you find it a good read! We continuously get questions from you, our customers, regarding this topic, so I hope I have answered them. After you are done reading it, go play with pureQuery (you can get it by downloading the trial version of Data Studio Developer) and pureXML yourself and make sure you give us your feedback, either here on the blog or on the Data Studio forum.
-- Vitor Rodrigues