Skip to main content

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 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.


oceans said…
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.

You can try ClobDomain type in BC and try mapping to XMLType (easiest apparoach) or this complex thing
oceans said…
thank you Jobinesh... I will followup the link u provided above and post my comment there further...
Diwakar Rajana said…
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.

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!