0

At first my app was going to access a MySQL database, but everything changed and now it must read from a XML file, it will only read from it.

The basic idea is:
1. Admin App persist to MySQL.
2. Admin App generates a MySQL xml dump (mysqldump tool).
3. App send the xml to client.
4. Client query the xml.

Maybe there are more clever ways to architecture this, but right now this is not the point. Is there any Hibernate like XML - Relational to do this, how could I achieve this?

Tolio
  • 1,023
  • 13
  • 30

2 Answers2

0

How big is the XML going to be? To big to load into RAM or not? If not too big, load and use XPath. I recommend JDOM. If too big and you are not allowed to make any other files, use a streaming XPath solution (see this SO post), but then you've got quite a problem. Performance is going to be terrible. If you can transform it to another file, you might find an embedded DB that suits you (Derby, Hypersonic...).

Community
  • 1
  • 1
Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
  • The XML is not big. I don't have the current size right now but I' am sure it can be fully loaded in runtime. – Tolio Apr 16 '12 at 03:18
0

Ended using XStream to create my xml(instead of using the MySQL dump) and also to deserialize it. Worked like a charm.

The steps I followed.

  1. Created a Bean to serve as my root node, this bean hold lists of all the other beans.

  2. Did an xstream.toXML(myRootBean) and write it to a xml file.

  3. At the other end, read the file and did an xstream.fromXML() casting it to myRootBean.

  4. Then just access the lists, like myRootBean.getPotatoList()

Important to notice that you must set the alias for each class before toXML and fromXML.

xstream.alias("potatos", List.class);

xstream.alias("potato", Potato.class);

Tolio
  • 1,023
  • 13
  • 30