Working with XML data
by, 10-25-2011 at 06:59 PM (1510 Views)
Hibernate allows us to work with persistent XML data same as POJOs. A parsed XML tree is actually a representation of relational data at the object level, instead of POJOs.
Hibernate uses dom4j API for manipulating XML trees. We can write queries that retrieve dom4j trees from the database and then all modifications to the tree automatically are synchronized to the database.
One can take an XML document, parse it using dom4j, and write it to the database with any of Hibernate's basic operations: persist(), saveOrUpdate(), merge(), delete(), replicate().
There are many applications of this feature like data import/export, externalization of entity data via JMS or SOAP and XSLT-based reporting. A single mapping can be used to map properties of a class and nodes of an XML document to the database. But if there is no class to map, it will be used to map just the XML.