XML for Queried Data

ADF Business Components helps you to transform queried data into xml format. Interestingly, you can manipulate this xml content without much effort, and the same can be posted back to database as well. Please refer this topic 39.7 Reading and Writing XML in Fusion Middleware Fusion Developer's Guide to learn more.

I'm attaching a simple demo application illustrating the usage of ViewObject::readXML(...) and ViewObject::writeXML(...) APIs.
You can download the sample workspace from here. Please see CRUDXMLTestClient.java file in the sample project.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

PS: Please note that ViewObject.readXML() will create new row, if the row that you supplied in the xml has not been retrieved by calling findByKey(). New row is inserted into the view object's rowset. Its attributes are populated using the values in any attribute element children of the current row element in the XML.

If the primary key for the new row(EntityObject) is populated using DB Sequence, please remove that attribute from the xml. ADF run time will take care the rest if you have proper implementation in your XXXEntityObjectImpl class to use DB Sequence.


  1. Hi jobinesh,
    Thank you for this informative article. But my scenario is quite a complex one and I am not sure how to achieve it. The following is my use case.
    I have a DB with a table filled with rows with one column as XMLTYPE. Now I need to use the entity and view objects to query, read and write back to this XMLTYPE column. I am hoping the read/write API in viewobject will come in handy, but not sure how to design it better.


  2. You can try ClobDomain type in BC and try mapping to XMLType (easiest apparoach) or this complex thing http://www.jobinesh.com/2013/02/using-xmltype-with-adf-business.html.

  3. thank you Jobinesh... I will followup the link u provided above and post my comment there further...

  4. Hi Jobinesh,
    In your example, will the following statement

    vo.writeXML(-1, viewDefMap)

    take care of all levels of data. Here, I don't see any option to provide depthCount.


Post a Comment