Developing an XML Transaction Map

There may be situations when you want to read and write data
from an XML file instead of an RDBMS. For example, imagine working on
a banking project where you don't have direct access to bank's
database, and instead the customer provides you with sample data in
the form of XML files. Your requirement is that your
application should use these XML files during development, and a RDBMS
in production. We will take our contact application as example and
change it so that it will read and write data from an XML file
instead of an RDBMS. This requires two changes:

Add support for an external transactionManager in
your DAOMap.xml file.

In this example, XMLContactDAO implements the
ContactDAO business interface. Since we are using an
EXTERNAL transaction manager, we cannot use any of the
existing Template classes. In our class, we have created two simple
methods--loadChanges() and saveChanges--for reading and writing an XML file using the XStream framework. XStream is
open source framework that helps you read an XML file as a
Java object and save a Java object as an XML file.

Conclusion

Nowadays, a lot of new persistence frameworks are coming up. As
a developer, this is both good and bad for you. It's good because now
you have many more options to choose from. But it's bad because you
have to make choices. And the bigger problem is that you have to
commit to one persistence framework at the start of the project, at
which point you may not be completely clear on project requirements
or completely sure if a particular framework can fulfill all your
requirements. DAO is a very easy-to-use and useful framework that
guards against changes in persistence mechanisms. It may look like
you're making some investment up front, but it will definitely help
you in the long run.