Elbonian
Elbonian

Reputation: 1118

XML vs. object trees

In my current project (an order management system build from scratch), we are handling orders in the form of XML objects which are saved in a relational database.

I would outline the requirements like this:

What we did:

The problems we face:

Performance is not really an issue (yet), since it is an offline system and orders are often intentionally delayed by days.

I do not expect free consultancy here, but I am a little confused on how the approach could be improved (next time, basically).

What would you think is a good solution for handling these requirements? Would working with an object graph, something like JXPath and OGNL and an OR mapper be a better approach? Or using XML support of e.g. the Oracle database?

Upvotes: 2

Views: 348

Answers (2)

Jochen Bedersdorfer
Jochen Bedersdorfer

Reputation: 4122

If your schema changes often, I would advise against using any kind of object-mapping. You'd keep changing boilerplate code just for the heck of it.

Instead, use the declarative schema definition to validate data changes and access. Consider an order as a single datum, expressed as an XML document. Use a document-oriented store like MongoDB, Cassandra or one of the many XML databases to manipulate the document directly. Don't bother with cutting it into pieces to store it in a relational db.

Making the data accessible via reporting tools in a relational database might be considered secondary. A simple map-reduce job on a MongoDB, for example, could populate the required order details into a relational database whenever required, separating the two use cases quite naturally.

Upvotes: 1

bdoughan
bdoughan

Reputation: 149007

The standard Java EE approach is to represent your data as POJOs and use JPA for the database access and JAXB to convert the objects to/from XML.

JPA

  • Object-to-Relational standard
  • Supported by all the application server vendors.
  • Multiple available implementations EclipseLink, Hibernate, etc.
  • Powerful query language JPQL (that is very similar to SQL)
  • Handles query optimization for you.

JAXB

  • Object-to-XML standard
  • Supported by all the application server vendors.
  • Multiple implementations available: EclipseLink MOXy, Metro, Apache JaxMe, etc.

Example

Upvotes: 1

Related Questions