Alexander Mills
Alexander Mills

Reputation: 100080

Java XML format to save directly to relational or non-relational DB

Is there a standard XML format to save Java objects into relational or non-relational databases?

I am looking for something in Java akin to how you can save JSON directly into MongoDB (as BSON).

It doesn't have to be a non-relational database, something with an ORM process would do.

So it would be a Java object represented by XML (or something similar) then the XML could be sent over a wire to be saved in a DB. Maybe there's no point in doing this for relational databases.

Is JAXB the only game in town?

Upvotes: 1

Views: 176

Answers (1)

Rob
Rob

Reputation: 6497

I have used HyperJaxb3 with great success. It is a JAXB plugin that takes the XSD for your XML and puts JPA annotations on your generated Java classes. This allows you to map your XML documents to SQL tables such that everything is exposed in your relational database. Round-tripping XML documents through the database is trivial.

The JPA details are highly customizable either in-line in your XSD or in a separate bindings file. HyperJaxb3 is open source and the author has been helpful in answering the few questions that I have had. He is active on Stack Overflow.

Upvotes: 1

Related Questions