Java:XML到数据库中,最简单的方法是什么? [英] Java: XML into a Database, whats the simplest way?

查看:148
本文介绍了Java:XML到数据库中,最简单的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆XML文件和一个XSD文件。



我想简单地转换成POJO,然后将它们插入到数据库中。
数据库架构在我的控制之下,所以它可以是我喜欢的。



我环顾了一大堆apis,但想要另一个意见什么是最好的。


  • JAXB?

  • XMlBeans?

  • XPATH到DBUnit?



hibernate是否有一些api从XSD创建POJO,然后将XML读入这些POJO,然后将数据插入到数据库中?



或者spring有没有功能来帮助这个?



我想我只是在你的意见后,只是有一个API我错过了,这将有助于做我想做的。



感谢您
Jeff Porter

解决方案

绕过转换为POJO并将XML直接存储为CLOB的步骤。它将允许稍后进行鸭子打字,您可能会发现它有利。



如果您以后需要单独查询这些对象,映射到Java POJO是有意义的。如果您始终需要整个流,而无需查询XML中的值(例如XPath),那么我会说将XML存储为CLOB更有意义。


I have a load of XML files, and an XSD for them.

I'd like to simply convert then into POJO's and insert them into a database. The DB schema is under my control, so it can be what ever I like.

I've looked around at a load of apis, but wanted another opinion what works best.

  • JAXB?
  • XMlBeans?
  • XPATH to DBUnit?

Does hibernate have some api to create POJO's from an XSD, then read the XML into those POJOs, and then insert the data into the database?

Or does spring have any features to help with this?

I guess I'm just after your views, just incase there is an API I've missed that will do help do what I want.

Thanks Jeff Porter

解决方案

Or you could bypass the step of translating into POJOs and store the XML directly as a CLOB. It'll allow "duck typing" later on, which you might find advantageous.

Mapping to Java POJOs make sense if you need to query for those objects individually later on. If you need the entire stream, all the time, without ever having to query for values in the XML (e.g., XPath), then I'd say that storing XML as a CLOB makes more sense.

这篇关于Java:XML到数据库中,最简单的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆